summaryrefslogtreecommitdiff
path: root/rotord/src
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src')
-rw-r--r--rotord/src/cvimage.h1
-rw-r--r--rotord/src/graph.cpp28
-rw-r--r--rotord/src/rendercontext.cpp3
-rwxr-xr-xrotord/src/rotor.h2
4 files changed, 25 insertions, 9 deletions
diff --git a/rotord/src/cvimage.h b/rotord/src/cvimage.h
index dc421de..68bdb48 100644
--- a/rotord/src/cvimage.h
+++ b/rotord/src/cvimage.h
@@ -3,6 +3,7 @@
#include <math.h>
#include <cv.h>
+#include <highgui.h>
//converting to use a cv image...
//cv::Mat supports most of what we want here
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 299510a..2f0fab1 100755
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -1214,7 +1214,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;