From 1118137da25434b2f2468d858ecb9102f802cb27 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Thu, 10 Jul 2014 09:25:53 -0400 Subject: [PATCH] ROITransform now looks for X,Y,Width,Height fields --- openbr/openbr_plugin.cpp | 8 ++++++++ openbr/openbr_plugin.h | 1 + openbr/plugins/algorithms.cpp | 2 +- openbr/plugins/crop.cpp | 17 +++++++++++------ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 0d84260..0a2e9dc 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -126,6 +126,14 @@ bool File::contains(const QString &key) const return m_metadata.contains(key) || Globals->contains(key) || key == "name"; } +bool File::contains(const QStringList &keys) const +{ + foreach (const QString &key, keys) + if (!contains(key)) + return false; + return true; +} + QVariant File::value(const QString &key) const { return m_metadata.contains(key) ? m_metadata.value(key) : (key == "name" ? name : Globals->property(qPrintable(key))); diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index bc30f40..88ecdaf 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -213,6 +213,7 @@ struct BR_EXPORT File QString resolved() const; /*!< \brief Returns name prepended with Globals->path if name does not exist. */ bool contains(const QString &key) const; /*!< \brief Returns \c true if the key has an associated value, \c false otherwise. */ + bool contains(const QStringList &keys) const; /*!< \brief Returns \c true if all keys have associated values, \c false otherwise. */ QVariant value(const QString &key) const; /*!< \brief Returns the value for the specified key. */ static QVariant parse(const QString &value); /*!< \brief Try to convert the QString to a QPointF or QRectF if possible. */ inline void set(const QString &key, const QVariant &value) { m_metadata.insert(key, value); } /*!< \brief Insert or overwrite the metadata key with the specified value. */ diff --git a/openbr/plugins/algorithms.cpp b/openbr/plugins/algorithms.cpp index b8d6c58..5da894f 100644 --- a/openbr/plugins/algorithms.cpp +++ b/openbr/plugins/algorithms.cpp @@ -39,7 +39,7 @@ class AlgorithmsInitializer : public Initializer Globals->abbreviations.insert("BlurredFaceDetection", "Open+LimitSize(1024)+SkinMask/(Cvt(Gray)+GradientMask)+And+Morph(Erode,16)+LargestConvexArea"); Globals->abbreviations.insert("DrawFaceDetection", "Open+Cascade(FrontalFace)+Expand+ASEFEyes+Draw"); Globals->abbreviations.insert("ShowFaceDetection", "DrawFaceDetection+Expand+Show"); - Globals->abbreviations.insert("DownloadFaceRecognition", "Download+Expand+FaceDetection+Expand++Expand++++SetMetadata(AlgorithmID,-1):MatchProbability(ByteL1)"); + Globals->abbreviations.insert("DownloadFaceRecognition", "Download+ROI+Expand+FaceDetection+Expand++Expand++++SetMetadata(AlgorithmID,-1):MatchProbability(ByteL1)"); Globals->abbreviations.insert("OpenBR", "FaceRecognition"); Globals->abbreviations.insert("GenderEstimation", "GenderClassification"); Globals->abbreviations.insert("AgeEstimation", "AgeRegression"); diff --git a/openbr/plugins/crop.cpp b/openbr/plugins/crop.cpp index 9751962..cc0c359 100644 --- a/openbr/plugins/crop.cpp +++ b/openbr/plugins/crop.cpp @@ -65,14 +65,19 @@ class ROITransform : public UntrainableTransform if (!propName.isEmpty()) { QRectF rect = src.file.get(propName); dst += src.m()(OpenCVUtils::toRect(rect)); - } - else if (src.file.rects().empty()) { - dst = src; - if (Globals->verbose) qWarning("No rects present in file."); - } - else + } else if (!src.file.rects().empty()) { foreach (const QRectF &rect, src.file.rects()) dst += src.m()(OpenCVUtils::toRect(rect)); + } else if (src.file.contains(QStringList() << "X" << "Y" << "Width" << "Height")) { + dst += src.m()(Rect(src.file.get("X"), + src.file.get("Y"), + src.file.get("Width"), + src.file.get("Height"))); + } else { + dst = src; + if (Globals->verbose) + qWarning("No rects present in file."); + } } }; -- libgit2 0.21.4