Commit 515eb7f4ee6edadf7b0ceec317ab9e39e7809116
1 parent
8306521a
Reverted changes in Flip to maintain old functionality
Showing
1 changed file
with
32 additions
and
46 deletions
openbr/plugins/register.cpp
| ... | ... | @@ -125,7 +125,7 @@ BR_REGISTER(Transform, AffineTransform) |
| 125 | 125 | * \brief Flips the image about an axis. |
| 126 | 126 | * \author Josh Klontz \cite jklontz |
| 127 | 127 | */ |
| 128 | -class FlipTransform : public UntrainableMetaTransform | |
| 128 | +class FlipTransform : public UntrainableTransform | |
| 129 | 129 | { |
| 130 | 130 | Q_OBJECT |
| 131 | 131 | Q_ENUMS(Axis) |
| ... | ... | @@ -140,59 +140,45 @@ public: |
| 140 | 140 | private: |
| 141 | 141 | BR_PROPERTY(Axis, axis, Y) |
| 142 | 142 | |
| 143 | - void project(const TemplateList &src, TemplateList &dst) const | |
| 143 | + void project(const Template &src, Template &dst) const | |
| 144 | 144 | { |
| 145 | - for (int i=0; i<src.size(); i++) { | |
| 146 | - dst.append(src[i]); | |
| 147 | - | |
| 148 | - Mat buffer; | |
| 149 | - flip(src[i], buffer, axis); | |
| 150 | - dst.append(Template(src[i].file,buffer)); | |
| 151 | - | |
| 152 | - QList<QPointF> flippedPoints; | |
| 153 | - foreach(const QPointF &point, src[i].file.points()) { | |
| 154 | - if (axis == Y) { | |
| 155 | - flippedPoints.append(QPointF(src[i].m().cols-point.x(),point.y())); | |
| 156 | - } else if (axis == X) { | |
| 157 | - flippedPoints.append(QPointF(point.x(),src[i].m().rows-point.y())); | |
| 158 | - } else { | |
| 159 | - flippedPoints.append(QPointF(src[i].m().cols-point.x(),src[i].m().rows-point.y())); | |
| 160 | - } | |
| 145 | + flip(src, dst, axis); | |
| 146 | + | |
| 147 | + QList<QPointF> flippedPoints; | |
| 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())); | |
| 161 | 155 | } |
| 156 | + } | |
| 162 | 157 | |
| 163 | - QList<QRectF> flippedRects; | |
| 164 | - foreach(const QRectF &rect, src[i].file.rects()) { | |
| 165 | - if (axis == Y) { | |
| 166 | - flippedRects.append(QRectF(src[i].m().cols-rect.right(), | |
| 167 | - rect.y(), | |
| 168 | - rect.width(), | |
| 169 | - rect.height())); | |
| 170 | - } else if (axis == X) { | |
| 171 | - flippedRects.append(QRectF(rect.x(), | |
| 172 | - src[i].m().rows-rect.bottom(), | |
| 173 | - rect.width(), | |
| 174 | - rect.height())); | |
| 175 | - } else { | |
| 176 | - flippedRects.append(QRectF(src[i].m().cols-rect.right(), | |
| 177 | - src[i].m().rows-rect.bottom(), | |
| 178 | - rect.width(), | |
| 179 | - rect.height())); | |
| 180 | - } | |
| 158 | + QList<QRectF> flippedRects; | |
| 159 | + foreach(const QRectF &rect, src.file.rects()) { | |
| 160 | + if (axis == Y) { | |
| 161 | + flippedRects.append(QRectF(src.m().cols-rect.right(), | |
| 162 | + rect.y(), | |
| 163 | + rect.width(), | |
| 164 | + rect.height())); | |
| 165 | + } else if (axis == X) { | |
| 166 | + flippedRects.append(QRectF(rect.x(), | |
| 167 | + src.m().rows-rect.bottom(), | |
| 168 | + rect.width(), | |
| 169 | + rect.height())); | |
| 170 | + } else { | |
| 171 | + flippedRects.append(QRectF(src.m().cols-rect.right(), | |
| 172 | + src.m().rows-rect.bottom(), | |
| 173 | + rect.width(), | |
| 174 | + rect.height())); | |
| 181 | 175 | } |
| 182 | - | |
| 183 | - dst.last().file.setPoints(flippedPoints); | |
| 184 | - dst.last().file.setRects(flippedRects); | |
| 185 | - dst.last().file.set("Flipped",true); | |
| 186 | 176 | } |
| 187 | - } | |
| 188 | 177 | |
| 189 | - void project(const Template &src, Template &dst) const { | |
| 190 | - TemplateList temp; | |
| 191 | - project(TemplateList() << src, temp); | |
| 192 | - if (!temp.isEmpty()) dst = temp.first(); | |
| 178 | + dst.file.setPoints(flippedPoints); | |
| 179 | + dst.file.setRects(flippedRects); | |
| 193 | 180 | } |
| 194 | 181 | }; |
| 195 | - | |
| 196 | 182 | BR_REGISTER(Transform, FlipTransform) |
| 197 | 183 | |
| 198 | 184 | /*! | ... | ... |