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 | 38 | |
| 39 | 39 | FaceDet() {} // constructor |
| 40 | 40 | |
| 41 | - | |
| 42 | - vector<DetPar> detpars_; // all the valid faces in the current image | |
| 43 | - | |
| 44 | -private: | |
| 45 | 41 | int iface_; // index of current face for NextFace_ |
| 46 | 42 | // indexes into detpars_ |
| 43 | + vector<DetPar> detpars_; // all the valid faces in the current image | |
| 47 | 44 | |
| 45 | +private: | |
| 48 | 46 | DISALLOW_COPY_AND_ASSIGN(FaceDet); |
| 49 | 47 | |
| 50 | 48 | }; // end class FaceDet | ... | ... |
openbr/plugins/core/algorithms.cpp
| ... | ... | @@ -39,7 +39,7 @@ class AlgorithmsInitializer : public Initializer |
| 39 | 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 | 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 | 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 | 43 | Globals->abbreviations.insert("FR_Represent", "((DenseHOG/DenseLBP)+Cat+LDA(.98)+Normalize(L2))"); |
| 44 | 44 | |
| 45 | 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 | 67 | BR_PROPERTY(QList<float>, pinPoints, QList<float>()) |
| 68 | 68 | Q_PROPERTY(QStringList pinLabels READ get_pinLabels WRITE set_pinLabels RESET reset_pinLabels STORED false) |
| 69 | 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 | 73 | Resource<StasmCascadeClassifier> stasmCascadeResource; |
| 72 | 74 | |
| ... | ... | @@ -158,6 +160,21 @@ class StasmTransform : public UntrainableMetaTransform |
| 158 | 160 | StasmCascadeClassifier *stasmCascade = stasmCascadeResource.acquire(); |
| 159 | 161 | foundFace = 1; |
| 160 | 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 | 178 | while (foundFace) { |
| 162 | 179 | stasm_search_auto(&foundFace, landmarks, reinterpret_cast<const char*>(stasmSrc.data), stasmSrc.cols, stasmSrc.rows, *stasmCascade, detection); |
| 163 | 180 | if (foundFace) { | ... | ... |