Commit 10047515252e6be2e37f788331cf2b32847ea176

Authored by Josh Klontz
1 parent 210701f8

PP5 tweaks. Changed metadata 'Face' to 'FrontalFace' to be consistent with Casca…

…deTransform. Changed decision to output an empty template on a per template basis with a check against Globals->enrollAll
Showing 1 changed file with 13 additions and 13 deletions
openbr/plugins/pp5.cpp
@@ -154,10 +154,10 @@ struct PP5Context @@ -154,10 +154,10 @@ struct PP5Context
154 154
155 ppr_face_attributes_type face_attributes; 155 ppr_face_attributes_type face_attributes;
156 ppr_get_face_attributes(face, &face_attributes); 156 ppr_get_face_attributes(face, &face_attributes);
157 - metadata.insert("Face", QRectF(face_attributes.position.x - face_attributes.dimensions.width/2,  
158 - face_attributes.position.y - face_attributes.dimensions.height/2,  
159 - face_attributes.dimensions.width,  
160 - face_attributes.dimensions.height)); 157 + metadata.insert("FrontalFace", QRectF(face_attributes.position.x - face_attributes.dimensions.width/2,
  158 + face_attributes.position.y - face_attributes.dimensions.height/2,
  159 + face_attributes.dimensions.width,
  160 + face_attributes.dimensions.height));
161 metadata.insert("PP5_Face_Confidence", face_attributes.confidence); 161 metadata.insert("PP5_Face_Confidence", face_attributes.confidence);
162 metadata.insert("PP5_Face_Roll", face_attributes.rotation.roll); 162 metadata.insert("PP5_Face_Roll", face_attributes.rotation.roll);
163 metadata.insert("PP5_Face_Pitch", face_attributes.rotation.pitch); 163 metadata.insert("PP5_Face_Pitch", face_attributes.rotation.pitch);
@@ -240,7 +240,8 @@ class PP5EnrollTransform : public UntrainableMetaTransform @@ -240,7 +240,8 @@ class PP5EnrollTransform : public UntrainableMetaTransform
240 240
241 PP5Context *context = contexts.acquire(); 241 PP5Context *context = contexts.acquire();
242 242
243 - foreach(const Template & src, srcList) { 243 + foreach (const Template &src, srcList) {
  244 + bool foundFace = false;
244 if (!src.isEmpty()) { 245 if (!src.isEmpty()) {
245 ppr_raw_image_type raw_image; 246 ppr_raw_image_type raw_image;
246 PP5Context::createRawImage(src, raw_image); 247 PP5Context::createRawImage(src, raw_image);
@@ -254,6 +255,7 @@ class PP5EnrollTransform : public UntrainableMetaTransform @@ -254,6 +255,7 @@ class PP5EnrollTransform : public UntrainableMetaTransform
254 int extractable; 255 int extractable;
255 TRY(ppr_is_template_extractable(context->context, face, &extractable)) 256 TRY(ppr_is_template_extractable(context->context, face, &extractable))
256 if (!extractable && !detectOnly) continue; 257 if (!extractable && !detectOnly) continue;
  258 + else foundFace = true;
257 259
258 cv::Mat m; 260 cv::Mat m;
259 if (detectOnly) { 261 if (detectOnly) {
@@ -272,20 +274,18 @@ class PP5EnrollTransform : public UntrainableMetaTransform @@ -272,20 +274,18 @@ class PP5EnrollTransform : public UntrainableMetaTransform
272 // Found a face, nothing else to do (if we aren't trying to find multiple faces). 274 // Found a face, nothing else to do (if we aren't trying to find multiple faces).
273 if (!Globals->enrollAll) 275 if (!Globals->enrollAll)
274 break; 276 break;
275 - } 277 + }
276 278
277 ppr_free_face_list(face_list); 279 ppr_free_face_list(face_list);
278 ppr_free_image(image); 280 ppr_free_image(image);
279 ppr_raw_image_free(raw_image); 281 ppr_raw_image_free(raw_image);
280 } 282 }
281 - }  
282 283
283 - // No faces were detected, output something with FTE set.  
284 - if (dstList.empty()) {  
285 - dstList.append(srcList.first());  
286 - dstList.first().file.set("FTE",true);  
287 - if (!detectOnly)  
288 - dstList.first().m() = cv::Mat(); 284 + // No faces were detected when we were expecting one, output something with FTE set.
  285 + if (!foundFace && !Globals->enrollAll) {
  286 + dstList.append(Template(src.file, detectOnly ? src.m() : cv::Mat()));
  287 + dstList.last().file.set("FTE", true);
  288 + }
289 } 289 }
290 290
291 contexts.release(context); 291 contexts.release(context);