Commit 081174b91dc1e1cfa74d33040a1bde9b93b9d92b
1 parent
0ca00691
Transform to decompose rect to X, Y, Width, and Height in metadata (for universal templates)
Showing
1 changed file
with
35 additions
and
0 deletions
openbr/plugins/metadata/recttokeys.cpp
0 → 100644
| 1 | +#include <openbr/plugins/openbr_internal.h> | ||
| 2 | + | ||
| 3 | +namespace br | ||
| 4 | +{ | ||
| 5 | + | ||
| 6 | +/*! | ||
| 7 | + * \ingroup transforms | ||
| 8 | + * \brief Convert a rect to X, Y, Width, and Height. Handy to | ||
| 9 | + * \author Austin Blanton \cite imaus10 | ||
| 10 | + */ | ||
| 11 | +class RectToKeysTransform : public UntrainableMetadataTransform | ||
| 12 | +{ | ||
| 13 | + Q_OBJECT | ||
| 14 | + Q_PROPERTY(QString key READ get_key WRITE set_key RESET reset_key STORED false) | ||
| 15 | + BR_PROPERTY(QString, key, "") | ||
| 16 | + | ||
| 17 | + void projectMetadata(const File &src, File &dst) const | ||
| 18 | + { | ||
| 19 | + dst = src; | ||
| 20 | + if (src.contains(key)) { | ||
| 21 | + QRectF r = src.get<QRectF>(key); | ||
| 22 | + dst.set("Height", r.height()); | ||
| 23 | + dst.set("Width", r.width()); | ||
| 24 | + dst.set("X", r.left()); | ||
| 25 | + dst.set("Y", r.bottom()); | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | +}; | ||
| 30 | + | ||
| 31 | +BR_REGISTER(Transform, RectToKeysTransform) | ||
| 32 | + | ||
| 33 | +} // namespace br | ||
| 34 | + | ||
| 35 | +#include "metadata/recttokeys.moc" |