Commit fabf7784a36333fb335e996effe9e2d8f2d27366

Authored by Josh Klontz
2 parents 352b8980 e6dc1bb9

Merge pull request #299 from biometrics/selectpoints_invert

allow SelectPoints to specify which points to exclude instead of include
Showing 1 changed file with 8 additions and 5 deletions
openbr/plugins/template.cpp
@@ -162,15 +162,18 @@ class SelectPointsTransform : public UntrainableMetadataTransform @@ -162,15 +162,18 @@ class SelectPointsTransform : public UntrainableMetadataTransform
162 { 162 {
163 Q_OBJECT 163 Q_OBJECT
164 Q_PROPERTY(QList<int> indices READ get_indices WRITE set_indices RESET reset_indices STORED false) 164 Q_PROPERTY(QList<int> indices READ get_indices WRITE set_indices RESET reset_indices STORED false)
  165 + Q_PROPERTY(bool invert READ get_invert WRITE set_invert RESET reset_invert STORED false) // keep the points _not_ in the list
165 BR_PROPERTY(QList<int>, indices, QList<int>()) 166 BR_PROPERTY(QList<int>, indices, QList<int>())
  167 + BR_PROPERTY(bool, invert, false)
166 168
167 void projectMetadata(const File &src, File &dst) const 169 void projectMetadata(const File &src, File &dst) const
168 { 170 {
169 - dst = src;  
170 - QList<QPointF> origPoints = src.points();  
171 - dst.clearPoints();  
172 - for (int i = 0; i < indices.size(); i++)  
173 - dst.appendPoint(origPoints[indices[i]]); 171 + const QList<QPointF> srcPoints = src.points();
  172 + QList<QPointF> dstPoints;
  173 + for (int i=0; i<srcPoints.size(); i++)
  174 + if (indices.contains(i) ^ invert)
  175 + dstPoints.append(srcPoints[i]);
  176 + dst.setPoints(dstPoints);
174 } 177 }
175 }; 178 };
176 179