Commit 1118137da25434b2f2468d858ecb9102f802cb27
1 parent
be3307eb
ROITransform now looks for X,Y,Width,Height fields
Showing
4 changed files
with
21 additions
and
7 deletions
openbr/openbr_plugin.cpp
| ... | ... | @@ -126,6 +126,14 @@ bool File::contains(const QString &key) const |
| 126 | 126 | return m_metadata.contains(key) || Globals->contains(key) || key == "name"; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | +bool File::contains(const QStringList &keys) const | |
| 130 | +{ | |
| 131 | + foreach (const QString &key, keys) | |
| 132 | + if (!contains(key)) | |
| 133 | + return false; | |
| 134 | + return true; | |
| 135 | +} | |
| 136 | + | |
| 129 | 137 | QVariant File::value(const QString &key) const |
| 130 | 138 | { |
| 131 | 139 | return m_metadata.contains(key) ? m_metadata.value(key) : (key == "name" ? name : Globals->property(qPrintable(key))); | ... | ... |
openbr/openbr_plugin.h
| ... | ... | @@ -213,6 +213,7 @@ struct BR_EXPORT File |
| 213 | 213 | QString resolved() const; /*!< \brief Returns name prepended with Globals->path if name does not exist. */ |
| 214 | 214 | |
| 215 | 215 | bool contains(const QString &key) const; /*!< \brief Returns \c true if the key has an associated value, \c false otherwise. */ |
| 216 | + bool contains(const QStringList &keys) const; /*!< \brief Returns \c true if all keys have associated values, \c false otherwise. */ | |
| 216 | 217 | QVariant value(const QString &key) const; /*!< \brief Returns the value for the specified key. */ |
| 217 | 218 | static QVariant parse(const QString &value); /*!< \brief Try to convert the QString to a QPointF or QRectF if possible. */ |
| 218 | 219 | 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. */ | ... | ... |
openbr/plugins/algorithms.cpp
| ... | ... | @@ -39,7 +39,7 @@ class AlgorithmsInitializer : public Initializer |
| 39 | 39 | Globals->abbreviations.insert("BlurredFaceDetection", "Open+LimitSize(1024)+SkinMask/(Cvt(Gray)+GradientMask)+And+Morph(Erode,16)+LargestConvexArea"); |
| 40 | 40 | Globals->abbreviations.insert("DrawFaceDetection", "Open+Cascade(FrontalFace)+Expand+ASEFEyes+Draw"); |
| 41 | 41 | Globals->abbreviations.insert("ShowFaceDetection", "DrawFaceDetection+Expand+Show"); |
| 42 | - Globals->abbreviations.insert("DownloadFaceRecognition", "Download+Expand+FaceDetection+Expand+<FaceRecognitionRegistration>+Expand+<FaceRecognitionExtraction>+<FaceRecognitionEmbedding>+<FaceRecognitionQuantization>+SetMetadata(AlgorithmID,-1):MatchProbability(ByteL1)"); | |
| 42 | + Globals->abbreviations.insert("DownloadFaceRecognition", "Download+ROI+Expand+FaceDetection+Expand+<FaceRecognitionRegistration>+Expand+<FaceRecognitionExtraction>+<FaceRecognitionEmbedding>+<FaceRecognitionQuantization>+SetMetadata(AlgorithmID,-1):MatchProbability(ByteL1)"); | |
| 43 | 43 | Globals->abbreviations.insert("OpenBR", "FaceRecognition"); |
| 44 | 44 | Globals->abbreviations.insert("GenderEstimation", "GenderClassification"); |
| 45 | 45 | Globals->abbreviations.insert("AgeEstimation", "AgeRegression"); | ... | ... |
openbr/plugins/crop.cpp
| ... | ... | @@ -65,14 +65,19 @@ class ROITransform : public UntrainableTransform |
| 65 | 65 | if (!propName.isEmpty()) { |
| 66 | 66 | QRectF rect = src.file.get<QRectF>(propName); |
| 67 | 67 | dst += src.m()(OpenCVUtils::toRect(rect)); |
| 68 | - } | |
| 69 | - else if (src.file.rects().empty()) { | |
| 70 | - dst = src; | |
| 71 | - if (Globals->verbose) qWarning("No rects present in file."); | |
| 72 | - } | |
| 73 | - else | |
| 68 | + } else if (!src.file.rects().empty()) { | |
| 74 | 69 | foreach (const QRectF &rect, src.file.rects()) |
| 75 | 70 | dst += src.m()(OpenCVUtils::toRect(rect)); |
| 71 | + } else if (src.file.contains(QStringList() << "X" << "Y" << "Width" << "Height")) { | |
| 72 | + dst += src.m()(Rect(src.file.get<int>("X"), | |
| 73 | + src.file.get<int>("Y"), | |
| 74 | + src.file.get<int>("Width"), | |
| 75 | + src.file.get<int>("Height"))); | |
| 76 | + } else { | |
| 77 | + dst = src; | |
| 78 | + if (Globals->verbose) | |
| 79 | + qWarning("No rects present in file."); | |
| 80 | + } | |
| 76 | 81 | } |
| 77 | 82 | }; |
| 78 | 83 | ... | ... |