Commit 58b7965df42ccbb64e9da31fb28234447b6bd050

Authored by Scott Klum
1 parent ee8ebeeb

Fixed a stasm4 so that if eyes aren't present it will correctly default to single_search

Showing 1 changed file with 9 additions and 9 deletions
openbr/plugins/stasm4.cpp
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 #include "openbr/core/qtutils.h" 5 #include "openbr/core/qtutils.h"
6 #include "openbr/core/opencvutils.h" 6 #include "openbr/core/opencvutils.h"
7 #include <QString> 7 #include <QString>
8 -#include <Eigen/SVD>  
9 8
10 using namespace std; 9 using namespace std;
11 using namespace cv; 10 using namespace cv;
@@ -77,7 +76,7 @@ class StasmTransform : public UntrainableTransform @@ -77,7 +76,7 @@ class StasmTransform : public UntrainableTransform
77 76
78 StasmCascadeClassifier *stasmCascade = stasmCascadeResource.acquire(); 77 StasmCascadeClassifier *stasmCascade = stasmCascadeResource.acquire();
79 78
80 - int foundface; 79 + int foundFace = 0;
81 int nLandmarks = stasm_NLANDMARKS; 80 int nLandmarks = stasm_NLANDMARKS;
82 float landmarks[2 * stasm_NLANDMARKS]; 81 float landmarks[2 * stasm_NLANDMARKS];
83 82
@@ -109,13 +108,14 @@ class StasmTransform : public UntrainableTransform @@ -109,13 +108,14 @@ class StasmTransform : public UntrainableTransform
109 else if (i == 39) /*Stasm Left Eye*/ { eyes[2*i] = leftEye.x(); eyes[2*i+1] = leftEye.y(); } 108 else if (i == 39) /*Stasm Left Eye*/ { eyes[2*i] = leftEye.x(); eyes[2*i+1] = leftEye.y(); }
110 else { eyes[2*i] = 0; eyes[2*i+1] = 0; } 109 else { eyes[2*i] = 0; eyes[2*i+1] = 0; }
111 } 110 }
112 - } else qFatal("Unable to interpret pinned eyes."); 111 + stasm_search_pinned(landmarks, eyes, reinterpret_cast<const char*>(src.m().data), src.m().cols, src.m().rows, NULL);
113 112
114 - stasm_search_pinned(landmarks, eyes, reinterpret_cast<const char*>(src.m().data), src.m().cols, src.m().rows, NULL); 113 + // The ASM in Stasm is guaranteed to converge in this case
  114 + foundFace = 1;
  115 + }
  116 + }
115 117
116 - // The ASM in Stasm is guaranteed to converge in this case  
117 - foundface = 1;  
118 - } stasm_search_single(&foundface, landmarks, reinterpret_cast<const char*>(src.m().data), src.m().cols, src.m().rows, *stasmCascade, NULL, NULL); 118 + if (!foundFace) stasm_search_single(&foundFace, landmarks, reinterpret_cast<const char*>(src.m().data), src.m().cols, src.m().rows, *stasmCascade, NULL, NULL);
119 119
120 if (stasm3Format) { 120 if (stasm3Format) {
121 nLandmarks = 76; 121 nLandmarks = 76;
@@ -130,8 +130,8 @@ class StasmTransform : public UntrainableTransform @@ -130,8 +130,8 @@ class StasmTransform : public UntrainableTransform
130 dst.file.clearRects(); 130 dst.file.clearRects();
131 } 131 }
132 132
133 - if (!foundface) {  
134 - qWarning("No face found in %s", qPrintable(src.file.fileName())); 133 + if (!foundFace) {
  134 + qWarning("No face found in %s.", qPrintable(src.file.fileName()));
135 } else { 135 } else {
136 for (int i = 0; i < nLandmarks; i++) { 136 for (int i = 0; i < nLandmarks; i++) {
137 QPointF point(landmarks[2 * i], landmarks[2 * i + 1]); 137 QPointF point(landmarks[2 * i], landmarks[2 * i + 1]);