Commit 24e343f2fb6e2b17bc2f97cac722eefcaa5d3617

Authored by Josh Klontz
1 parent 320c4e7b

use the new rotatePoints function

openbr/plugins/imgproc/affine.cpp
@@ -118,20 +118,8 @@ private: @@ -118,20 +118,8 @@ private:
118 Mat affineTransform = getAffineTransform(srcPoints, dstPoints); 118 Mat affineTransform = getAffineTransform(srcPoints, dstPoints);
119 warpAffine(src, dst, affineTransform, Size(width, height), method, borderMode); 119 warpAffine(src, dst, affineTransform, Size(width, height), method, borderMode);
120 120
121 - if (warpPoints) {  
122 - QList<QPointF> points = src.file.points();  
123 - QList<QPointF> rotatedPoints;  
124 - for (int i=0; i<points.size(); i++) {  
125 - rotatedPoints.append(QPointF(points.at(i).x()*affineTransform.at<double>(0,0)+  
126 - points.at(i).y()*affineTransform.at<double>(0,1)+  
127 - affineTransform.at<double>(0,2),  
128 - points.at(i).x()*affineTransform.at<double>(1,0)+  
129 - points.at(i).y()*affineTransform.at<double>(1,1)+  
130 - affineTransform.at<double>(1,2)));  
131 - }  
132 -  
133 - dst.file.setPoints(rotatedPoints);  
134 - } 121 + if (warpPoints)
  122 + dst.file.setPoints(OpenCVUtils::rotatePoints(src.file.points(), affineTransform));
135 123
136 if (storeAffine) { 124 if (storeAffine) {
137 QList<float> affineParams; 125 QList<float> affineParams;
openbr/plugins/metadata/grid.cpp
@@ -14,8 +14,9 @@ @@ -14,8 +14,9 @@
14 * limitations under the License. * 14 * limitations under the License. *
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
17 -#include <openbr/plugins/openbr_internal.h>  
18 #include <opencv2/imgproc/imgproc.hpp> 17 #include <opencv2/imgproc/imgproc.hpp>
  18 +#include <openbr/plugins/openbr_internal.h>
  19 +#include <openbr/core/opencvutils.h>
19 20
20 using namespace cv; 21 using namespace cv;
21 22
@@ -51,15 +52,8 @@ class GridTransform : public UntrainableTransform @@ -51,15 +52,8 @@ class GridTransform : public UntrainableTransform
51 landmarks.append(QPointF(x,y)); 52 landmarks.append(QPointF(x,y));
52 53
53 if (angle > 0) { 54 if (angle > 0) {
54 - Mat rotMatrix = getRotationMatrix2D(Point2f(src.m().rows/2,src.m().cols/2),angle,1.0);  
55 - for (int i=0; i<landmarks.size(); i++) {  
56 - landmarks.replace(i,QPointF(landmarks.at(i).x()*rotMatrix.at<double>(0,0)+  
57 - landmarks.at(i).y()*rotMatrix.at<double>(0,1)+  
58 - rotMatrix.at<double>(0,2),  
59 - landmarks.at(i).x()*rotMatrix.at<double>(1,0)+  
60 - landmarks.at(i).y()*rotMatrix.at<double>(1,1)+  
61 - rotMatrix.at<double>(1,2)));  
62 - } 55 + const Mat rotMatrix = getRotationMatrix2D(Point2f(src.m().rows/2,src.m().cols/2), angle, 1.0);
  56 + landmarks = OpenCVUtils::rotatePoints(landmarks, rotMatrix);
63 } 57 }
64 58
65 dst = src; 59 dst = src;