Commit f30dde91db0bb8a256bb03e1a04f46cd914d4395

Authored by Scott Klum
1 parent 82113eb9

Fixed FTO processing in a few cases

openbr/core/bee.cpp
... ... @@ -43,9 +43,15 @@ FileList BEE::readSigset(const File &sigset, bool ignoreMetadata)
43 43 QFile file(sigset.resolved());
44 44 bool success;
45 45 success = file.open(QIODevice::ReadOnly); if (!success) qFatal("Unable to open %s for reading.", qPrintable(sigset));
46   - success = doc.setContent(&file); if (!success) qFatal("Unable to parse %s.", qPrintable(sigset));
  46 + success = doc.setContent(&file);
  47 +
47 48 file.close();
48 49  
  50 + if (!success) {
  51 + qWarning("Unable to parse %s.", qPrintable(sigset));
  52 + return fileList;
  53 + }
  54 +
49 55 QDomElement docElem = doc.documentElement();
50 56 if (docElem.nodeName() != "biometric-signature-set")
51 57 return fileList;
... ...
openbr/openbr_plugin.cpp
... ... @@ -368,7 +368,7 @@ TemplateList TemplateList::fromGallery(const br::File &gallery)
368 368 QScopedPointer<Gallery> i(Gallery::make(file));
369 369 TemplateList newTemplates = i->read();
370 370  
371   - // If file is a Format not a Gallery
  371 + // If file is a Format not a Gallery (e.g. XML Format vs. XML Gallery)
372 372 if (newTemplates.isEmpty())
373 373 newTemplates.append(file);
374 374  
... ...
openbr/plugins/distance.cpp
... ... @@ -56,6 +56,8 @@ private:
56 56  
57 57 float compare(const Template &a, const Template &b) const
58 58 {
  59 + if (a.file.getBool("FTO") || b.file.getBool("FTO")) return -std::numeric_limits<float>::max();
  60 +
59 61 if ((a.m().size != b.m().size) ||
60 62 (a.m().type() != b.m().type()))
61 63 return -std::numeric_limits<float>::max();
... ...
openbr/plugins/format.cpp
... ... @@ -659,8 +659,8 @@ class xmlFormat : public Format
659 659 QDomDocument doc(fileName);
660 660 QFile f(fileName);
661 661  
662   - if (!f.open(QIODevice::ReadOnly)) qWarning("Unable to open %s for reading.", qPrintable(file.flat()));
663   - if (!doc.setContent(&f)) qWarning("Unable to parse %s.", qPrintable(file.flat()));
  662 + if (!f.open(QIODevice::ReadOnly)) qFatal("Unable to open %s for reading.", qPrintable(file.flat()));
  663 + if (!doc.setContent(&f)) qWarning("Unable to parse %s.", qPrintable(file.flat()));
664 664 f.close();
665 665  
666 666 QDomElement docElem = doc.documentElement();
... ...
openbr/plugins/pp5.cpp
... ... @@ -241,41 +241,43 @@ class PP5EnrollTransform : public UntrainableMetaTransform
241 241 PP5Context *context = contexts.acquire();
242 242  
243 243 foreach(const Template & src, srcList) {
244   - ppr_raw_image_type raw_image;
245   - PP5Context::createRawImage(src, raw_image);
246   - ppr_image_type image;
247   - TRY(ppr_create_image(raw_image, &image))
248   - ppr_face_list_type face_list;
249   - TRY(ppr_detect_faces(context->context, image, &face_list))
250   -
251   - for (int i=0; i<face_list.length; i++) {
252   - ppr_face_type face = face_list.faces[i];
253   - int extractable;
254   - TRY(ppr_is_template_extractable(context->context, face, &extractable))
255   - if (!extractable && !detectOnly) continue;
256   -
257   - cv::Mat m;
258   - if (detectOnly) {
259   - m = src;
260   - } else {
261   - TRY(ppr_extract_face_template(context->context, image, &face))
262   - context->createMat(face, m);
263   - }
264   - Template dst;
265   - dst.file = src.file;
266   -
267   - dst.file.append(PP5Context::toMetadata(face));
268   - dst += m;
269   - dstList.append(dst);
270   -
271   - // Found a face, nothing else to do (if we aren't trying to find multiple faces).
272   - if (!Globals->enrollAll)
273   - break;
  244 + if (!src.isEmpty()) {
  245 + ppr_raw_image_type raw_image;
  246 + PP5Context::createRawImage(src, raw_image);
  247 + ppr_image_type image;
  248 + TRY(ppr_create_image(raw_image, &image))
  249 + ppr_face_list_type face_list;
  250 + TRY(ppr_detect_faces(context->context, image, &face_list))
  251 +
  252 + for (int i=0; i<face_list.length; i++) {
  253 + ppr_face_type face = face_list.faces[i];
  254 + int extractable;
  255 + TRY(ppr_is_template_extractable(context->context, face, &extractable))
  256 + if (!extractable && !detectOnly) continue;
  257 +
  258 + cv::Mat m;
  259 + if (detectOnly) {
  260 + m = src;
  261 + } else {
  262 + TRY(ppr_extract_face_template(context->context, image, &face))
  263 + context->createMat(face, m);
  264 + }
  265 + Template dst;
  266 + dst.file = src.file;
  267 +
  268 + dst.file.append(PP5Context::toMetadata(face));
  269 + dst += m;
  270 + dstList.append(dst);
  271 +
  272 + // Found a face, nothing else to do (if we aren't trying to find multiple faces).
  273 + if (!Globals->enrollAll)
  274 + break;
  275 + }
  276 +
  277 + ppr_free_face_list(face_list);
  278 + ppr_free_image(image);
  279 + ppr_raw_image_free(raw_image);
274 280 }
275   -
276   - ppr_free_face_list(face_list);
277   - ppr_free_image(image);
278   - ppr_raw_image_free(raw_image);
279 281 }
280 282  
281 283 // No faces were detected, output something with FTE set.
... ...
openbr/plugins/regions.cpp
... ... @@ -95,8 +95,9 @@ class CatTransform : public UntrainableMetaTransform
95 95 for (int i=0; i<src.size(); i++)
96 96 sizes[i%partitions] += src[i].total();
97 97  
98   - foreach (int size, sizes)
99   - dst.append(Mat(1, size, src.m().type()));
  98 + if (!src.empty())
  99 + foreach (int size, sizes)
  100 + dst.append(Mat(1, size, src.m().type()));
100 101  
101 102 QVector<int> offsets(partitions, 0);
102 103 for (int i=0; i<src.size(); i++) {
... ...