From e882744df2d2b3dabb95a8424ee9c01a296ab757 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Wed, 7 May 2014 11:50:38 -0400 Subject: [PATCH] switch to ppr_get_subject_similarity_score to support multi-signature templates --- openbr/plugins/pp5.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/openbr/plugins/pp5.cpp b/openbr/plugins/pp5.cpp index 900decf..a247d65 100644 --- a/openbr/plugins/pp5.cpp +++ b/openbr/plugins/pp5.cpp @@ -309,7 +309,7 @@ class PP5CompareDistance : public Distance struct NativeGallery { FileList files; - QList faceIDs; + QList subjectIDs; ppr_gallery_type gallery; }; @@ -322,7 +322,7 @@ class PP5CompareDistance : public Distance ppr_free_gallery(gallery.gallery); } - float compare(const cv::Mat &target, const cv::Mat &query) const + float compare(const Template &target, const Template &query) const { TemplateList targetList; targetList.append(target); @@ -338,10 +338,10 @@ class PP5CompareDistance : public Distance ppr_gallery_type target_gallery, query_gallery; ppr_create_gallery(context, &target_gallery); ppr_create_gallery(context, &query_gallery); - QList target_face_ids, query_face_ids; - enroll(target, &target_gallery, target_face_ids); - enroll(query, &query_gallery, query_face_ids); - compareNative(target_gallery, target_face_ids, query_gallery, query_face_ids, output); + QList target_subject_ids, query_subject_ids; + enroll(target, &target_gallery, target_subject_ids); + enroll(query, &query_gallery, query_subject_ids); + compareNative(target_gallery, target_subject_ids, query_gallery, query_subject_ids, output); ppr_free_gallery(target_gallery); ppr_free_gallery(query_gallery); } @@ -351,12 +351,12 @@ class PP5CompareDistance : public Distance ppr_similarity_matrix_type simmat; TRY(ppr_compare_galleries(context, query, target, &simmat)) for (int i=0; i::max(); - if ((query_face_id != -1) && (target_face_id != -1)) { - TRY(ppr_get_face_similarity_score(context, simmat, query_face_id, target_face_id, &score)) + if ((query_subject_id != -1) && (target_subject_id != -1)) { + TRY(ppr_get_subject_similarity_score(context, simmat, query_subject_id, target_subject_id, &score)) } output->setRelative(score, i, j); } @@ -364,19 +364,20 @@ class PP5CompareDistance : public Distance ppr_free_similarity_matrix(simmat); } - void enroll(const TemplateList &templates, ppr_gallery_type *gallery, QList &face_ids) const + void enroll(const TemplateList &templates, ppr_gallery_type *gallery, QList &subject_ids) const { - int face_id = 0; + int subject_id = 0, face_id = 0; foreach (const Template &src, templates) { if (src.m().data) { ppr_face_type face; createFace(src, &face); - TRY(ppr_add_face(context, gallery, face, face_id, face_id)) - face_ids.append(face_id); + TRY(ppr_add_face(context, gallery, face, subject_id, face_id)) + subject_ids.append(subject_id); + subject_id++; face_id++; ppr_free_face(face); } else { - face_ids.append(-1); + subject_ids.append(-1); } } } @@ -390,7 +391,7 @@ class PP5CompareDistance : public Distance } else { ppr_create_gallery(context, &nativeGallery.gallery); TemplateList templates = TemplateList::fromGallery(gallery); - enroll(templates, &nativeGallery.gallery, nativeGallery.faceIDs); + enroll(templates, &nativeGallery.gallery, nativeGallery.subjectIDs); nativeGallery.files = templates.files(); if (gallery.get("retain")) cache.insert(gallery.name, nativeGallery); @@ -421,7 +422,7 @@ class PP5CompareDistance : public Distance QScopedPointer o(Output::make(output, nativeTarget.files, nativeQuery.files)); o->setBlock(0, 0); - compareNative(nativeTarget.gallery, nativeTarget.faceIDs, nativeQuery.gallery, nativeQuery.faceIDs, o.data()); + compareNative(nativeTarget.gallery, nativeTarget.subjectIDs, nativeQuery.gallery, nativeQuery.subjectIDs, o.data()); cacheRelease(targetGallery, nativeTarget); cacheRelease(queryGallery, nativeQuery); -- libgit2 0.21.4