Commit 3d92a1dd52a84b9b95f81e81b661a46d332159a1

Authored by Josh Klontz
1 parent 8726eb4e

now storing points and landmarks directly

app/examples/face_recognition.cpp
@@ -30,10 +30,9 @@ @@ -30,10 +30,9 @@
30 30
31 static void printTemplate(const br::Template &t) 31 static void printTemplate(const br::Template &t)
32 { 32 {
33 - printf("%s eyes: (%d, %d) (%d, %d)\n",  
34 - qPrintable(t.file.fileName()),  
35 - t.file.get<int>("Affine_0_X"), t.file.get<int>("Affine_0_Y"),  
36 - t.file.get<int>("Affine_1_X"), t.file.get<int>("Affine_1_Y")); 33 + const QPoint firstEye = t.file.get<QPoint>("Affine_0");
  34 + const QPoint secondEye = t.file.get<QPoint>("Affine_1");
  35 + printf("%s eyes: (%d, %d) (%d, %d)\n", qPrintable(t.file.fileName()), firstEye.x(), firstEye.y(), secondEye.x(), secondEye.y());
37 } 36 }
38 37
39 int main(int argc, char *argv[]) 38 int main(int argc, char *argv[])
app/openbr-gui/templateviewer.cpp
@@ -39,10 +39,8 @@ void TemplateViewer::setFile(const File &amp;file_) @@ -39,10 +39,8 @@ void TemplateViewer::setFile(const File &amp;file_)
39 39
40 // Update landmarks 40 // Update landmarks
41 landmarks.clear(); 41 landmarks.clear();
42 - if (file.contains("Affine_0_X") && file.contains("Affine_0_Y"))  
43 - landmarks.append(QPointF(file.get<float>("Affine_0_X"), file.get<float>("Affine_0_Y")));  
44 - if (file.contains("Affine_1_X") && file.contains("Affine_1_Y"))  
45 - landmarks.append(QPointF(file.get<float>("Affine_1_X"), file.get<float>("Affine_1_Y"))); 42 + if (file.contains("Affine_0")) landmarks.append(file.get<QPointF>("Affine_0"));
  43 + if (file.contains("Affine_1")) landmarks.append(file.get<QPointF>("Affine_1"));
