Commit b735d7791a8e1eb60a1fc00c5b294e304ad3a28e
1 parent
d81b25ae
Stasm uses rects or metadata key rect now
Showing
3 changed files
with
20 additions
and
5 deletions
3rdparty/stasm4.0.0/stasm/MOD_1/facedet.h
| @@ -38,13 +38,11 @@ public: | @@ -38,13 +38,11 @@ public: | ||
| 38 | 38 | ||
| 39 | FaceDet() {} // constructor | 39 | FaceDet() {} // constructor |
| 40 | 40 | ||
| 41 | - | ||
| 42 | - vector<DetPar> detpars_; // all the valid faces in the current image | ||
| 43 | - | ||
| 44 | -private: | ||
| 45 | int iface_; // index of current face for NextFace_ | 41 | int iface_; // index of current face for NextFace_ |
| 46 | // indexes into detpars_ | 42 | // indexes into detpars_ |
| 43 | + vector<DetPar> detpars_; // all the valid faces in the current image | ||
| 47 | 44 | ||
| 45 | +private: | ||
| 48 | DISALLOW_COPY_AND_ASSIGN(FaceDet); | 46 | DISALLOW_COPY_AND_ASSIGN(FaceDet); |
| 49 | 47 | ||
| 50 | }; // end class FaceDet | 48 | }; // end class FaceDet |
openbr/plugins/core/algorithms.cpp
| @@ -39,7 +39,7 @@ class AlgorithmsInitializer : public Initializer | @@ -39,7 +39,7 @@ class AlgorithmsInitializer : public Initializer | ||
| 39 | Globals->abbreviations.insert("FR_Mouth", "(CropFromLandmarks([59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76])+Resize(24,48))"); | 39 | Globals->abbreviations.insert("FR_Mouth", "(CropFromLandmarks([59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76])+Resize(24,48))"); |
| 40 | Globals->abbreviations.insert("FR_Nose", "(CropFromLandmarks([16,17,18,19,20,21,22,23,24,25,26,27],padding=3)+Resize(36,36))"); | 40 | Globals->abbreviations.insert("FR_Nose", "(CropFromLandmarks([16,17,18,19,20,21,22,23,24,25,26,27],padding=3)+Resize(36,36))"); |
| 41 | Globals->abbreviations.insert("FR_Face", "(Crop(24,24,88,88)+Resize(44,44))"); | 41 | Globals->abbreviations.insert("FR_Face", "(Crop(24,24,88,88)+Resize(44,44))"); |
| 42 | - Globals->abbreviations.insert("FR_Detect", "(Open+Cvt(Gray)+Stasm+Rename(StasmLeftEye,Affine_1,true)+Rename(StasmRightEye,Affine_0,true)+Affine(136,136,0.35,0.35,warpPoints=true))"); | 42 | + Globals->abbreviations.insert("FR_Detect", "(Open+Cvt(Gray)+Cascade+Stasm+Rename(StasmLeftEye,Affine_1,true)+Rename(StasmRightEye,Affine_0,true)+Affine(136,136,0.35,0.35,warpPoints=true))"); |
| 43 | Globals->abbreviations.insert("FR_Represent", "((DenseHOG/DenseLBP)+Cat+LDA(.98)+Normalize(L2))"); | 43 | Globals->abbreviations.insert("FR_Represent", "((DenseHOG/DenseLBP)+Cat+LDA(.98)+Normalize(L2))"); |
| 44 | 44 | ||
| 45 | Globals->abbreviations.insert("GenderClassification", "FaceDetection+Expand+FaceClassificationRegistration+Expand+<FaceClassificationExtraction>+<GenderClassifier>+Discard"); | 45 | Globals->abbreviations.insert("GenderClassification", "FaceDetection+Expand+FaceClassificationRegistration+Expand+<FaceClassificationExtraction>+<GenderClassifier>+Discard"); |
openbr/plugins/metadata/stasm4.cpp
| @@ -67,6 +67,8 @@ class StasmTransform : public UntrainableMetaTransform | @@ -67,6 +67,8 @@ class StasmTransform : public UntrainableMetaTransform | ||
| 67 | BR_PROPERTY(QList<float>, pinPoints, QList<float>()) | 67 | BR_PROPERTY(QList<float>, pinPoints, QList<float>()) |
| 68 | Q_PROPERTY(QStringList pinLabels READ get_pinLabels WRITE set_pinLabels RESET reset_pinLabels STORED false) | 68 | Q_PROPERTY(QStringList pinLabels READ get_pinLabels WRITE set_pinLabels RESET reset_pinLabels STORED false) |
| 69 | BR_PROPERTY(QStringList, pinLabels, QStringList()) | 69 | BR_PROPERTY(QStringList, pinLabels, QStringList()) |
| 70 | + Q_PROPERTY(QString inputVariable READ get_inputVariable WRITE set_inputVariable RESET reset_inputVariable STORED false) | ||
| 71 | + BR_PROPERTY(QString, inputVariable, "FrontalFace") | ||
| 70 | 72 | ||
| 71 | Resource<StasmCascadeClassifier> stasmCascadeResource; | 73 | Resource<StasmCascadeClassifier> stasmCascadeResource; |
| 72 | 74 | ||
| @@ -158,6 +160,21 @@ class StasmTransform : public UntrainableMetaTransform | @@ -158,6 +160,21 @@ class StasmTransform : public UntrainableMetaTransform | ||
| 158 | StasmCascadeClassifier *stasmCascade = stasmCascadeResource.acquire(); | 160 | StasmCascadeClassifier *stasmCascade = stasmCascadeResource.acquire(); |
| 159 | foundFace = 1; | 161 | foundFace = 1; |
| 160 | stasm::FaceDet detection; | 162 | stasm::FaceDet detection; |
| 163 | + | ||
| 164 | + QList<QRectF> rects = t.file.contains(inputVariable) ? QList<QRectF>() << t.file.get<QRectF>(inputVariable) : t.file.rects(); | ||
| 165 | + if (!rects.isEmpty()) detection.iface_ = 0; | ||
| 166 | + for (int i=0; i<rects.size(); i++) { | ||
| 167 | + Rect rect = OpenCVUtils::toRect(rects[i]); | ||
| 168 | + stasm::DetPar detpar; | ||
| 169 | + detpar.x = rect.x + rect.width / 2.; | ||
| 170 | + detpar.y = rect.y + rect.height / 2.; | ||
| 171 | + detpar.width = double(rect.width); | ||
| 172 | + detpar.height = double(rect.height); | ||
| 173 | + detpar.yaw = 0; | ||
| 174 | + detpar.eyaw = stasm::EYAW00; | ||
| 175 | + detection.detpars_.push_back(detpar); | ||
| 176 | + } | ||
| 177 | + | ||
| 161 | while (foundFace) { | 178 | while (foundFace) { |
| 162 | stasm_search_auto(&foundFace, landmarks, reinterpret_cast<const char*>(stasmSrc.data), stasmSrc.cols, stasmSrc.rows, *stasmCascade, detection); | 179 | stasm_search_auto(&foundFace, landmarks, reinterpret_cast<const char*>(stasmSrc.data), stasmSrc.cols, stasmSrc.rows, *stasmCascade, detection); |
| 163 | if (foundFace) { | 180 | if (foundFace) { |