From 65854488bd77f98d68b41d07c956939bf9be69cb Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Wed, 1 Oct 2014 11:09:23 -0400 Subject: [PATCH] Added PointsToMatrix and NormalizePoints --- openbr/plugins/landmarks.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+), 0 deletions(-) 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