46 while (landmarks.size() < NumLandmarks) 44 while (landmarks.size() < NumLandmarks)
47 landmarks.append(QPointF()); 45 landmarks.append(QPointF());
48 nearestLandmark = -1; 46 nearestLandmark = -1;
sdk/openbr_plugin.cpp
@@ -148,84 +148,72 @@ float File::label() const @@ -148,84 +148,72 @@ float File::label() const
148 return ok ? val : -1; 148 return ok ? val : -1;
149 } 149 }
150 150
151 -QList<QPointF> File::landmarks() const 151 +QList<QPointF> File::namedPoints() const
152 { 152 {
153 QList<QPointF> landmarks; 153 QList<QPointF> landmarks;
154 - foreach (const QVariant &landmark, value("Landmarks").toList())  
155 - landmarks.append(landmark.toPointF());  
156 - return landmarks;  
157 -}  
158 -  
159 -QList<QPointF> File::namedLandmarks() const  
160 -{  
161 - QList<QPointF> landmarks;  
162 - QStringList keys = localMetadata().keys();  
163 - foreach (const QString &key, keys) {  
164 - if (!key.endsWith("_X"))  
165 - continue;  
166 - QString keyBaseName = key.left(key.size()-2);  
167 - if (!keys.contains(keyBaseName+"_Y") ||  
168 - keys.contains(keyBaseName+"_Width") ||  
169 - keys.contains(keyBaseName+"_Height") ||  
170 - keys.contains(keyBaseName+"_Radius"))  
171 - continue;  
172 - landmarks.append(QPointF(get<float>(keyBaseName+"_X"), get<float>(keyBaseName+"_Y"))); 154 + foreach (const QString &key, localMetadata().keys()) {
  155 + const QVariant &variant = m_metadata[key];
  156 + if (variant.canConvert<QPointF>())
  157 + landmarks.append(variant.value<QPointF>());
173 } 158 }
174 return landmarks; 159 return landmarks;
175 } 160 }
176 161
177 -void File::appendLandmark(const QPointF &landmark) 162 +QList<QPointF> File::points() const
178 { 163 {
179 - QList<QVariant> newLandmarks = m_metadata["Landmarks"].toList();  
180 - newLandmarks.append(landmark);  
181 - m_metadata["Landmarks"] = newLandmarks; 164 + QList<QPointF> points;
  165 + foreach (const QVariant &point, m_metadata["Points"].toList())
  166 + points.append(point.toPointF());
  167 + return points;
182 } 168 }
183 169
184 -void File::appendLandmarks(const QList<QPointF> &landmarks) 170 +void File::appendPoint(const QPointF &point)
185 { 171 {
186 - QList<QVariant> newLandmarks = m_metadata["Landmarks"].toList();  
187 - foreach (const QPointF &landmark, landmarks)  
188 - newLandmarks.append(landmark);  
189 - m_metadata["Landmarks"] = newLandmarks; 172 + QList<QVariant> newPoints = m_metadata["Points"].toList();
  173 + newPoints.append(point);
  174 + m_metadata["Points"] = newPoints;
190 } 175 }
191 176
192 -void File::setLandmarks(const QList<QPointF> &landmarks) 177 +void File::appendPoints(const QList<QPointF> &points)
193 { 178 {
194 - QList<QVariant> landmarkList; landmarkList.reserve(landmarks.size());  
195 - foreach (const QPointF &landmark, landmarks)  
196 - landmarkList.append(landmark);  
197 - m_metadata["Landmarks"] = landmarkList; 179 + QList<QVariant> newPoints = m_metadata["Points"].toList();
  180 + foreach (const QPointF &point, points)
  181 + newPoints.append(point);
  182 + m_metadata["Points"] = newPoints;
198 } 183 }
199 184
200 -QList<QRectF> File::ROIs() const 185 +QList<QRectF> File::namedRects() const
201 { 186 {
202 - QList<QRectF> ROIs;  
203 - foreach (const QVariant &ROI, value("ROIs").toList())  
204 - ROIs.append(ROI.toRect());  
205 - return ROIs; 187 + QList<QRectF> rects;
  188 + foreach (const QString &key, localMetadata().keys()) {
  189 + const QVariant &variant = m_metadata[key];
  190 + if (variant.canConvert<QRectF>())
  191 + rects.append(variant.value<QRectF>());
  192 + }
  193 + return rects;
206 } 194 }
207 195
208 -void File::appendROI(const QRectF &ROI) 196 +QList<QRectF> File::rects() const
209 { 197 {
210 - QList<QVariant> newROIs = m_metadata["ROIs"].toList();  
211 - newROIs.append(ROI);  
212 - m_metadata["ROIs"] = newROIs; 198 + QList<QRectF> rects;
  199 + foreach (const QVariant &rect, m_metadata["Rects"].toList())
  200 + rects.append(rect.toRect());
  201 + return rects;
213 } 202 }
214 203
215 -void File::appendROIs(const QList<QRectF> &ROIs) 204 +void File::appendRect(const QRectF &rect)
216 { 205 {
217 - QList<QVariant> newROIs = m_metadata["ROIs"].toList();  
218 - foreach (const QRectF &ROI, ROIs)  
219 - newROIs.append(ROI);  
220 - m_metadata["ROIs"] = newROIs; 206 + QList<QVariant> newRects = m_metadata["Rects"].toList();
  207 + newRects.append(rect);
  208 + m_metadata["Rects"] = newRects;
221 } 209 }
222 210
223 -void File::setROIs(const QList<QRectF> &ROIs) 211 +void File::appendRects(const QList<QRectF> &rects)
224 { 212 {
225 - QList<QVariant> ROIList; ROIList.reserve(ROIs.size());  
226 - foreach (const QRectF &ROI, ROIs)  
227 - ROIList.append(ROI);  
228 - m_metadata["ROIs"] = ROIList; 213 + QList<QVariant> newRects = m_metadata["Rects"].toList();
  214 + foreach (const QRectF &rect, rects)
  215 + newRects.append(rect);
  216 + m_metadata["Rects"] = newRects;
229 } 217 }
230 218
231 /* File - private methods */ 219 /* File - private methods */
sdk/openbr_plugin.h
@@ -128,8 +128,6 @@ void reset_##NAME() { NAME = DEFAULT; } @@ -128,8 +128,6 @@ void reset_##NAME() { NAME = DEFAULT; }
128 * 128 *
129 * Key | Value | Description 129 * Key | Value | Description
130 * --- | ---- | ----------- 130 * --- | ---- | -----------
131 - * path | QString | Resolve complete file paths from file names  
132 - * enrollAll | bool | Enroll zero or more templates per file  
133 * separator | QString | Seperate #name into multiple files 131 * separator | QString | Seperate #name into multiple files
134 * Index | int | Index of a template in a template list 132 * Index | int | Index of a template in a template list
135 * Label | float | Classification/Regression class 133 * Label | float | Classification/Regression class
@@ -145,8 +143,8 @@ void reset_##NAME() { NAME = DEFAULT; } @@ -145,8 +143,8 @@ void reset_##NAME() { NAME = DEFAULT; }
145 * Roll | float | Pose 143 * Roll | float | Pose
146 * Pitch | float | Pose 144 * Pitch | float | Pose
147 * Yaw | float | Pose 145 * Yaw | float | Pose
148 - * Landmarks | QList<QPointF> | Landmark list  
149 - * ROIs | QList<Rect> | Region Of Interest (ROI) list 146 + * Points | QList<QPointF> | List of unnamed points
  147 + * Rects | QList<Rect> | List of unnamed rects
