Commit 2463460dca6d4554ef7306032e150b0123ffd7e4

Authored by Scott Klum
1 parent c996e5ae

Local

sdk/core/core.cpp
@@ -113,8 +113,9 @@ struct AlgorithmCore @@ -113,8 +113,9 @@ struct AlgorithmCore
113 QScopedPointer<Gallery> g(Gallery::make(gallery)); 113 QScopedPointer<Gallery> g(Gallery::make(gallery));
114 if (g.isNull()) return FileList(); 114 if (g.isNull()) return FileList();
115 115
116 - if (gallery.contains("read") || gallery.contains("cache")) 116 + if (gallery.contains("read") || gallery.contains("cache")) {
117 fileList = g->files(); 117 fileList = g->files();
  118 + }
118 if (!fileList.isEmpty() && gallery.contains("cache")) 119 if (!fileList.isEmpty() && gallery.contains("cache"))
119 return fileList; 120 return fileList;
120 121
sdk/plugins/filter.cpp
@@ -155,7 +155,6 @@ class CSDNTransform : public UntrainableTransform @@ -155,7 +155,6 @@ class CSDNTransform : public UntrainableTransform
155 } 155 }
156 } 156 }
157 157
158 - m.convertTo(m, CV_8UC1);  
159 dst = m; 158 dst = m;
160 159
161 } 160 }
@@ -214,6 +213,7 @@ class ContrastEqTransform : public UntrainableTransform @@ -214,6 +213,7 @@ class ContrastEqTransform : public UntrainableTransform
214 for (int i=0; i<nRows; i++) 213 for (int i=0; i<nRows; i++)
215 for (int j=0; j<nCols; j++) 214 for (int j=0; j<nCols; j++)
216 m.at<float>(i, j) = fast_tanh(p[i*nCols+j]); 215 m.at<float>(i, j) = fast_tanh(p[i*nCols+j]);
  216 +
217 dst = m; 217 dst = m;
218 } 218 }
219 }; 219 };
sdk/plugins/output.cpp
@@ -170,6 +170,7 @@ class rrOutput : public MatrixOutput @@ -170,6 +170,7 @@ class rrOutput : public MatrixOutput
170 const float threshold = file.getFloat("threshold", -std::numeric_limits<float>::max()); 170 const float threshold = file.getFloat("threshold", -std::numeric_limits<float>::max());
171 171
172 QStringList lines; 172 QStringList lines;
  173 +
