Commit 262f80c2e7ffe65828d1cfbc7cba9f7fcfcd9ed4
1 parent
e7549375
Handling missing data in Flip and ReorderPoints
Showing
2 changed files
with
15 additions
and
9 deletions
openbr/plugins/register.cpp
| ... | ... | @@ -146,12 +146,15 @@ private: |
| 146 | 146 | |
| 147 | 147 | QList<QPointF> flippedPoints; |
| 148 | 148 | foreach(const QPointF &point, src.file.points()) { |
| 149 | - if (axis == Y) { | |
| 150 | - flippedPoints.append(QPointF(src.m().cols-point.x(),point.y())); | |
| 151 | - } else if (axis == X) { | |
| 152 | - flippedPoints.append(QPointF(point.x(),src.m().rows-point.y())); | |
| 153 | - } else { | |
| 154 | - flippedPoints.append(QPointF(src.m().cols-point.x(),src.m().rows-point.y())); | |
| 149 | + // Check for missing data using the QPointF(-1,-1) convention | |
| 150 | + if (point != QPointF(-1,-1)) { | |
| 151 | + if (axis == Y) { | |
| 152 | + flippedPoints.append(QPointF(src.m().cols-point.x(),point.y())); | |
| 153 | + } else if (axis == X) { | |
| 154 | + flippedPoints.append(QPointF(point.x(),src.m().rows-point.y())); | |
| 155 | + } else { | |
| 156 | + flippedPoints.append(QPointF(src.m().cols-point.x(),src.m().rows-point.y())); | |
| 157 | + } | |
| 155 | 158 | } |
| 156 | 159 | } |
| 157 | 160 | ... | ... |
openbr/plugins/template.cpp
| ... | ... | @@ -229,9 +229,12 @@ class ReorderPointsTransform : public UntrainableMetadataTransform |
| 229 | 229 | { |
| 230 | 230 | if (from.size() == to.size()) { |
| 231 | 231 | QList<QPointF> points = src.points(); |
| 232 | - for (int i=0; i<from.size(); i++) | |
| 233 | - std::swap(points[from[i]],points[to[i]]); | |
| 234 | - dst.setPoints(points); | |
| 232 | + if (!points.contains(QPointF(-1,-1))) { | |
| 233 | + for (int i=0; i<from.size(); i++) { | |
| 234 | + std::swap(points[from[i]],points[to[i]]); | |
| 235 | + } | |
| 236 | + dst.setPoints(points); | |
| 237 | + } | |
| 235 | 238 | } else qFatal("Inconsistent sizes for to and from index lists."); |
| 236 | 239 | } |
| 237 | 240 | }; | ... | ... |