From 05452b119e685f749465398309ff60fdb641968b Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Fri, 26 Dec 2014 11:18:36 -0500 Subject: [PATCH] Updated Flip and added RandRotate --- openbr/plugins/register.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/openbr/plugins/register.cpp b/openbr/plugins/register.cpp index 485d56c..d87ef16 100644 --- a/openbr/plugins/register.cpp +++ b/openbr/plugins/register.cpp @@ -125,7 +125,7 @@ BR_REGISTER(Transform, AffineTransform) * \brief Flips the image about an axis. * \author Josh Klontz \cite jklontz */ -class FlipTransform : public UntrainableTransform +class FlipTransform : public UntrainableMetaTransform { Q_OBJECT Q_ENUMS(Axis) @@ -140,14 +140,62 @@ public: private: BR_PROPERTY(Axis, axis, Y) - void project(const Template &src, Template &dst) const + void project(const TemplateList &src, TemplateList &dst) const { - flip(src, dst, axis); + dst.append(src.first()); + for (int i=0; i range READ get_range WRITE set_range RESET reset_range STORED false) + BR_PROPERTY(QList, range, QList() << -15 << 15) + + void project(const Template &src, Template &dst) const { + int span = range.first() - range.last(); + int angle = (rand() % span) + range.first(); + Mat rotMatrix = getRotationMatrix2D(Point2f(src.m().rows/2,src.m().cols/2),angle,1.0); + warpAffine(src,dst,rotMatrix,Size(src.m().cols,src.m().rows)); + + QList points = src.file.points(); + QList rotatedPoints; + for (int i=0; i(0,0)+ + points.at(i).y()*rotMatrix.at(0,1)+ + rotMatrix.at(0,2), + points.at(i).x()*rotMatrix.at(1,0)+ + points.at(i).y()*rotMatrix.at(1,1)+ + rotMatrix.at(1,2))); + } + + dst.file.setPoints(rotatedPoints); + } +}; + +BR_REGISTER(Transform, RandRotateTransform) + } // namespace br #include "register.moc" -- libgit2 0.21.4