From 6fe1b6e664f2a5d26e5ace7c7082169b656eef05 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 15 Jul 2013 15:47:48 +0100 Subject: transform node working --- rotord/cvimage.h | 10 +++++++--- rotord/rotor.cpp | 2 +- rotord/rotor.h | 25 +++++++++++++++++++++---- 3 files changed, 29 insertions(+), 8 deletions(-) (limited to 'rotord') diff --git a/rotord/cvimage.h b/rotord/cvimage.h index cbf2840..6c237b4 100644 --- a/rotord/cvimage.h +++ b/rotord/cvimage.h @@ -85,7 +85,7 @@ namespace Rotor { ownsRGBdata=ownsAdata=ownsZdata=false; } bool setup(int _w,int _h){ //set up with internal data - rgb.create(_w,_h,CV_8UC3); + rgb.create(_h,_w,CV_8UC3); RGBdata=rgb.data; //can move to use the bare pointer eventually ownsRGBdata=false; //will not be necessary w=_w; @@ -108,8 +108,12 @@ namespace Rotor { bool setup_fromRGB(int _w,int _h,uint8_t *pRGBdata,int linepadding=0){ //here the data belongs to libavcodec or other //could move to using cv::Mat there also and just passing cv:Mat over - std::cerr<<"creating cv::Mat with step= "<<((_w*3)+linepadding)<0) return ℑ //just return the previous frame if possible else return nullptr; }; - cerr<<"setting up frame: lineoffset="<<(player.pFrameRGB->linesize[0]-(frame.w*3))<receiver=&s; + if (p->parameter=="rotation") p->receiver=&r; + if (p->parameter=="transformX") p->receiver=&tX; + if (p->parameter=="transformY") p->receiver=&tY; + if (p->parameter=="originX") p->receiver=&oX; + if (p->parameter=="originY") p->receiver=&oY; + } + }; Transform* clone(map &_settings) { return new Transform(_settings);}; Image *output(const Frame_spec &frame){ if (image_inputs.size()) { @@ -1190,7 +1200,7 @@ namespace Rotor { cv::Mat rot_mat(2,3,CV_32FC1); cv::Mat trans_mat(2,3,CV_32FC1); - /* + Image inter; inter.setup(other->w,other->h); // Compute matrix by creating triangle and transforming @@ -1206,8 +1216,8 @@ namespace Rotor { dstTri[i].y=srcTri[i].y+(tY*other->h); } trans_mat=getAffineTransform( srcTri, dstTri ); - warpAffine( other->rgb, inter.rgb, trans_mat, inter.rgb.size() ); - */ + warpAffine( other->rgb, inter.rgb, trans_mat, inter.rgb.size(), cv::INTER_LINEAR, cv::BORDER_WRAP); + // Compute rotation matrix // @@ -1216,7 +1226,14 @@ namespace Rotor { rot_mat = getRotationMatrix2D( centre, r, s ); // Do the transformation // - warpAffine( other->rgb, image.rgb, rot_mat, image->rgb.size() ); + warpAffine( inter.rgb, image.rgb, rot_mat, image.rgb.size(), cv::INTER_LINEAR, cv::BORDER_WRAP); + //BORDER_WRAP + + //INTER_NEAREST - a nearest-neighbor interpolation + //INTER_LINEAR - a bilinear interpolation (used by default) + //INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method. + //INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood + //INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood return ℑ } -- cgit v1.2.3