diff --git a/openbr/plugins/landmarks.cpp b/openbr/plugins/landmarks.cpp index 4266c80..6358fbd 100644 --- a/openbr/plugins/landmarks.cpp +++ b/openbr/plugins/landmarks.cpp @@ -437,6 +437,54 @@ class AnonymizeLandmarksTransform : public UntrainableMetadataTransform BR_REGISTER(Transform, AnonymizeLandmarksTransform) +class PointsToMatrixTransform : public UntrainableTransform +{ + Q_OBJECT + + Q_PROPERTY(QString inputVariable READ get_inputVariable WRITE set_inputVariable RESET reset_inputVariable STORED false) + BR_PROPERTY(QString, inputVariable, QString()) + + void project(const Template &src, Template &dst) const + { + dst = src; + + if (inputVariable.isEmpty()) { + dst.m() = OpenCVUtils::pointsToMatrix(dst.file.points()); + } else { + if (src.file.contains(inputVariable)) + dst.m() = OpenCVUtils::pointsToMatrix(dst.file.get >(inputVariable)); + } + } +}; + +BR_REGISTER(Transform, PointsToMatrixTransform) + +class NormalizePointsTransform : public UntrainableTransform +{ + Q_OBJECT + + Q_PROPERTY(int index READ get_index WRITE set_index RESET reset_index STORED false) + BR_PROPERTY(int, index, 0) +; + void project(const Template &src, Template &dst) const + { + dst = src; + + QList points = dst.file.points(); + QPointF normPoint = points.at(index); + + QList normalizedPoints; + normalizedPoints.append(normPoint); + for (int i=0; i