Commit aadf59cd9d44127108dd7b9e96b3594d90aca499
1 parent
7b17e413
Revert "remove averagepoints"
This reverts commit d9cb5da3b9ac061676b92cff2520bb0bc54327b0.
Showing
1 changed file
with
43 additions
and
0 deletions
openbr/plugins/metadata/averagepoints.cpp
0 → 100644
| 1 | +#include <openbr/plugins/openbr_internal.h> | |
| 2 | + | |
| 3 | +namespace br | |
| 4 | +{ | |
| 5 | + | |
| 6 | +/*! | |
| 7 | + * \ingroup transforms | |
| 8 | + * \brief Averages a set of landmarks into a new landmark | |
| 9 | + * \author Brendan Klare \cite bklare | |
| 10 | + */ | |
| 11 | +class AveragePointsTransform : public UntrainableMetadataTransform | |
| 12 | +{ | |
| 13 | + Q_OBJECT | |
| 14 | + Q_PROPERTY(QList<int> indices READ get_indices WRITE set_indices RESET reset_indices STORED false) | |
| 15 | + Q_PROPERTY(QString metaName READ get_metaName WRITE set_metaName RESET reset_metaName STORED true) | |
| 16 | + Q_PROPERTY(bool append READ get_append WRITE set_append RESET reset_append STORED true) | |
| 17 | + BR_PROPERTY(QList<int>, indices, QList<int>()) | |
| 18 | + BR_PROPERTY(QString, metaName, "") | |
| 19 | + BR_PROPERTY(bool, append, false) | |
| 20 | + | |
| 21 | + void projectMetadata(const File &src, File &dst) const | |
| 22 | + { | |
| 23 | + dst = src; | |
| 24 | + float x1 = 0, y1 = 0; | |
| 25 | + | |
| 26 | + for (int i = 0; i < indices.size(); i++) { | |
| 27 | + x1 += src.points()[indices[i]].x(); | |
| 28 | + y1 += src.points()[indices[i]].y(); | |
| 29 | + } | |
| 30 | + | |
| 31 | + QPointF p(x1 / indices.size(), y1 / indices.size()); | |
| 32 | + if (!metaName.isEmpty()) | |
| 33 | + dst.set(metaName, p); | |
| 34 | + if (append) | |
| 35 | + dst.appendPoint(p); | |
| 36 | + } | |
| 37 | +}; | |
| 38 | + | |
| 39 | +BR_REGISTER(Transform, AveragePointsTransform) | |
| 40 | + | |
| 41 | +} // namespace br | |
| 42 | + | |
| 43 | +#include "metadata/averagepoints.moc" | ... | ... |