Commit 1e61fbe144ca46c15f4245971a130c87a674165f
1 parent
b418c8e3
Generalized keytorect
Showing
1 changed file
with
16 additions
and
9 deletions
openbr/plugins/metadata/keytorect.cpp renamed to openbr/plugins/metadata/keytolandmark.cpp
| @@ -24,28 +24,35 @@ namespace br | @@ -24,28 +24,35 @@ namespace br | ||
| 24 | * \brief Convert values of key_X, key_Y, key_Width, key_Height to a rect. | 24 | * \brief Convert values of key_X, key_Y, key_Width, key_Height to a rect. |
| 25 | * \author Jordan Cheney \cite JordanCheney | 25 | * \author Jordan Cheney \cite JordanCheney |
| 26 | */ | 26 | */ |
| 27 | -class KeyToRectTransform : public UntrainableMetadataTransform | 27 | +class KeyToLandmarkTransform : public UntrainableMetadataTransform |
| 28 | { | 28 | { |
| 29 | Q_OBJECT | 29 | Q_OBJECT |
| 30 | Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false) | 30 | Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false) |
| 31 | + Q_PROPERTY(bool point READ get_point WRITE set_point RESET reset_point STORED false) | ||
| 31 | BR_PROPERTY(QString, key, "") | 32 | BR_PROPERTY(QString, key, "") |
| 33 | + BR_PROPERTY(bool, point, false) | ||
| 32 | 34 | ||
| 33 | void projectMetadata(const File &src, File &dst) const | 35 | void projectMetadata(const File &src, File &dst) const |
| 34 | { | 36 | { |
| 35 | dst = src; | 37 | dst = src; |
| 36 | 38 | ||
| 37 | - if (src.contains(QStringList() << key + "_X" << key + "_Y" << key + "_Width" << key + "_Height")) | ||
| 38 | - dst.appendRect(QRectF(src.get<int>(key + "_X"), | ||
| 39 | - src.get<int>(key + "_Y"), | ||
| 40 | - src.get<int>(key + "_Width"), | ||
| 41 | - src.get<int>(key + "_Height"))); | 39 | + if (point) { |
| 40 | + if (src.contains(QStringList() << key + "_X" << key + "_Y")) | ||
| 41 | + dst.appendPoint(QPointF(src.get<float>(key + "_X"), | ||
| 42 | + src.get<float>(key + "_Y"))); | ||
| 43 | + } else { | ||
| 44 | + if (src.contains(QStringList() << key + "_X" << key + "_Y" << key + "_Width" << key + "_Height")) | ||
| 45 | + dst.appendRect(QRectF(src.get<float>(key + "_X"), | ||
| 46 | + src.get<float>(key + "_Y"), | ||
| 47 | + src.get<float>(key + "_Width"), | ||
| 48 | + src.get<float>(key + "_Height"))); | ||
| 49 | + } | ||
| 42 | 50 | ||
| 43 | } | 51 | } |
| 44 | - | ||
| 45 | }; | 52 | }; |
| 46 | 53 | ||
| 47 | -BR_REGISTER(Transform, KeyToRectTransform) | 54 | +BR_REGISTER(Transform, KeyToLandmarkTransform) |
| 48 | 55 | ||
| 49 | } // namespace br | 56 | } // namespace br |
| 50 | 57 | ||
| 51 | -#include "metadata/keytorect.moc" | 58 | +#include "metadata/keytolandmark.moc" |