From f30dde91db0bb8a256bb03e1a04f46cd914d4395 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Wed, 17 Jul 2013 12:15:23 -0400 Subject: [PATCH] Fixed FTO processing in a few cases --- openbr/core/bee.cpp | 8 +++++++- openbr/openbr_plugin.cpp | 2 +- openbr/plugins/distance.cpp | 2 ++ openbr/plugins/format.cpp | 4 ++-- openbr/plugins/pp5.cpp | 70 ++++++++++++++++++++++++++++++++++++---------------------------------- openbr/plugins/regions.cpp | 5 +++-- 6 files changed, 51 insertions(+), 40 deletions(-) diff --git a/openbr/core/bee.cpp b/openbr/core/bee.cpp index fb840ca..18c498b 100644 --- a/openbr/core/bee.cpp +++ b/openbr/core/bee.cpp @@ -43,9 +43,15 @@ FileList BEE::readSigset(const File &sigset, bool ignoreMetadata) QFile file(sigset.resolved()); bool success; success = file.open(QIODevice::ReadOnly); if (!success) qFatal("Unable to open %s for reading.", qPrintable(sigset)); - success = doc.setContent(&file); if (!success) qFatal("Unable to parse %s.", qPrintable(sigset)); + success = doc.setContent(&file); + file.close(); + if (!success) { + qWarning("Unable to parse %s.", qPrintable(sigset)); + return fileList; + } + QDomElement docElem = doc.documentElement(); if (docElem.nodeName() != "biometric-signature-set") return fileList; diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 82e5e15..0979d68 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -368,7 +368,7 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) QScopedPointer i(Gallery::make(file)); TemplateList newTemplates = i->read(); - // If file is a Format not a Gallery + // If file is a Format not a Gallery (e.g. XML Format vs. XML Gallery) if (newTemplates.isEmpty()) newTemplates.append(file); diff --git a/openbr/plugins/distance.cpp b/openbr/plugins/distance.cpp index 7f0cf71..cf5010c 100644 --- a/openbr/plugins/distance.cpp +++ b/openbr/plugins/distance.cpp @@ -56,6 +56,8 @@ private: float compare(const Template &a, const Template &b) const { + if (a.file.getBool("FTO") || b.file.getBool("FTO")) return -std::numeric_limits::max(); + if ((a.m().size != b.m().size) || (a.m().type() != b.m().type())) return -std::numeric_limits::max(); diff --git a/openbr/plugins/format.cpp b/openbr/plugins/format.cpp index 7a1294f..816b7f2 100644 --- a/openbr/plugins/format.cpp +++ b/openbr/plugins/format.cpp @@ -659,8 +659,8 @@ class xmlFormat : public Format QDomDocument doc(fileName); QFile f(fileName); - if (!f.open(QIODevice::ReadOnly)) qWarning("Unable to open %s for reading.", qPrintable(file.flat())); - if (!doc.setContent(&f)) qWarning("Unable to parse %s.", qPrintable(file.flat())); + if (!f.open(QIODevice::ReadOnly)) qFatal("Unable to open %s for reading.", qPrintable(file.flat())); + if (!doc.setContent(&f)) qWarning("Unable to parse %s.", qPrintable(file.flat())); f.close(); QDomElement docElem = doc.documentElement(); diff --git a/openbr/plugins/pp5.cpp b/openbr/plugins/pp5.cpp index 658a0d8..045e15b 100644 --- a/openbr/plugins/pp5.cpp +++ b/openbr/plugins/pp5.cpp @@ -241,41 +241,43 @@ class PP5EnrollTransform : public UntrainableMetaTransform PP5Context *context = contexts.acquire(); foreach(const Template & src, srcList) { - ppr_raw_image_type raw_image; - PP5Context::createRawImage(src, raw_image); - ppr_image_type image; - TRY(ppr_create_image(raw_image, &image)) - ppr_face_list_type face_list; - TRY(ppr_detect_faces(context->context, image, &face_list)) - - for (int i=0; icontext, face, &extractable)) - if (!extractable && !detectOnly) continue; - - cv::Mat m; - if (detectOnly) { - m = src; - } else { - TRY(ppr_extract_face_template(context->context, image, &face)) - context->createMat(face, m); - } - Template dst; - dst.file = src.file; - - dst.file.append(PP5Context::toMetadata(face)); - dst += m; - dstList.append(dst); - - // Found a face, nothing else to do (if we aren't trying to find multiple faces). - if (!Globals->enrollAll) - break; + if (!src.isEmpty()) { + ppr_raw_image_type raw_image; + PP5Context::createRawImage(src, raw_image); + ppr_image_type image; + TRY(ppr_create_image(raw_image, &image)) + ppr_face_list_type face_list; + TRY(ppr_detect_faces(context->context, image, &face_list)) + + for (int i=0; icontext, face, &extractable)) + if (!extractable && !detectOnly) continue; + + cv::Mat m; + if (detectOnly) { + m = src; + } else { + TRY(ppr_extract_face_template(context->context, image, &face)) + context->createMat(face, m); + } + Template dst; + dst.file = src.file; + + dst.file.append(PP5Context::toMetadata(face)); + dst += m; + dstList.append(dst); + + // Found a face, nothing else to do (if we aren't trying to find multiple faces). + if (!Globals->enrollAll) + break; + } + + ppr_free_face_list(face_list); + ppr_free_image(image); + ppr_raw_image_free(raw_image); } - - ppr_free_face_list(face_list); - ppr_free_image(image); - ppr_raw_image_free(raw_image); } // No faces were detected, output something with FTE set. diff --git a/openbr/plugins/regions.cpp b/openbr/plugins/regions.cpp index f047fb6..020f3e1 100644 --- a/openbr/plugins/regions.cpp +++ b/openbr/plugins/regions.cpp @@ -95,8 +95,9 @@ class CatTransform : public UntrainableMetaTransform for (int i=0; i offsets(partitions, 0); for (int i=0; i