150 * Age | QString | Age used for demographic filtering 148 * Age | QString | Age used for demographic filtering
151 * _* | * | Reserved for internal use 149 * _* | * | Reserved for internal use
152 */ 150 */
@@ -225,18 +223,19 @@ struct BR_EXPORT File @@ -225,18 +223,19 @@ struct BR_EXPORT File
225 inline void setLabel(float label) { set("Label", label); } /*!< \brief Convenience function for setting the file's \c Label. */ 223 inline void setLabel(float label) { set("Label", label); } /*!< \brief Convenience function for setting the file's \c Label. */
226 inline bool failed() const { return get<bool>("FTE", false) || get<bool>("FTO", false); } /*!< \brief Returns \c true if the file failed to open or enroll, \c false otherwise. */ 224 inline bool failed() const { return get<bool>("FTE", false) || get<bool>("FTO", false); } /*!< \brief Returns \c true if the file failed to open or enroll, \c false otherwise. */
227 225
228 - QList<QPointF> landmarks() const; /*!< \brief Returns the file's landmark list. */  
229 - QList<QPointF> namedLandmarks() const; /*!< \brief Returns landmarks derived from metadata keys. */  
230 - void appendLandmark(const QPointF &landmark); /*!< \brief Adds a landmark to the file's landmark list. */  
231 - void appendLandmarks(const QList<QPointF> &landmarks); /*!< \brief Adds landmarks to the file's landmark list. */  
232 - inline void clearLandmarks() { m_metadata["Landmarks"] = QList<QVariant>(); } /*!< \brief Clears the file's landmark list. */  
233 - void setLandmarks(const QList<QPointF> &landmarks); /*!< \brief Assigns the file's landmark list. */  
234 -  
235 - QList<QRectF> ROIs() const; /*!< \brief Returns the file's ROI list. */  
236 - void appendROI(const QRectF &ROI); /*!< \brief Adds a ROI to the file's ROI list. */  
237 - void appendROIs(const QList<QRectF> &ROIs); /*!< \brief Adds ROIs to the file's ROI list. */  
238 - inline void clearROIs() { m_metadata["ROIs"] = QList<QVariant>(); } /*!< \brief Clears the file's landmark list. */  
239 - void setROIs(const QList<QRectF> &ROIs); /*!< \brief Assigns the file's landmark list. */ 226 + QList<QPointF> namedPoints() const; /*!< \brief Returns points convertible from metadata keys. */
  227 + QList<QPointF> points() const; /*!< \brief Returns the file's points list. */
  228 + void appendPoint(const QPointF &point); /*!< \brief Adds a point to the file's point list. */
  229 + void appendPoints(const QList<QPointF> &points); /*!< \brief Adds landmarks to the file's landmark list. */
  230 + inline void clearPoints() { m_metadata["Points"] = QList<QVariant>(); } /*!< \brief Clears the file's landmark list. */
  231 + inline void setPoints(const QList<QPointF> &points) { clearPoints(); appendPoints(points); } /*!< \brief Overwrites the file's landmark list. */
  232 +
  233 + QList<QRectF> namedRects() const; /*!< \brief Returns rects convertible from metadata values. */
  234 + QList<QRectF> rects() const; /*!< \brief Returns the file's rects list. */
  235 + void appendRect(const QRectF &rect); /*!< \brief Adds a rect to the file's rect list. */
  236 + void appendRects(const QList<QRectF> &rects); /*!< \brief Adds rects to the file's rect list. */
  237 + inline void clearRects() { m_metadata["Rects"] = QList<QVariant>(); } /*!< \brief Clears the file's rect list. */
  238 + inline void setRects(const QList<QRectF> &rects) { clearRects(); appendRects(rects); } /*!< \brief Overwrites the file's rect list. */
