From 06cfdb2fb3e8c66c6d822cd4d35d296fe8ab13d1 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Mon, 8 Jun 2015 18:26:04 -0400 Subject: [PATCH] Rotation matrix can be applied to points --- openbr/plugins/imgproc/affine.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+), 0 deletions(-) diff --git a/openbr/plugins/imgproc/affine.cpp b/openbr/plugins/imgproc/affine.cpp index 2204d6c..4d60256 100644 --- a/openbr/plugins/imgproc/affine.cpp +++ b/openbr/plugins/imgproc/affine.cpp @@ -54,6 +54,7 @@ private: Q_PROPERTY(float y3 READ get_y3 WRITE set_y3 RESET reset_y3 STORED false) Q_PROPERTY(Method method READ get_method WRITE set_method RESET reset_method STORED false) Q_PROPERTY(bool storeAffine READ get_storeAffine WRITE set_storeAffine RESET reset_storeAffine STORED false) + Q_PROPERTY(bool warpPoints READ get_warpPoints WRITE set_warpPoints RESET reset_warpPoints STORED false) BR_PROPERTY(int, width, 64) BR_PROPERTY(int, height, 64) BR_PROPERTY(float, x1, 0) @@ -64,6 +65,7 @@ private: BR_PROPERTY(float, y3, -1) BR_PROPERTY(Method, method, Bilin) BR_PROPERTY(bool, storeAffine, false) + BR_PROPERTY(bool, warpPoints, false) static Point2f getThirdAffinePoint(const Point2f &a, const Point2f &b) { @@ -112,6 +114,22 @@ private: dst.file.set("Affine_0", OpenCVUtils::fromPoint(dstPoints[0])); dst.file.set("Affine_1", OpenCVUtils::fromPoint(dstPoints[1])); if (!twoPoints) dst.file.set("Affine_2", OpenCVUtils::fromPoint(dstPoints[2])); + + if (warpPoints) { + QList points = src.file.points(); + QList rotatedPoints; + for (int i=0; i(0,0)+ + points.at(i).y()*affineTransform.at(0,1)+ + affineTransform.at(0,2), + points.at(i).x()*affineTransform.at(1,0)+ + points.at(i).y()*affineTransform.at(1,1)+ + affineTransform.at(1,2))); + } + + dst.file.setPoints(rotatedPoints); + } + if (storeAffine) { QList affineParams; for (int i = 0 ; i < 2; i++) -- libgit2 0.21.4