diff options
| author | Tim Redfern <tim@herge.(none)> | 2013-07-26 17:06:55 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@herge.(none)> | 2013-07-26 17:06:55 +0100 |
| commit | 7092eaaae3e844a68804b8a6b6825381e9a81443 (patch) | |
| tree | 2d65ea068c5bc6c678f9dc3e2c456a6f6b15b83d /rotord | |
| parent | 6f7be98c7289aedd9e45f9fafcc67ac6348cebf2 (diff) | |
cairo library and first drawing node
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/Makefile | 4 | ||||
| -rw-r--r-- | rotord/cvimage.h | 3 | ||||
| -rw-r--r-- | rotord/nodes_drawing.h | 43 | ||||
| -rwxr-xr-x | rotord/rotor.cpp | 1 | ||||
| -rwxr-xr-x | rotord/rotor.h | 27 |
5 files changed, 49 insertions, 29 deletions
diff --git a/rotord/Makefile b/rotord/Makefile index 270cd8c..41ededb 100644 --- a/rotord/Makefile +++ b/rotord/Makefile @@ -3,13 +3,13 @@ #http://docs.gstreamer.com/display/GstSDK/Installing+on+Linux #MY_CFLAGS = -fpermissive -std=c++11 -Wno-error -I /opt/gstreamer-sdk/include/gstreamer-0.10/ -I /opt/gstreamer-sdk/include/glib-2.0 -I /opt/gstreamer-sdk/lib/glib-2.0/include -I /opt/gstreamer-sdk/include/libxml2 $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags) -MY_CFLAGS = -fpermissive -std=c++11 -I /usr/include/opencv +MY_CFLAGS = -fpermissive -std=c++11 -I /usr/include/opencv -I /usr/include/cairo #-Wno-error $(shell pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 --cflags) # -I ../ffmpeg # The linker options.libgstaasinklibgstaasink.so -MY_LIBS = -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 = -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 = -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 #MY_LIBS = ../libavcodec/ffmpeg/libavcodec/libavcodec.a ../libavcodec/ffmpeg/libavutil/libavutil.a ../libavcodec/ffmpeg/libavformat/libavformat.a ../libavcodec/ffmpeg/libavfilter/libavfilter.a ../libavcodec/ffmpeg/libavdevice/libavdevice.a -lPocoNet -lPocoXML -lPocoUtil -lPocoFoundation -lvamp-hostsdk diff --git a/rotord/cvimage.h b/rotord/cvimage.h index 81233a0..2f9ed3b 100644 --- a/rotord/cvimage.h +++ b/rotord/cvimage.h @@ -87,6 +87,9 @@ namespace Rotor { h=0; ownsRGBdata=ownsAdata=ownsZdata=false; } + int getStride(){ + return w*3; + } bool setup(int _w,int _h){ //set up with internal data rgb.create(_h,_w,CV_8UC3); RGBdata=rgb.data; //can move to use the bare pointer eventually diff --git a/rotord/nodes_drawing.h b/rotord/nodes_drawing.h new file mode 100644 index 0000000..11df2d6 --- /dev/null +++ b/rotord/nodes_drawing.h @@ -0,0 +1,43 @@ +#ifndef ROTOR_NODES_DRAWING +#define ROTOR_NODES_DRAWING + +#include "rotor.h" +#include <cairo.h> + +namespace Rotor { + class Draw: public Image_node { + public: + Draw(){image=nullptr;}; + Draw(map<string,string> &settings) { + base_settings(settings); + }; + ~Draw(){ if (image) delete image;}; + Draw* clone(map<string,string> &_settings) { return new Draw(_settings);}; + Image *output(const Frame_spec &frame){ + if (image_inputs.size()) { + if (image_inputs[0]->connection){ + //copy incoming image **writable + if (image) delete image; + image=(((Image_node*)image_inputs[0]->connection)->get_output(frame))->clone(); + } + else image->setup(frame.w,frame.h); + } + else image->setup(frame.w,frame.h); //do this twice or use a goto + //draw onto new or input image + cairo_surface_t * cs = cairo_image_surface_create_for_data (image->RGBdata, + CAIRO_FORMAT_RGB24, + image->w, + image->h, + image->getStride()); + cairo_t *c=cairo_create(cs); + cairo_rectangle(c, image->w/2, image->h/2, image->w, image->h); + cairo_set_source_rgb(c, 1.0, 0.0, 0.0); + cairo_fill(c); + return image; + } + private: + Image *image; //is an image generator + }; +} + +#endif
\ No newline at end of file diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index d1865ee..8b72c50 100755 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -1,5 +1,6 @@ #include "rotor.h" #include "nodes_audio_analysis.h" +#include "nodes_drawing.h" using namespace Rotor; Node_factory::Node_factory(){ diff --git a/rotord/rotor.h b/rotord/rotor.h index abba4cf..f922fcf 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -20,8 +20,6 @@ http://stackoverflow.com/questions/5261658/how-to-seek-in-ffmpeg-c-c #include <memory> #include <sys/time.h> #include <iostream> -//#include <cairo.h> - #include "Poco/Net/HTTPServer.h" #include "Poco/Net/HTTPResponse.h" @@ -1263,31 +1261,6 @@ namespace Rotor { private: Image *image; //is an image generator }; - class Draw: public Image_node { - public: - Draw(){image=nullptr;}; - Draw(map<string,string> &settings) { - base_settings(settings); - }; - ~Draw(){ if (image) delete image;}; - Draw* clone(map<string,string> &_settings) { return new Draw(_settings);}; - Image *output(const Frame_spec &frame){ - if (image_inputs.size()) { - if (image_inputs[0]->connection){ - //copy incoming image **writable - if (image) delete image; - image=(((Image_node*)image_inputs[0]->connection)->get_output(frame))->clone(); - } - else image->setup(frame.w,frame.h); - } - else image->setup(frame.w,frame.h); //do this twice or use a goto - //draw onto new or input image - - return image; - } - private: - Image *image; //is an image generator - }; //------------------------------------------------------------------- class Node_factory{ public: |