240 239
241 private: 240 private:
242 QMap<QString,QVariant> m_metadata; 241 QMap<QString,QVariant> m_metadata;
sdk/plugins/cascade.cpp
@@ -83,7 +83,7 @@ class CascadeTransform : public UntrainableTransform @@ -83,7 +83,7 @@ class CascadeTransform : public UntrainableTransform
83 83
84 foreach (const Rect &rect, rects) { 84 foreach (const Rect &rect, rects) {
85 dst += src; 85 dst += src;
86 - dst.file.appendROI(OpenCVUtils::fromRect(rect)); 86 + dst.file.appendRect(OpenCVUtils::fromRect(rect));
87 } 87 }
88 } 88 }
89 }; 89 };
sdk/plugins/crop.cpp
@@ -26,7 +26,7 @@ namespace br @@ -26,7 +26,7 @@ namespace br
26 26
27 /*! 27 /*!
28 * \ingroup transforms 28 * \ingroup transforms
29 - * \brief Crops the regions of interest. 29 + * \brief Crops the rectangular regions of interest.
30 * \author Josh Klontz \cite jklontz 30 * \author Josh Klontz \cite jklontz
31 */ 31 */
32 class ROITransform : public UntrainableTransform 32 class ROITransform : public UntrainableTransform
@@ -35,8 +35,8 @@ class ROITransform : public UntrainableTransform @@ -35,8 +35,8 @@ class ROITransform : public UntrainableTransform
35 35
36 void project(const Template &src, Template &dst) const 36 void project(const Template &src, Template &dst) const
37 { 37 {
38 - foreach (const QRectF ROI, src.file.ROIs())  
39 - dst += src.m()(OpenCVUtils::toRect(ROI)); 38 + foreach (const QRectF &rect, src.file.rects())
  39 + dst += src.m()(OpenCVUtils::toRect(rect));
40 } 40 }
41 }; 41 };
42 42
sdk/plugins/draw.cpp
@@ -47,19 +47,19 @@ class DrawTransform : public UntrainableTransform @@ -47,19 +47,19 @@ class DrawTransform : public UntrainableTransform
47 const Scalar verboseColor(255, 255, 0); 47 const Scalar verboseColor(255, 255, 0);
48 dst = src.m().clone(); 48 dst = src.m().clone();
49 49
50 - QList<Point2f> landmarks = OpenCVUtils::toPoints(src.file.landmarks()); 50 + QList<Point2f> landmarks = OpenCVUtils::toPoints(src.file.points());
51 51
52 if (unnamed) { 52 if (unnamed) {
53 foreach (const Point2f &landmark, landmarks) 53 foreach (const Point2f &landmark, landmarks)
54 circle(dst, landmark, 3, color, -1); 54 circle(dst, landmark, 3, color, -1);
55 } 55 }
56 if (named) { 56 if (named) {
57 - QList<Point2f> namedLandmarks = OpenCVUtils::toPoints(src.file.namedLandmarks()); 57 + QList<Point2f> namedLandmarks = OpenCVUtils::toPoints(src.file.namedPoints());
58 foreach (const Point2f &landmark, namedLandmarks) 58 foreach (const Point2f &landmark, namedLandmarks)
59 circle(dst, landmark, 3, color); 59 circle(dst, landmark, 3, color);
60 } 60 }
61 if (ROI) { 61 if (ROI) {
62 - QList<Rect> ROIs = OpenCVUtils::toRects(src.file.ROIs()); 62 + QList<Rect> ROIs = OpenCVUtils::toRects(src.file.rects());
63 foreach (const Rect ROI, ROIs) 63 foreach (const Rect ROI, ROIs)
64 rectangle(dst, ROI, color); 64 rectangle(dst, ROI, color);
65 } 65 }
@@ -154,11 +154,11 @@ class EditTransform : public UntrainableTransform @@ -154,11 +154,11 @@ class EditTransform : public UntrainableTransform
154 { 154 {
155 (void) event; 155 (void) event;
156 if (flags) { 156 if (flags) {
157 - QList<QRectF> ROIs = currentTemplate.file.ROIs();  
158 - for (int i=ROIs.size()-1; i>=0; i--)  
159 - if (ROIs[i].contains(x,y))  
160 - ROIs.removeAt(i);  
161 - currentTemplate.file.setROIs(ROIs); 157 + QList<QRectF> rects = currentTemplate.file.rects();
  158 + for (int i=rects.size()-1; i>=0; i--)
  159 + if (rects[i].contains(x,y))
  160 + rects.removeAt(i);
  161 + currentTemplate.file.setRects(rects);
162 } 162 }
163 163
164 Template temp; 164 Template temp;
sdk/plugins/eyes.cpp
@@ -147,7 +147,7 @@ public: @@ -147,7 +147,7 @@ public:
147 private: 147 private:
148 void project(const Template &src, Template &dst) const 148 void project(const Template &src, Template &dst) const
149 { 149 {
150 - Rect roi = OpenCVUtils::toRect(src.file.ROIs().first()); 150 + Rect roi = OpenCVUtils::toRect(src.file.rects().first());
151 151
152 Mat gray; 152 Mat gray;
153 OpenCVUtils::cvtGray(src.m()(roi), gray); 153 OpenCVUtils::cvtGray(src.m()(roi), gray);
@@ -183,12 +183,10 @@ private: @@ -183,12 +183,10 @@ private:
183 float second_eye_y = (right_rect.y + maxLoc.y)*gray.rows/height+roi.y; 183 float second_eye_y = (right_rect.y + maxLoc.y)*gray.rows/height+roi.y;
184 184
185 dst = src; 185 dst = src;
186 - dst.file.appendLandmark(QPointF(first_eye_x, first_eye_y));  
187 - dst.file.appendLandmark(QPointF(second_eye_x, second_eye_y));  
188 - dst.file.set("ASEF_Right_Eye_X", first_eye_x);  
189 - dst.file.set("ASEF_Right_Eye_Y", first_eye_y);  
190 - dst.file.set("ASEF_Left_Eye_X", second_eye_x);  
191 - dst.file.set("ASEF_Left_Eye_Y", second_eye_y); 186 + dst.file.appendPoint(QPointF(first_eye_x, first_eye_y));
  187 + dst.file.appendPoint(QPointF(second_eye_x, second_eye_y));
  188 + dst.file.set("ASEF_Right_Eye", QPointF(first_eye_x, first_eye_y));
  189 + dst.file.set("ASEF_Left_Eye", QPointF(second_eye_x, second_eye_y));
192 } 190 }
193 }; 191 };
194 192
sdk/plugins/hist.cpp
@@ -174,7 +174,7 @@ class VarianceChangeDetectorTransform : public UntrainableTransform @@ -174,7 +174,7 @@ class VarianceChangeDetectorTransform : public UntrainableTransform
174 int *buffer = new int[bins]; 174 int *buffer = new int[bins];
175 175
176 float bestRatio = -std::numeric_limits<float>::max(); 176 float bestRatio = -std::numeric_limits<float>::max();
177 - QRect bestROI; 177 + QRectF bestRect;
178 178
179 const int rows = m.rows; 179 const int rows = m.rows;
180 const int cols = m.cols/bins; 180 const int cols = m.cols/bins;
@@ -202,7 +202,7 @@ class VarianceChangeDetectorTransform : public UntrainableTransform @@ -202,7 +202,7 @@ class VarianceChangeDetectorTransform : public UntrainableTransform
202 202
203 if (ratio > bestRatio) { 203 if (ratio > bestRatio) {
204 bestRatio = ratio; 204 bestRatio = ratio;
205 - bestROI = QRect(j*radius, i*radius, scale*radius, scale*radius); 205 + bestRect = QRect(j*radius, i*radius, scale*radius, scale*radius);
206 } 206 }
207 } 207 }
208 } 208 }
@@ -210,7 +210,7 @@ class VarianceChangeDetectorTransform : public UntrainableTransform @@ -210,7 +210,7 @@ class VarianceChangeDetectorTransform : public UntrainableTransform
210 } 210 }
211 211
212 delete[] buffer; 212 delete[] buffer;
213 - dst.file.appendROI(bestROI); 213 + dst.file.appendRect(bestRect);
214 dst.file.setLabel(bestRatio); 214 dst.file.setLabel(bestRatio);
215 } 215 }
216 }; 216 };
sdk/plugins/keypoint.cpp
@@ -57,10 +57,10 @@ class KeyPointDetectorTransform : public UntrainableTransform @@ -57,10 +57,10 @@ class KeyPointDetectorTransform : public UntrainableTransform
57 dst.file.set("FTE", true); 57 dst.file.set("FTE", true);
58 } 58 }
59 59
60 - QList<Rect> ROIs; 60 + QList<Rect> rects;
61 foreach (const KeyPoint &keyPoint, keyPoints) 61 foreach (const KeyPoint &keyPoint, keyPoints)
62 - ROIs.append(Rect(keyPoint.pt.x, keyPoint.pt.y, keyPoint.size, keyPoint.size));  
63 - dst.file.setROIs(OpenCVUtils::fromRects(ROIs)); 62 + rects.append(Rect(keyPoint.pt.x, keyPoint.pt.y, keyPoint.size, keyPoint.size));
  63 + dst.file.setRects(OpenCVUtils::fromRects(rects));
