Commit 2aae0a3bd1836c4f515947e4d5815e9bf8693a99

Authored by Josh Klontz
2 parents afa88d8e 95b636e0

Merge pull request #368 from biometrics/rotate_grid

Grid Rotation
openbr/plugins/metadata/grid.cpp
... ... @@ -15,6 +15,9 @@
15 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16  
17 17 #include <openbr/plugins/openbr_internal.h>
  18 +#include <opencv2/imgproc/imgproc.hpp>
  19 +
  20 +using namespace cv;
18 21  
19 22 namespace br
20 23 {
... ... @@ -30,9 +33,11 @@ class GridTransform : public UntrainableTransform
30 33 Q_PROPERTY(int rows READ get_rows WRITE set_rows RESET reset_rows STORED false)
31 34 Q_PROPERTY(int columns READ get_columns WRITE set_columns RESET reset_columns STORED false)
32 35 Q_PROPERTY(float border READ get_border WRITE set_border RESET reset_border STORED false)
  36 + Q_PROPERTY(float angle READ get_angle WRITE set_angle RESET reset_angle STORED false)
33 37 BR_PROPERTY(int, rows, 1)
34 38 BR_PROPERTY(int, columns, 1)
35 39 BR_PROPERTY(float, border, 0)
  40 + BR_PROPERTY(float, angle, 0)
36 41  
37 42 void project(const Template &src, Template &dst) const
38 43 {
... ... @@ -44,6 +49,19 @@ class GridTransform : public UntrainableTransform
44 49 for (float y=row_step/2+row_border; y<src.m().rows-row_border; y+=row_step)
45 50 for (float x=column_step/2+col_border; x<src.m().cols-col_border; x+=column_step)
46 51 landmarks.append(QPointF(x,y));
  52 +
  53 + 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 + }
  63 + }
  64 +
47 65 dst = src;
48 66 dst.file.setPoints(landmarks);
49 67 }
... ...