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