Commit 32b35bfbf9f8fdf3841a27c0ee8c9dda1decc737
Merge branch 'master' of https://github.com/biometrics/openbr
Showing
2 changed files
with
25 additions
and
15 deletions
openbr/plugins/gallery.cpp
| @@ -856,8 +856,18 @@ class FDDBGallery : public Gallery | @@ -856,8 +856,18 @@ class FDDBGallery : public Gallery | ||
| 856 | for (int i=0; i<numDetects; i++) { | 856 | for (int i=0; i<numDetects; i++) { |
| 857 | const QStringList detect = lines.takeFirst().split(' '); | 857 | const QStringList detect = lines.takeFirst().split(' '); |
| 858 | Template t(fileName); | 858 | Template t(fileName); |
| 859 | - t.file.set("Face", QRectF(detect[0].toFloat(), detect[1].toFloat(), detect[2].toFloat(), detect[3].toFloat())); | ||
| 860 | - t.file.set("Confidence", detect[4].toFloat()); | 859 | + if (detect.size() == 5) { //rectangle |
| 860 | + t.file.set("Face", QRectF(detect[0].toFloat(), detect[1].toFloat(), detect[2].toFloat(), detect[3].toFloat())); | ||
| 861 | + t.file.set("Confidence", detect[4].toFloat()); | ||
| 862 | + } else if (detect.size() == 6) { //ellipse | ||
| 863 | + float x = detect[3].toFloat(), | ||
| 864 | + y = detect[4].toFloat(), | ||
| 865 | + radius = detect[1].toFloat(); | ||
| 866 | + t.file.set("Face", QRectF(x - radius,y - radius,radius * 2.0, radius * 2.0)); | ||
| 867 | + t.file.set("Confidence", detect[5].toFloat()); | ||
| 868 | + } else { | ||
| 869 | + qFatal("Unknown FDDB annotation format."); | ||
| 870 | + } | ||
| 861 | templates.append(t); | 871 | templates.append(t); |
| 862 | } | 872 | } |
| 863 | } | 873 | } |
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); |