64 } 64 }
65 }; 65 };
66 66
@@ -92,10 +92,10 @@ class KeyPointDescriptorTransform : public UntrainableTransform @@ -92,10 +92,10 @@ class KeyPointDescriptorTransform : public UntrainableTransform
92 { 92 {
93 std::vector<KeyPoint> keyPoints; 93 std::vector<KeyPoint> keyPoints;
94 if (size == -1) { 94 if (size == -1) {
95 - foreach (const QRectF &ROI, src.file.ROIs()) 95 + foreach (const QRectF &ROI, src.file.rects())
96 keyPoints.push_back(KeyPoint(ROI.x(), ROI.y(), (ROI.width() + ROI.height())/2)); 96 keyPoints.push_back(KeyPoint(ROI.x(), ROI.y(), (ROI.width() + ROI.height())/2));
97 } else { 97 } else {
98 - foreach (const QPointF &landmark, src.file.landmarks()) 98 + foreach (const QPointF &landmark, src.file.points())
99 keyPoints.push_back(KeyPoint(landmark.x(), landmark.y(), size)); 99 keyPoints.push_back(KeyPoint(landmark.x(), landmark.y(), size));
100 } 100 }
101 descriptorExtractor->compute(src, keyPoints, dst); 101 descriptorExtractor->compute(src, keyPoints, dst);
@@ -166,7 +166,7 @@ class SIFTDescriptorTransform : public UntrainableTransform @@ -166,7 +166,7 @@ class SIFTDescriptorTransform : public UntrainableTransform
166 void project(const Template &src, Template &dst) const 166 void project(const Template &src, Template &dst) const
167 { 167 {
168 std::vector<KeyPoint> keyPoints; 168 std::vector<KeyPoint> keyPoints;
169 - foreach (const QPointF &val, src.file.landmarks()) 169 + foreach (const QPointF &val, src.file.points())
170 keyPoints.push_back(KeyPoint(val.x(), val.y(), size)); 170 keyPoints.push_back(KeyPoint(val.x(), val.y(), size));
171 171
172 Mat m; 172 Mat m;
@@ -200,7 +200,7 @@ class GridTransform : public UntrainableTransform @@ -200,7 +200,7 @@ class GridTransform : public UntrainableTransform
200 for (float j=column_step/2; j<src.m().cols; j+=column_step) 200 for (float j=column_step/2; j<src.m().cols; j+=column_step)
201 landmarks.append(QPointF(i,j)); 201 landmarks.append(QPointF(i,j));
202 dst = src; 202 dst = src;
203 - dst.file.setLandmarks(landmarks); 203 + dst.file.setPoints(landmarks);
204 } 204 }
205 }; 205 };
206 206
sdk/plugins/meta.cpp
@@ -37,18 +37,18 @@ static TemplateList Expanded(const TemplateList &amp;templates) @@ -37,18 +37,18 @@ static TemplateList Expanded(const TemplateList &amp;templates)
37 } 37 }
38 38
39 const bool fte = t.file.get<bool>("FTE", false); 39 const bool fte = t.file.get<bool>("FTE", false);
40 - QList<QPointF> landmarks = t.file.landmarks();  
41 - QList<QRectF> ROIs = t.file.ROIs();  
42 - if (landmarks.size() % t.size() != 0) qFatal("Uneven landmark count.");  
43 - if (ROIs.size() % t.size() != 0) qFatal("Uneven ROI count.");  
44 - const int landmarkStep = landmarks.size() / t.size();  
45 - const int ROIStep = ROIs.size() / t.size(); 40 + QList<QPointF> points = t.file.points();
  41 + QList<QRectF> rects = t.file.rects();
  42 + if (points.size() % t.size() != 0) qFatal("Uneven point count.");
  43 + if (rects.size() % t.size() != 0) qFatal("Uneven rect count.");
  44 + const int pointStep = points.size() / t.size();
  45 + const int rectStep = rects.size() / t.size();
