diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-09-02 15:19:56 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-09-02 15:19:56 +0100 |
| commit | 7e543cdaff89e99a9940624b949d684d4aed69c0 (patch) | |
| tree | 60590f338263c7a695c6b94dcbac52194252d112 /rotord/src/nodes_transform.h | |
| parent | eb6cbcd58f2f1142cab49a54283b290ecb9e0a4a (diff) | |
| parent | 10a475fe33fc645e3623c2bf4b176194bf45675b (diff) | |
Merge branch 'master' of eclectronics.org@eclectronics.org:rotor
Diffstat (limited to 'rotord/src/nodes_transform.h')
| -rw-r--r-- | rotord/src/nodes_transform.h | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/rotord/src/nodes_transform.h b/rotord/src/nodes_transform.h index fd6b7be..8baf1fa 100644 --- a/rotord/src/nodes_transform.h +++ b/rotord/src/nodes_transform.h @@ -62,23 +62,37 @@ namespace Rotor { cv::Point2f srcTri[3], dstTri[3]; cv::Mat rot_mat(2,3,CV_32FC1); cv::Mat trans_mat(2,3,CV_32FC1); + cv::Mat out_mat(3,3,CV_32FC1); - Image inter; - inter.setup(in->w,in->h); + //normally a scale of 1 will place the image on screen at pixel size + //it should be that a scale of 1 places it at width w + //how to scale around the centre + cv::Mat inter; + if (s<1){ + if (s<.01) s=.01; + float scalefac=((float)image.w/in->w)*s; + cv::resize(in->rgb,inter,cv::Size(in->w*scalefac,in->h*scalefac),s,s); //double fx=0, double fy=0, int interpolation=INTER_LINEAR )ΒΆ + s=1.0f; + } + else { + inter=in->rgb; + s=((float)image.w/in->w)*s; + } + // Compute matrix by creating triangle and transforming //is there a better way - combine the 2? Just a bit of geometry srcTri[0].x=0; srcTri[0].y=0; - srcTri[1].x=in->w-1; + srcTri[1].x=image.w-1; srcTri[1].y=0; srcTri[2].x=0; - srcTri[2].y=in->h-1; + srcTri[2].y=image.h-1; for (int i=0;i<3;i++){ - dstTri[i].x=srcTri[i].x+(tX*in->w); - dstTri[i].y=srcTri[i].y+(tY*in->h); + dstTri[i].x=srcTri[i].x+(tX*image.w); + dstTri[i].y=srcTri[i].y+(tY*image.w); //use w for equiv coords } trans_mat=getAffineTransform( srcTri, dstTri ); - warpAffine( in->rgb, inter.rgb, trans_mat, inter.rgb.size(), filtmode, cv::BORDER_WRAP); + //warpAffine( in->rgb, inter.rgb, trans_mat, inter.rgb.size(), filtmode, cv::BORDER_WRAP); // Compute rotation matrix // @@ -88,9 +102,18 @@ namespace Rotor { // Do the transformation // - warpAffine( inter.rgb, image.rgb, rot_mat, image.rgb.size(), filtmode, cv::BORDER_WRAP); + //warpAffine( inter.rgb, image.rgb, rot_mat, image.rgb.size(), filtmode, cv::BORDER_WRAP); //BORDER_WRAP + //trans_mat.resize(3); + //rot_mat.resize(3); + //trans_mat.data[8]=1.0f; + //rot_mat.data[8]=1.0f; + //out_mat=rot_mat*trans_mat; + //out_mat.resize(2); + + warpAffine( inter, image.rgb, rot_mat, image.rgb.size(), filtmode, cv::BORDER_WRAP); + return ℑ } return nullptr; |
