From 6ab3d0c5687b3b702c644ea061ddcbe744261fe9 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Mon, 29 Dec 2014 12:02:58 -0500 Subject: [PATCH] Separated point reordering functionality, reverted openbr_plugin change such that Fork is not affected --- openbr/openbr_plugin.cpp | 8 ++------ openbr/plugins/algorithms.cpp | 8 ++++---- openbr/plugins/regions.cpp | 8 ++++++++ openbr/plugins/register.cpp | 36 +++++++++++++----------------------- openbr/plugins/template.cpp | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 33 deletions(-) diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 5ba7b7c..44c94a3 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -81,10 +81,8 @@ QString File::hash() const void File::append(const QVariantMap &metadata) { - foreach (const QString &key, metadata.keys()) { - if (key != "Points" && key != "Rects") - set(key, metadata[key]); - } + foreach (const QString &key, metadata.keys()) + set(key, metadata[key]); } void File::append(const File &other) @@ -98,8 +96,6 @@ void File::append(const File &other) } } append(other.m_metadata); - appendPoints(other.points()); - appendRects(other.rects()); } QList File::split() const diff --git a/openbr/plugins/algorithms.cpp b/openbr/plugins/algorithms.cpp index f456dac..07e835f 100644 --- a/openbr/plugins/algorithms.cpp +++ b/openbr/plugins/algorithms.cpp @@ -79,10 +79,10 @@ class AlgorithmsInitializer : public Initializer Globals->abbreviations.insert("RegisterAffine", "Open+Affine(256,256,0.37,0.45)"); Globals->abbreviations.insert("ContrastEnhanced", "Open+Affine(256,256,0.37,0.45)+Cvt(Gray)+Blur(1.1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)"); Globals->abbreviations.insert("ColoredLBP", "Open+Affine(128,128,0.37,0.45)+Cvt(Gray)+Blur(1.1)+Gamma(0.2)+DoG(1,2)+ContrastEq(0.1,10)+LBP(1,2)+ColoredU2"); - Globals->abbreviations.insert("FlipMUCT","Flip(from=[ 0, 1, 2, 3, 4, 5, 6, 7, 17,18,19,20,21,31,32,36,37,38,39,40,41,48,49,50,55,56,60,61,65], \ - to=[16,15,14,13,12,11,10, 9, 26,25,24,23,22,35,34,45,44,43,42,47,46,54,53,52,59,58,64,63,67])"); - Globals->abbreviations.insert("FlipMUCTNoJaw","Flip(from=[0,1,2,3,4,14,15,19,20,21,22,23,24,31,32,33,38,39,43,44,48], \ - to=[9,8,7,6,5,18,17,28,27,26,25,30,29,37,36,35,42,41,47,46,50])"); + Globals->abbreviations.insert("FlipMUCT","Flip+ReorderPoints([ 0, 1, 2, 3, 4, 5, 6, 7, 17,18,19,20,21,31,32,36,37,38,39,40,41,48,49,50,55,56,60,61,65], \ + to=[16,15,14,13,12,11,10, 9, 26,25,24,23,22,35,34,45,44,43,42,47,46,54,53,52,59,58,64,63,67],true)"); + Globals->abbreviations.insert("FlipMUCTNoJaw","Flip+ReorderPoints([0,1,2,3,4,14,15,19,20,21,22,23,24,31,32,33,38,39,43,44,48], \ + [9,8,7,6,5,18,17,28,27,26,25,30,29,37,36,35,42,41,47,46,50],true)"); // Transforms Globals->abbreviations.insert("FaceDetection", "Open+Cvt(Gray)+Cascade(FrontalFace)"); diff --git a/openbr/plugins/regions.cpp b/openbr/plugins/regions.cpp index e6a88c8..1322248 100644 --- a/openbr/plugins/regions.cpp +++ b/openbr/plugins/regions.cpp @@ -246,8 +246,16 @@ class DupTransform : public UntrainableMetaTransform void project(const Template &src, Template &dst) const { + QList points = src.file.points(); + QList rects = src.file.rects(); + for (int i=0; i from READ get_from WRITE set_from RESET reset_from STORED false) - Q_PROPERTY(QList to READ get_to WRITE set_to RESET reset_to STORED false) public: /*!< */ @@ -144,34 +139,29 @@ public: private: BR_PROPERTY(Axis, axis, Y) - BR_PROPERTY(QList, from, QList()) - BR_PROPERTY(QList, to, QList()) void project(const TemplateList &src, TemplateList &dst) const { - dst.append(src.first()); for (int i=0; i flippedPoints; - foreach(const QPointF &point, dst.last().file.points()) { - if (axis == Y) { - flippedPoints.append(QPointF(src[i].m().cols-point.x(),point.y())); - } else if (axis == X) { - flippedPoints.append(QPointF(point.x(),src[i].m().rows-point.y())); - } else { - flippedPoints.append(QPointF(src[i].m().cols-point.x(),src[i].m().rows-point.y())); - } + QList flippedPoints; + foreach(const QPointF &point, src.last().file.points()) { + if (axis == Y) { + flippedPoints.append(QPointF(src[i].m().cols-point.x(),point.y())); + } else if (axis == X) { + flippedPoints.append(QPointF(point.x(),src[i].m().rows-point.y())); + } else { + flippedPoints.append(QPointF(src[i].m().cols-point.x(),src[i].m().rows-point.y())); } + } - for (int j=0; j from READ get_from WRITE set_from RESET reset_from STORED false) + Q_PROPERTY(QList to READ get_to WRITE set_to RESET reset_to STORED false) + Q_PROPERTY(bool flippedOnly READ get_flippedOnly WRITE set_flippedOnly RESET reset_flippedOnly STORED false) + BR_PROPERTY(QList, from, QList()) + BR_PROPERTY(QList, to, QList()) + BR_PROPERTY(bool, flippedOnly, false) + + void projectMetadata(const File &src, File &dst) const + { + if (flippedOnly && !src.contains("Flipped")) { + dst = src; + return; + } + + if (from.size() == to.size()) { + QList points = src.points(); + for (int i=0; i