summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-08-28 21:51:56 +0100
committerComment <tim@gray.(none)>2013-08-28 21:51:56 +0100
commit1aacbf3bb5dee98bc5ab4994e1907a8416811941 (patch)
treee7057c80480f7ebb1d9d2998fcf6a5759b42668f
parentcaed9b7b05005ee2bcec8e7262bf5f63fe2a4df8 (diff)
preview in XML base64
-rw-r--r--rotord/Makefile2
-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
5 files changed, 26 insertions, 10 deletions
diff --git a/rotord/Makefile b/rotord/Makefile
index 2842cf1..25159b0 100644
--- a/rotord/Makefile
+++ b/rotord/Makefile
@@ -9,7 +9,7 @@ MY_CFLAGS = -fpermissive -std=c++11 -I /usr/include/opencv -I /usr/include/cairo
# -I ../ffmpeg
# The linker options.libgstaasinklibgstaasink.so
-MY_LIBS = -ljsoncpp -lcairo -lopencv_core -lopencv_video -lopencv_imgproc -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil -lstdc++ -lm
+MY_LIBS = -ljsoncpp -lcairo -lopencv_core -lopencv_video -lopencv_imgproc -lopencv_highgui -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil -lstdc++ -lm
#-lopencv_highgui
#MY_LIBS = -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk -lsndfile -L /usr/local/lib -lswscale -lavcodec -lavformat -lavfilter -lavdevice -lavutil $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --libs)
# -lgstreamer-0.10 -lgstreamer-video-0.10 -lgstreamer-base-0.10 -lglib-2.0 -lgstapp-0.10
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;