Commit 06cfdb2fb3e8c66c6d822cd4d35d296fe8ab13d1
1 parent
5bae8c7a
Rotation matrix can be applied to points
Showing
1 changed file
with
18 additions
and
0 deletions
openbr/plugins/imgproc/affine.cpp
| ... | ... | @@ -54,6 +54,7 @@ private: |
| 54 | 54 | Q_PROPERTY(float y3 READ get_y3 WRITE set_y3 RESET reset_y3 STORED false) |
| 55 | 55 | Q_PROPERTY(Method method READ get_method WRITE set_method RESET reset_method STORED false) |
| 56 | 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 | 58 | BR_PROPERTY(int, width, 64) |
| 58 | 59 | BR_PROPERTY(int, height, 64) |
| 59 | 60 | BR_PROPERTY(float, x1, 0) |
| ... | ... | @@ -64,6 +65,7 @@ private: |
| 64 | 65 | BR_PROPERTY(float, y3, -1) |
| 65 | 66 | BR_PROPERTY(Method, method, Bilin) |
| 66 | 67 | BR_PROPERTY(bool, storeAffine, false) |
| 68 | + BR_PROPERTY(bool, warpPoints, false) | |
| 67 | 69 | |
| 68 | 70 | static Point2f getThirdAffinePoint(const Point2f &a, const Point2f &b) |
| 69 | 71 | { |
| ... | ... | @@ -112,6 +114,22 @@ private: |
| 112 | 114 | dst.file.set("Affine_0", OpenCVUtils::fromPoint(dstPoints[0])); |
| 113 | 115 | dst.file.set("Affine_1", OpenCVUtils::fromPoint(dstPoints[1])); |
| 114 | 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 | 133 | if (storeAffine) { |
| 116 | 134 | QList<float> affineParams; |
| 117 | 135 | for (int i = 0 ; i < 2; i++) | ... | ... |