diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-08-29 15:35:58 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-08-29 15:35:58 +0100 |
| commit | feb34d02ff8ef3c9cbe9e5a948a461c81d9b4d1a (patch) | |
| tree | ddfec0212c0969e6976cd7099008fa87f55083ce /rotord | |
| parent | 486a76df31169f2b510ae26e8252783d8f90de27 (diff) | |
| parent | 1aacbf3bb5dee98bc5ab4994e1907a8416811941 (diff) | |
Merge branch 'master' of eclectronics.org@eclectronics.org:rotor
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/src/graph.cpp | 28 | ||||
| -rw-r--r-- | rotord/src/rendercontext.cpp | 3 | ||||
| -rwxr-xr-x | rotord/src/rotor.h | 2 |
3 files changed, 24 insertions, 9 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 9536fdc..03192f3 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -33,20 +33,34 @@ bool Graph::signal_render(string &signal_xml,const float framerate) { return false; } */ -bool Graph::preview(xmlIO &XML,string node,int frame,int w,int h){ - // - //bool imencode(const string& ext, InputArray img, vector<uchar>& buf, const vector<int>& params=vector<int>()) - //if (find_node_id) +bool Graph::preview(xmlIO &XML,string &node,string &_format,int frame,int w,int h){ if (nodes.find(node)!=nodes.end()){ - float t=frame*framerate; + float t=frame/framerate; + XML.addTag("preview"); + XML.addAttribute("preview","frame",ofToString(frame),0); + XML.addAttribute("preview","nodeID",node,0); + XML.pushTag("preview"); if (dynamic_cast<Signal_node*>(nodes[node])){ Time_spec ts=Time_spec(t,framerate,0.0f); XML.addValue("signal",dynamic_cast<Signal_node*>(nodes[node])->get_output(ts)); - return true; } if (dynamic_cast<Image_node*>(nodes[node])){ - return true; + Frame_spec fs=Frame_spec(t,framerate,0.0f,w,h); + Image *img=dynamic_cast<Image_node*>(nodes[node])->get_output(fs); + vector<uchar> buf; + string format=(_format==""?".png":_format); + if (cv::imencode(format,img->rgb,buf)){ //, const vector<int>& params=vector<int>()) + stringstream output; + Poco::Base64Encoder *enc=new Poco::Base64Encoder(output); + enc->write(buf.data(),buf.size()); + enc->close(); + delete enc; + XML.addValue("image",output.str()); + XML.addAttribute("image","format",format,0); + } } + XML.popTag(); + return true; } return false; } diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index b93f39d..7d85cce 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -312,7 +312,8 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H int frame=root["frame"].asInt(); int width=root["width"].asInt(); int height=root["height"].asInt(); - if (graph.preview(XML,preview_node,frame,width,height)) { + string format=root["format"].asString(); + if (graph.preview(XML,preview_node,format,frame,width,height)) { status=HTTPResponse::HTTP_OK; } else { diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 77f7743..ae6b849 100755 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -1242,7 +1242,7 @@ namespace Rotor { bool parseXml(string media_path); bool parseJson(string &data,string &media_path); bool set_resolution(int w,int h); - bool preview(xmlIO &XML,string node,int frame,int w,int h); + bool preview(xmlIO &XML,string &node,string &format,int frame,int w,int h); bool loaded; float duration; float framerate; |
