Commit b8c2696b185ece058c5c473a9e025c5c2fb4a598

Authored by Colin Heinzmann
1 parent 087a8f65

removed untested options and code paths

CUDAAffine will only have bilinear transformation with a single reference point for now
openbr/plugins/cuda/cudaaffine.cpp
... ... @@ -47,46 +47,24 @@ namespace br
47 47  
48 48 /*!
49 49 * \ingroup transforms
50   - * \brief Performs a two or three point registration on the GPU. Modified from stock OpenBR implementation
  50 + * \brief Performs a two or three point registration on the GPU. Modified from stock OpenBR implementation. Only supports single-point input bilinear transformation.
51 51 * \author Greg Schrock \cite gls022
  52 + * \author Colin Heinzmann \cite DepthDeluxe
52 53 * \note Method: Area should be used for shrinking an image, Cubic for slow but accurate enlargment, Bilin for fast enlargement.
53 54 */
54 55 class CUDAAffineTransform : public UntrainableTransform
55 56 {
56 57 Q_OBJECT
57   - Q_ENUMS(Method)
58 58  
59   - public:
60   - /*!< */
61   - enum Method { Near = INTER_NEAREST,
62   - Area = INTER_AREA,
63   - Bilin = INTER_LINEAR,
64   - Cubic = INTER_CUBIC,
65   - Lanczo = INTER_LANCZOS4};
66   -
67   - private:
  59 + private:
68 60 Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false)
69 61 Q_PROPERTY(int height READ get_height WRITE set_height RESET reset_height STORED false)
70 62 Q_PROPERTY(float x1 READ get_x1 WRITE set_x1 RESET reset_x1 STORED false)
71 63 Q_PROPERTY(float y1 READ get_y1 WRITE set_y1 RESET reset_y1 STORED false)
72   - Q_PROPERTY(float x2 READ get_x2 WRITE set_x2 RESET reset_x2 STORED false)
73   - Q_PROPERTY(float y2 READ get_y2 WRITE set_y2 RESET reset_y2 STORED false)
74   - Q_PROPERTY(float x3 READ get_x3 WRITE set_x3 RESET reset_x3 STORED false)
75   - Q_PROPERTY(float y3 READ get_y3 WRITE set_y3 RESET reset_y3 STORED false)
76   - Q_PROPERTY(Method method READ get_method WRITE set_method RESET reset_method STORED false)
77   - Q_PROPERTY(bool storeAffine READ get_storeAffine WRITE set_storeAffine RESET reset_storeAffine STORED false)
78   - Q_PROPERTY(bool warpPoints READ get_warpPoints WRITE set_warpPoints RESET reset_warpPoints STORED false)
79 64 BR_PROPERTY(int, width, 64)
80 65 BR_PROPERTY(int, height, 64)
81 66 BR_PROPERTY(float, x1, 0)
82 67 BR_PROPERTY(float, y1, 0)
83   - BR_PROPERTY(float, x2, -1)
84   - BR_PROPERTY(float, y2, -1)
85   - BR_PROPERTY(float, x3, -1)
86   - BR_PROPERTY(float, y3, -1)
87   - BR_PROPERTY(Method, method, Bilin)
88   - BR_PROPERTY(bool, storeAffine, false)
89   - BR_PROPERTY(bool, warpPoints, false)
90 68  
91 69 static Point2f getThirdAffinePoint(const Point2f &a, const Point2f &b)
92 70 {
... ... @@ -97,25 +75,21 @@ namespace br
97 75  
98 76 void project(const Template &src, Template &dst) const
99 77 {
100   - const bool twoPoints = ((x3 == -1) || (y3 == -1));
101   -
102 78 Point2f dstPoints[3];
103 79 dstPoints[0] = Point2f(x1*width, y1*height);
104   - dstPoints[1] = Point2f((x2 == -1 ? 1 - x1 : x2)*width, (y2 == -1 ? y1 : y2)*height);
105   - if (twoPoints) dstPoints[2] = getThirdAffinePoint(dstPoints[0], dstPoints[1]);
106   - else dstPoints[2] = Point2f(x3*width, y3*height);
  80 + dstPoints[1] = Point2f((1-x1)*width, (1-y1)*height);
  81 + dstPoints[2] = getThirdAffinePoint(dstPoints[0], dstPoints[1]);
107 82  
108 83 Point2f srcPoints[3];
109 84 if (src.file.contains("Affine_0") &&
110 85 src.file.contains("Affine_1") &&
111   - (src.file.contains("Affine_2") || twoPoints)) {
  86 + src.file.contains("Affine_2")) {
112 87 srcPoints[0] = OpenCVUtils::toPoint(src.file.get<QPointF>("Affine_0"));
113 88 srcPoints[1] = OpenCVUtils::toPoint(src.file.get<QPointF>("Affine_1"));
114   - if (!twoPoints) srcPoints[2] = OpenCVUtils::toPoint(src.file.get<QPointF>("Affine_2"));
115 89 } else {
116 90 const QList<Point2f> landmarks = OpenCVUtils::toPoints(src.file.points());
117 91  
118   - if ((landmarks.size() < 2) || (!twoPoints && (landmarks.size() < 3))) {
  92 + if (landmarks.size() < 2) {
119 93 void* const* srcDataPtr = src.m().ptr<void*>();
120 94 int rows = *((int*)srcDataPtr[1]);
121 95 int cols = *((int*)srcDataPtr[2]);
... ... @@ -134,10 +108,9 @@ namespace br
134 108 } else {
135 109 srcPoints[0] = landmarks[0];
136 110 srcPoints[1] = landmarks[1];
137   - if (!twoPoints) srcPoints[2] = landmarks[2];
138 111 }
139 112 }
140   - if (twoPoints) srcPoints[2] = getThirdAffinePoint(srcPoints[0], srcPoints[1]);
  113 + srcPoints[2] = getThirdAffinePoint(srcPoints[0], srcPoints[1]);
141 114  
142 115 Mat affineTransform = getAffineTransform(srcPoints, dstPoints);
143 116  
... ... @@ -155,31 +128,6 @@ namespace br
155 128  
156 129 cuda::affine::wrapper(srcDataPtr[0], &dstDataPtr[0], affineTransform, rows, cols, height, width);
157 130  
158   - // end altered code
159   -
160   - if (warpPoints) {
161   - QList<QPointF> points = src.file.points();
162   - QList<QPointF> rotatedPoints;
163   - for (int i=0; i<points.size(); i++) {
164   - rotatedPoints.append(QPointF(points.at(i).x()*affineTransform.at<double>(0,0)+
165   - points.at(i).y()*affineTransform.at<double>(0,1)+
166   - affineTransform.at<double>(0,2),
167   - points.at(i).x()*affineTransform.at<double>(1,0)+
168   - points.at(i).y()*affineTransform.at<double>(1,1)+
169   - affineTransform.at<double>(1,2)));
170   - }
171   -
172   - dst.file.setPoints(rotatedPoints);
173   - }
174   -
175   - if (storeAffine) {
176   - QList<float> affineParams;
177   - for (int i = 0 ; i < 2; i++)
178   - for (int j = 0; j < 3; j++)
179   - affineParams.append(affineTransform.at<double>(i, j));
180   - dst.file.setList("affineParameters", affineParams);
181   - }
182   -
183 131 dst = dstMat;
184 132 }
185 133 };
... ...