Commit 1711fd54d91fd100df618858cb53b2d57684d55d
1 parent
a1d23324
Fix bug in rotation
Showing
3 changed files
with
5 additions
and
18 deletions
openbr/core/opencvutils.cpp
| ... | ... | @@ -654,10 +654,10 @@ QList<QRectF> OpenCVUtils::rotateRects(const QList<QRectF> &rects, const Mat &ro |
| 654 | 654 | |
| 655 | 655 | void OpenCVUtils::rotate(const br::Template &src, br::Template &dst, float degrees, bool rotateMat, bool rotatePoints, bool rotateRects, const QPointF ¢er) |
| 656 | 656 | { |
| 657 | - const Mat rotMatrix = getRotationMatrix2D(center.isNull() ? Point2f(src.m().rows/2,src.m().cols/2) : toPoint(center), degrees, 1.0); | |
| 657 | + const Mat rotMatrix = getRotationMatrix2D(center.isNull() ? Point2f(src.m().cols / 2, src.m().rows / 2) : toPoint(center), degrees, 1.0); | |
| 658 | 658 | |
| 659 | 659 | if (rotateMat) { |
| 660 | - warpAffine(src,dst,rotMatrix,Size(src.m().cols,src.m().rows),INTER_AREA,BORDER_REPLICATE); | |
| 660 | + warpAffine(src, dst, rotMatrix, Size(src.m().cols, src.m().rows), INTER_AREA, BORDER_REPLICATE); | |
| 661 | 661 | dst.file = src.file; |
| 662 | 662 | } else |
| 663 | 663 | dst = src; | ... | ... |
openbr/plugins/imgproc/rotate.cpp
| 1 | 1 | #include <opencv2/imgproc/imgproc.hpp> |
| 2 | 2 | #include <openbr/plugins/openbr_internal.h> |
| 3 | +#include <openbr/core/opencvutils.h> | |
| 3 | 4 | |
| 4 | 5 | using namespace cv; |
| 5 | 6 | |
| ... | ... | @@ -19,21 +20,7 @@ class RotateTransform : public UntrainableTransform |
| 19 | 20 | BR_PROPERTY(int, angle, -90) |
| 20 | 21 | |
| 21 | 22 | void project(const Template &src, Template &dst) const { |
| 22 | - | |
| 23 | - if(angle == 270 || angle == -90){ | |
| 24 | - // Rotate clockwise 270 degrees | |
| 25 | - cv::transpose(src, dst); | |
| 26 | - cv::flip(dst, dst, 0); | |
| 27 | - }else if(angle == 180 || angle == -180){ | |
| 28 | - // Rotate clockwise 180 degrees | |
| 29 | - cv::flip(src, dst, -1); | |
| 30 | - }else if(angle == 90 || angle == -270){ | |
| 31 | - // Rotate clockwise 90 degrees | |
| 32 | - cv::transpose(src, dst); | |
| 33 | - cv::flip(dst, dst, 1); | |
| 34 | - }else { | |
| 35 | - dst = src; | |
| 36 | - } | |
| 23 | + OpenCVUtils::rotate(src, dst, angle); | |
| 37 | 24 | } |
| 38 | 25 | }; |
| 39 | 26 | ... | ... |
openbr/plugins/metadata/grid.cpp
| ... | ... | @@ -52,7 +52,7 @@ class GridTransform : public UntrainableTransform |
| 52 | 52 | landmarks.append(QPointF(x,y)); |
| 53 | 53 | |
| 54 | 54 | if (angle > 0) { |
| 55 | - const Mat rotMatrix = getRotationMatrix2D(Point2f(src.m().rows/2,src.m().cols/2), angle, 1.0); | |
| 55 | + const Mat rotMatrix = getRotationMatrix2D(Point2f(src.m().cols / 2, src.m().rows / 2), angle, 1.0); | |
| 56 | 56 | landmarks = OpenCVUtils::rotatePoints(landmarks, rotMatrix); |
| 57 | 57 | } |
| 58 | 58 | ... | ... |