173 for (int i=0; i<queryFiles.size(); i++) { 174 for (int i=0; i<queryFiles.size(); i++) {
174 QStringList files; 175 QStringList files;
175 if (!byLine) files.append(queryFiles[i]); 176 if (!byLine) files.append(queryFiles[i]);
@@ -181,7 +182,6 @@ class rrOutput : public MatrixOutput @@ -181,7 +182,6 @@ class rrOutput : public MatrixOutput
181 target.set("Score", QString::number(pair.first)); 182 target.set("Score", QString::number(pair.first));
182 files.append(target.flat()); 183 files.append(target.flat());
183 } 184 }
184 -  
185 lines.append(files.join(byLine ? "\n" : ",")); 185 lines.append(files.join(byLine ? "\n" : ","));
186 } 186 }
187 187
sdk/plugins/pp5.cpp
@@ -47,7 +47,7 @@ class PP5Initializer : public Initializer @@ -47,7 +47,7 @@ class PP5Initializer : public Initializer
47 { 47 {
48 TRY(ppr_initialize_sdk(qPrintable(Globals->sdkPath + "/share/openbr/models/pp5/"), my_license_id, my_license_key)) 48 TRY(ppr_initialize_sdk(qPrintable(Globals->sdkPath + "/share/openbr/models/pp5/"), my_license_id, my_license_key))
49 Globals->abbreviations.insert("PP5","Open!PP5Enroll:PP5Compare"); 49 Globals->abbreviations.insert("PP5","Open!PP5Enroll:PP5Compare");
50 - Globals->abbreviations.insert("RegisterFace", "Open+Cvt(Gray)+PP5Enroll(true)+Rename(PP5_Landmark0_Right_Eye_X,Affine_0_X)+Rename(PP5_Landmark0_Right_Eye_Y,Affine_0_Y)+Rename(PP5_Landmark1_Left_Eye_X,Affine_1_X)+Rename(PP5_Landmark1_Left_Eye_Y,Affine_1_Y)+Affine(96,128,0.28,0.45)"); 50 + Globals->abbreviations.insert("PP5Register", "Open+PP5Enroll(true)+RenameFirst([eyeLx,PP5_Landmark0_Right_Eye_X],Affine_0_X)+RenameFirst([eyeLy,PP5_Landmark0_Right_Eye_Y],Affine_0_Y)+RenameFirst([eyeRx,PP5_Landmark1_Left_Eye_X],Affine_1_X)+RenameFirst([eyeRy,PP5_Landmark1_Left_Eye_Y],Affine_1_Y)");
51 } 51 }
52 52
53 void finalize() const 53 void finalize() const
sdk/plugins/regions.cpp
@@ -148,7 +148,11 @@ class RectFromLandmarksTransform : public UntrainableTransform @@ -148,7 +148,11 @@ class RectFromLandmarksTransform : public UntrainableTransform
148 148
149 void project(const Template &src, Template &dst) const 149 void project(const Template &src, Template &dst) const
150 { 150 {
151 - if (src.file.landmarks().isEmpty()) qFatal("No landmarks"); 151 + if (src.file.landmarks().isEmpty()) {
  152 + qWarning("No landmarks");
  153 + dst = src;
  154 + return;
  155 + }
152 156
153 int minX, minY; 157 int minX, minY;
154 minX = minY = std::numeric_limits<int>::max(); 158 minX = minY = std::numeric_limits<int>::max();
@@ -156,7 +160,7 @@ class RectFromLandmarksTransform : public UntrainableTransform @@ -156,7 +160,7 @@ class RectFromLandmarksTransform : public UntrainableTransform
156 maxX = maxY = -std::numeric_limits<int>::max(); 160 maxX = maxY = -std::numeric_limits<int>::max();
157 161
158 foreach(int index, indices) { 162 foreach(int index, indices) {
159 - if (src.file.landmarks().size() < index+1) { 163 + if (src.file.landmarks().size() > index+1) {
160 if (src.file.landmarks()[index].x() < minX) minX = src.file.landmarks()[index].x(); 164 if (src.file.landmarks()[index].x() < minX) minX = src.file.landmarks()[index].x();
161 if (src.file.landmarks()[index].x() > maxX) maxX = src.file.landmarks()[index].x(); 165 if (src.file.landmarks()[index].x() > maxX) maxX = src.file.landmarks()[index].x();
162 if (src.file.landmarks()[index].y() < minY) minY = src.file.landmarks()[index].y(); 166 if (src.file.landmarks()[index].y() < minY) minY = src.file.landmarks()[index].y();
@@ -165,11 +169,16 @@ class RectFromLandmarksTransform : public UntrainableTransform @@ -165,11 +169,16 @@ class RectFromLandmarksTransform : public UntrainableTransform
165 } 169 }
166 } 170 }
167 171
168 - double width = maxX-minX+padding;  
169 - double height = maxY-minY+padding;  
170 - //double deltaHeight = ((width/aspectRatio) - height); 172 + // Padding is .05
  173 + double width = maxX-minX;
  174 + double deltaWidth = width*padding;
  175 + width += deltaWidth;
  176 +
  177 + double height = maxY-minY;
  178 + double deltaHeight = width/aspectRatio - height;
  179 + height += deltaHeight;
171 180
172 - dst.m() = src.m()(Rect(std::max(0.0, minX-padding/2.0), std::max(0.0, minY-padding/2.0), width, height)); 181 + dst.m() = src.m()(Rect(std::max(0.0, minX - deltaWidth/2.0), std::max(0.0, minY - deltaHeight/2.0), std::min((double)src.m().cols, width), std::min((double)src.m().rows, height)));
173 } 182 }
174 }; 183 };
175 184
sdk/plugins/stasm.cmake
@@ -6,9 +6,9 @@ if(${BR_WITH_STASM}) @@ -6,9 +6,9 @@ if(${BR_WITH_STASM})
6 set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Stasm_LIBS}) 6 set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${Stasm_LIBS})
7 7
8 if(WIN32) 8 if(WIN32)
9 - install(DIRECTORY ${Stasm_DIR}/lib/ DESTINATION bin) 9 + install(DIRECTORY ${Stasm_DIR}/build/ DESTINATION bin)
10 else() 10 else()
11 - install(DIRECTORY ${Stasm_DIR}/lib/ DESTINATION lib) 11 + install(DIRECTORY ${Stasm_DIR}/build/ DESTINATION lib)
12 endif() 12 endif()
13 13
14 install(DIRECTORY ${Stasm_DIR}/models/ DESTINATION share/openbr/models/stasm) 14 install(DIRECTORY ${Stasm_DIR}/models/ DESTINATION share/openbr/models/stasm)
sdk/plugins/stasm.cpp
@@ -18,11 +18,11 @@ class StasmInitializer : public Initializer @@ -18,11 +18,11 @@ class StasmInitializer : public Initializer
18 18
19 void initialize() const 19 void initialize() const
20 { 20 {
21 - Globals->abbreviations.insert("RectFromStasmEyes","RectFromLandmarks([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],10)"); 21 + Globals->abbreviations.insert("RectFromStasmEyes","RectFromLandmarks([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],0.125,6.0)+Resize(44,168)"); //
22 Globals->abbreviations.insert("RectFromStasmJaw","RectFromLandmarks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],10)"); 22 Globals->abbreviations.insert("RectFromStasmJaw","RectFromLandmarks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],10)");
23 - Globals->abbreviations.insert("RectFromStasmBrow","RectFromLandmarks([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],10)");  
24 - Globals->abbreviations.insert("RectFromStasmNose","RectFromLandmarks([37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47],10)");  
25 - Globals->abbreviations.insert("RectFromStasmMouth","RectFromLandmarks([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],10)"); 23 + Globals->abbreviations.insert("RectFromStasmBrow","RectFromLandmarks([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],0.05,6.5)+Resize(44,230)");
  24 + Globals->abbreviations.insert("RectFromStasmNose","RectFromLandmarks([37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47],0.05,1.25)");
  25 + Globals->abbreviations.insert("RectFromStasmMouth","RectFromLandmarks([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],0.15,3.0)+Resize(44,110)");
26 } 26 }
27 }; 27 };
28 28
@@ -38,6 +38,11 @@ class StasmTransform : public UntrainableTransform @@ -38,6 +38,11 @@ class StasmTransform : public UntrainableTransform
38 { 38 {
39 Q_OBJECT 39 Q_OBJECT
40 40
  41 + void init()
  42 + {
  43 + Globals->setProperty("parallelism", "0"); // Can only work in single threaded mode
  44 + }
  45 +
41 void project(const Template &src, Template &dst) const 46 void project(const Template &src, Template &dst) const
42 { 47 {
43 int nlandmarks; 48 int nlandmarks;
@@ -50,6 +55,7 @@ class StasmTransform : public UntrainableTransform @@ -50,6 +55,7 @@ class StasmTransform : public UntrainableTransform
50 if (nlandmarks == 0) qWarning("Unable to detect Stasm landmarks"); 55 if (nlandmarks == 0) qWarning("Unable to detect Stasm landmarks");
51 56
52 dst = src; 57 dst = src;
  58 +
53 for (int i = 0; i < nlandmarks; i++) 59 for (int i = 0; i < nlandmarks; i++)
54 dst.file.appendLandmark(QPointF(landmarks[2 * i], landmarks[2 * i + 1])); 60 dst.file.appendLandmark(QPointF(landmarks[2 * i], landmarks[2 * i + 1]));
55 } 61 }