From fd2cdacf49b101658de7e0a624c84897a398e62e Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 12 Sep 2013 14:28:32 +0100 Subject: thumbnail function --- rotord/src/graph.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'rotord/src/graph.h') diff --git a/rotord/src/graph.h b/rotord/src/graph.h index b2132b9..6ade53e 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -1,6 +1,8 @@ #ifndef GRAPH_H #define GRAPH_H +#include "Poco/StringTokenizer.h" + #include "rotor.h" #include "nodes_audio_analysis.h" @@ -31,7 +33,7 @@ namespace Rotor { for (auto n: nodes) { delete n.second; } - nodes.clear(); + nodes.clear(); } string uid; //every version of a graph has a UUID, no particular need to actually read its data(?) //?? is it faster than using strings?? @@ -64,5 +66,22 @@ namespace Rotor { int outW,outH; }; + class Thumbnailer{ + public: + bool make(const string &inputfilename,int w,int h,const string &outputfilename) { + if (player.open(inputfilename)){ + if (player.fetchFrame(w,h,player.getNumberOfFrames()/4)) { + Image i; + i.setup_fromRGB(w,h,player.frame->Data[0],player.frame->Linesize[0]-(w*3)); + cv::imwrite(outputfilename.c_str(),i.rgb); + return true; + + } + } + return false; + } + private: + libav::ffms2_decoder player; + }; } #endif -- cgit v1.2.3