Commit 5b1a7183afa3ffe5aff87f4b6f74a4e3976e7825

Authored by Josh Klontz
1 parent e5056b7b

handle the case of few points

openbr/plugins/imgproc/synthesizekeypoints.cpp
@@ -155,10 +155,10 @@ class SynthesizePointsTransform : public MetadataTransform @@ -155,10 +155,10 @@ class SynthesizePointsTransform : public MetadataTransform
155 // Because not all triangulations are the same, we have to decide on a canonical set of triangles at training time. 155 // Because not all triangulations are the same, we have to decide on a canonical set of triangles at training time.
156 QHash<TriangleIndicies, int> counts; 156 QHash<TriangleIndicies, int> counts;
157 foreach (const Template &datum, data) { 157 foreach (const Template &datum, data) {
158 -  
159 const QList<QPointF> points = datum.file.points(); 158 const QList<QPointF> points = datum.file.points();
160 - if (points.size() == 0)  
161 - continue; 159 + if (points.size() <= 4)
  160 + continue;
  161 +
162 const QList< QList<int> > triangulation = getTriangulation(points, getBounds(points, 10)); 162 const QList< QList<int> > triangulation = getTriangulation(points, getBounds(points, 10));
163 if (triangulation.empty()) 163 if (triangulation.empty())
164 continue; 164 continue;
@@ -167,6 +167,9 @@ class SynthesizePointsTransform : public MetadataTransform @@ -167,6 +167,9 @@ class SynthesizePointsTransform : public MetadataTransform
167 counts[TriangleIndicies(indicies)]++; 167 counts[TriangleIndicies(indicies)]++;
168 } 168 }
169 169
  170 + if (counts.empty())
  171 + return;
  172 +
170 triangles.clear(); 173 triangles.clear();
171 QHash<TriangleIndicies, int>::const_iterator i = counts.constBegin(); 174 QHash<TriangleIndicies, int>::const_iterator i = counts.constBegin();
172 while (i != counts.constEnd()) { 175 while (i != counts.constEnd()) {