Commit e8e1b900d4fe43d22638bff63d4e264076428796

Authored by Josh Klontz
2 parents 5b27d664 06cfdb2f

Merge pull request #380 from biometrics/affine

Affine
openbr/plugins/imgproc/affine.cpp
@@ -54,6 +54,7 @@ private: @@ -54,6 +54,7 @@ private:
54 Q_PROPERTY(float y3 READ get_y3 WRITE set_y3 RESET reset_y3 STORED false) 54 Q_PROPERTY(float y3 READ get_y3 WRITE set_y3 RESET reset_y3 STORED false)
55 Q_PROPERTY(Method method READ get_method WRITE set_method RESET reset_method STORED false) 55 Q_PROPERTY(Method method READ get_method WRITE set_method RESET reset_method STORED false)
56 Q_PROPERTY(bool storeAffine READ get_storeAffine WRITE set_storeAffine RESET reset_storeAffine STORED false) 56 Q_PROPERTY(bool storeAffine READ get_storeAffine WRITE set_storeAffine RESET reset_storeAffine STORED false)
  57 + Q_PROPERTY(bool warpPoints READ get_warpPoints WRITE set_warpPoints RESET reset_warpPoints STORED false)
57 BR_PROPERTY(int, width, 64) 58 BR_PROPERTY(int, width, 64)
58 BR_PROPERTY(int, height, 64) 59 BR_PROPERTY(int, height, 64)
59 BR_PROPERTY(float, x1, 0) 60 BR_PROPERTY(float, x1, 0)
@@ -64,6 +65,7 @@ private: @@ -64,6 +65,7 @@ private:
64 BR_PROPERTY(float, y3, -1) 65 BR_PROPERTY(float, y3, -1)
65 BR_PROPERTY(Method, method, Bilin) 66 BR_PROPERTY(Method, method, Bilin)
66 BR_PROPERTY(bool, storeAffine, false) 67 BR_PROPERTY(bool, storeAffine, false)
  68 + BR_PROPERTY(bool, warpPoints, false)
67 69
68 static Point2f getThirdAffinePoint(const Point2f &a, const Point2f &b) 70 static Point2f getThirdAffinePoint(const Point2f &a, const Point2f &b)
69 { 71 {
@@ -112,6 +114,22 @@ private: @@ -112,6 +114,22 @@ private:
112 dst.file.set("Affine_0", OpenCVUtils::fromPoint(dstPoints[0])); 114 dst.file.set("Affine_0", OpenCVUtils::fromPoint(dstPoints[0]));
113 dst.file.set("Affine_1", OpenCVUtils::fromPoint(dstPoints[1])); 115 dst.file.set("Affine_1", OpenCVUtils::fromPoint(dstPoints[1]));
114 if (!twoPoints) dst.file.set("Affine_2", OpenCVUtils::fromPoint(dstPoints[2])); 116 if (!twoPoints) dst.file.set("Affine_2", OpenCVUtils::fromPoint(dstPoints[2]));
  117 +
  118 + if (warpPoints) {
  119 + QList<QPointF> points = src.file.points();
  120 + QList<QPointF> rotatedPoints;
  121 + for (int i=0; i<points.size(); i++) {
  122 + rotatedPoints.append(QPointF(points.at(i).x()*affineTransform.at<double>(0,0)+
  123 + points.at(i).y()*affineTransform.at<double>(0,1)+
  124 + affineTransform.at<double>(0,2),
  125 + points.at(i).x()*affineTransform.at<double>(1,0)+
  126 + points.at(i).y()*affineTransform.at<double>(1,1)+
  127 + affineTransform.at<double>(1,2)));
  128 + }
  129 +
  130 + dst.file.setPoints(rotatedPoints);
  131 + }
  132 +
115 if (storeAffine) { 133 if (storeAffine) {
116 QList<float> affineParams; 134 QList<float> affineParams;
117 for (int i = 0 ; i < 2; i++) 135 for (int i = 0 ; i < 2; i++)