46 46
47 for (int i=0; i<t.size(); i++) { 47 for (int i=0; i<t.size(); i++) {
48 if (!fte || !t.file.get<bool>("enrollAll", false)) { 48 if (!fte || !t.file.get<bool>("enrollAll", false)) {
49 expanded.append(Template(t.file, t[i])); 49 expanded.append(Template(t.file, t[i]));
50 - expanded.last().file.setROIs(ROIs.mid(i*ROIStep, ROIStep));  
51 - expanded.last().file.setLandmarks(landmarks.mid(i*landmarkStep, landmarkStep)); 50 + expanded.last().file.setRects(rects.mid(i*rectStep, rectStep));
  51 + expanded.last().file.setPoints(points.mid(i*pointStep, pointStep));
52 } 52 }
53 } 53 }
54 } 54 }
sdk/plugins/random.cpp
@@ -155,7 +155,7 @@ class RndPointTransform : public Transform @@ -155,7 +155,7 @@ class RndPointTransform : public Transform
155 void project(const Template &src, Template &dst) const 155 void project(const Template &src, Template &dst) const
156 { 156 {
157 dst = src; 157 dst = src;
158 - dst.file.appendLandmark(QPointF(src.m().cols * x, src.m().rows * y)); 158 + dst.file.appendPoint(QPointF(src.m().cols * x, src.m().rows * y));
159 } 159 }
160 }; 160 };
161 161
sdk/plugins/regions.cpp
@@ -148,7 +148,7 @@ class RectFromLandmarksTransform : public UntrainableTransform @@ -148,7 +148,7 @@ class RectFromLandmarksTransform : public UntrainableTransform
148 148
149 void project(const Template &src, Template &dst) const 149 void project(const Template &src, Template &dst) const
150 { 150 {
151 - if (src.file.landmarks().isEmpty()) { 151 + if (src.file.points().isEmpty()) {
152 qWarning("No landmarks"); 152 qWarning("No landmarks");
153 dst = src; 153 dst = src;
154 return; 154 return;
@@ -160,12 +160,12 @@ class RectFromLandmarksTransform : public UntrainableTransform @@ -160,12 +160,12 @@ class RectFromLandmarksTransform : public UntrainableTransform
160 maxX = maxY = -std::numeric_limits<int>::max(); 160 maxX = maxY = -std::numeric_limits<int>::max();
161 161
162 foreach(int index, indices) { 162 foreach(int index, indices) {
163 - if (src.file.landmarks().size() > index+1) {  
164 - if (src.file.landmarks()[index].x() < minX) minX = src.file.landmarks()[index].x();  
165 - if (src.file.landmarks()[index].x() > maxX) maxX = src.file.landmarks()[index].x();  
166 - if (src.file.landmarks()[index].y() < minY) minY = src.file.landmarks()[index].y();  
167 - if (src.file.landmarks()[index].y() > maxY) maxY = src.file.landmarks()[index].y();  
168 - dst.file.appendLandmark(src.file.landmarks()[index]); 163 + if (src.file.points().size() > index+1) {
  164 + if (src.file.points()[index].x() < minX) minX = src.file.points()[index].x();
  165 + if (src.file.points()[index].x() > maxX) maxX = src.file.points()[index].x();
  166 + if (src.file.points()[index].y() < minY) minY = src.file.points()[index].y();
  167 + if (src.file.points()[index].y() > maxY) maxY = src.file.points()[index].y();
  168 + dst.file.appendPoint(src.file.points()[index]);
169 } 169 }
170 } 170 }
171 171
sdk/plugins/register.cpp
@@ -67,17 +67,14 @@ class AffineTransform : public UntrainableTransform @@ -67,17 +67,14 @@ class AffineTransform : public UntrainableTransform
67 else dstPoints[2] = Point2f(x3*width, y3*height); 67 else dstPoints[2] = Point2f(x3*width, y3*height);
68 68
69 Point2f srcPoints[3]; 69 Point2f srcPoints[3];
70 - if (src.file.contains("Affine_0_X") &&  
71 - src.file.contains("Affine_0_Y") &&  
72 - src.file.contains("Affine_1_X") &&  
73 - src.file.contains("Affine_1_Y") &&  
74 - (src.file.contains("Affine_2_X") || twoPoints) &&  
75 - (src.file.contains("Affine_2_Y") || twoPoints)) {  
76 - srcPoints[0] = Point2f(src.file.get<float>("Affine_0_X"), src.file.get<float>("Affine_0_Y"));  
77 - srcPoints[1] = Point2f(src.file.get<float>("Affine_1_X"), src.file.get<float>("Affine_1_Y"));  
78 - if (!twoPoints) srcPoints[2] = Point2f(src.file.get<float>("Affine_2_X"), src.file.get<float>("Affine_2_Y")); 70 + if (src.file.contains("Affine_0") &&
  71 + src.file.contains("Affine_1") &&
  72 + (src.file.contains("Affine_2") || twoPoints)) {
  73 + srcPoints[0] = OpenCVUtils::toPoint(src.file.get<QPointF>("Affine_0"));
  74 + srcPoints[1] = OpenCVUtils::toPoint(src.file.get<QPointF>("Affine_1"));
  75 + if (!twoPoints) srcPoints[2] = OpenCVUtils::toPoint(src.file.get<QPointF>("Affine_2"));
79 } else { 76 } else {
80 - const QList<Point2f> landmarks = OpenCVUtils::toPoints(src.file.landmarks()); 77 + const QList<Point2f> landmarks = OpenCVUtils::toPoints(src.file.points());
81 78
82 if ((landmarks.size() < 2) || (!twoPoints && (landmarks.size() < 3))) { 79 if ((landmarks.size() < 2) || (!twoPoints && (landmarks.size() < 3))) {
83 resize(src, dst, Size(width, height)); 80 resize(src, dst, Size(width, height));
@@ -87,14 +84,9 @@ class AffineTransform : public UntrainableTransform @@ -87,14 +84,9 @@ class AffineTransform : public UntrainableTransform
87 srcPoints[1] = landmarks[1]; 84 srcPoints[1] = landmarks[1];
88 if (!twoPoints) srcPoints[2] = landmarks[2]; 85 if (!twoPoints) srcPoints[2] = landmarks[2];
89 86
90 - dst.file.set("Affine_0_X", landmarks[0].x);  
91 - dst.file.set("Affine_0_Y", landmarks[0].y);  
92 - dst.file.set("Affine_1_X", landmarks[1].x);  
93 - dst.file.set("Affine_1_Y", landmarks[1].y);  
94 - if (!twoPoints) {  
95 - dst.file.set("Affine_2_X", landmarks[2].x);  
96 - dst.file.set("Affine_2_Y", landmarks[2].y);  
97 - } 87 + dst.file.set("Affine_0", OpenCVUtils::fromPoint(landmarks[0]));
  88 + dst.file.set("Affine_1", OpenCVUtils::fromPoint(landmarks[1]));
  89 + if (!twoPoints) dst.file.set("Affine_2", OpenCVUtils::fromPoint(landmarks[2]));
98 } 90 }
99 } 91 }
100 if (twoPoints) srcPoints[2] = getThirdAffinePoint(srcPoints[0], srcPoints[1]); 92 if (twoPoints) srcPoints[2] = getThirdAffinePoint(srcPoints[0], srcPoints[1]);
sdk/plugins/wavelet.cpp
@@ -189,11 +189,11 @@ class GaborJetTransform : public UntrainableTransform @@ -189,11 +189,11 @@ class GaborJetTransform : public UntrainableTransform
189 189
190 void project(const Template &src, Template &dst) const 190 void project(const Template &src, Template &dst) const
191 { 191 {
192 - const QList<QPointF> landmarks = src.file.landmarks();  
193 - dst = Mat(landmarks.size(), kReals.size(), CV_32FC1);  
194 - for (int i=0; i<landmarks.size(); i++) 192 + const QList<QPointF> points = src.file.points();
  193 + dst = Mat(points.size(), kReals.size(), CV_32FC1);
  194 + for (int i=0; i<points.size(); i++)
195 for (int j=0; j<kReals.size(); j++) 195 for (int j=0; j<kReals.size(); j++)
196 - dst.m().at<float>(i,j) = response(src, landmarks[i], kReals[j], kImaginaries[j], component); 196 + dst.m().at<float>(i,j) = response(src, points[i], kReals[j], kImaginaries[j], component);
197 } 197 }
198 }; 198 };
199 199