Commit e882744df2d2b3dabb95a8424ee9c01a296ab757

Authored by Josh Klontz
1 parent 0ea18168

switch to ppr_get_subject_similarity_score to support multi-signature templates

Showing 1 changed file with 18 additions and 17 deletions
openbr/plugins/pp5.cpp
... ... @@ -309,7 +309,7 @@ class PP5CompareDistance : public Distance
309 309 struct NativeGallery
310 310 {
311 311 FileList files;
312   - QList<int> faceIDs;
  312 + QList<int> subjectIDs;
313 313 ppr_gallery_type gallery;
314 314 };
315 315  
... ... @@ -322,7 +322,7 @@ class PP5CompareDistance : public Distance
322 322 ppr_free_gallery(gallery.gallery);
323 323 }
324 324  
325   - float compare(const cv::Mat &target, const cv::Mat &query) const
  325 + float compare(const Template &target, const Template &query) const
326 326 {
327 327 TemplateList targetList;
328 328 targetList.append(target);
... ... @@ -338,10 +338,10 @@ class PP5CompareDistance : public Distance
338 338 ppr_gallery_type target_gallery, query_gallery;
339 339 ppr_create_gallery(context, &target_gallery);
340 340 ppr_create_gallery(context, &query_gallery);
341   - QList<int> target_face_ids, query_face_ids;
342   - enroll(target, &target_gallery, target_face_ids);
343   - enroll(query, &query_gallery, query_face_ids);
344   - compareNative(target_gallery, target_face_ids, query_gallery, query_face_ids, output);
  341 + QList<int> target_subject_ids, query_subject_ids;
  342 + enroll(target, &target_gallery, target_subject_ids);
  343 + enroll(query, &query_gallery, query_subject_ids);
  344 + compareNative(target_gallery, target_subject_ids, query_gallery, query_subject_ids, output);
345 345 ppr_free_gallery(target_gallery);
346 346 ppr_free_gallery(query_gallery);
347 347 }
... ... @@ -351,12 +351,12 @@ class PP5CompareDistance : public Distance
351 351 ppr_similarity_matrix_type simmat;
352 352 TRY(ppr_compare_galleries(context, query, target, &simmat))
353 353 for (int i=0; i<queryIDs.size(); i++) {
354   - int query_face_id = queryIDs[i];
  354 + int query_subject_id = queryIDs[i];
355 355 for (int j=0; j<targetIDs.size(); j++) {
356   - int target_face_id = targetIDs[j];
  356 + int target_subject_id = targetIDs[j];
357 357 float score = -std::numeric_limits<float>::max();
358   - if ((query_face_id != -1) && (target_face_id != -1)) {
359   - TRY(ppr_get_face_similarity_score(context, simmat, query_face_id, target_face_id, &score))
  358 + if ((query_subject_id != -1) && (target_subject_id != -1)) {
  359 + TRY(ppr_get_subject_similarity_score(context, simmat, query_subject_id, target_subject_id, &score))
360 360 }
361 361 output->setRelative(score, i, j);
362 362 }
... ... @@ -364,19 +364,20 @@ class PP5CompareDistance : public Distance
364 364 ppr_free_similarity_matrix(simmat);
365 365 }
366 366  
367   - void enroll(const TemplateList &templates, ppr_gallery_type *gallery, QList<int> &face_ids) const
  367 + void enroll(const TemplateList &templates, ppr_gallery_type *gallery, QList<int> &subject_ids) const
368 368 {
369   - int face_id = 0;
  369 + int subject_id = 0, face_id = 0;
370 370 foreach (const Template &src, templates) {
371 371 if (src.m().data) {
372 372 ppr_face_type face;
373 373 createFace(src, &face);
374   - TRY(ppr_add_face(context, gallery, face, face_id, face_id))
375   - face_ids.append(face_id);
  374 + TRY(ppr_add_face(context, gallery, face, subject_id, face_id))
  375 + subject_ids.append(subject_id);
  376 + subject_id++;
376 377 face_id++;
377 378 ppr_free_face(face);
378 379 } else {
379   - face_ids.append(-1);
  380 + subject_ids.append(-1);
380 381 }
381 382 }
382 383 }
... ... @@ -390,7 +391,7 @@ class PP5CompareDistance : public Distance
390 391 } else {
391 392 ppr_create_gallery(context, &nativeGallery.gallery);
392 393 TemplateList templates = TemplateList::fromGallery(gallery);
393   - enroll(templates, &nativeGallery.gallery, nativeGallery.faceIDs);
  394 + enroll(templates, &nativeGallery.gallery, nativeGallery.subjectIDs);
394 395 nativeGallery.files = templates.files();
395 396 if (gallery.get<bool>("retain"))
396 397 cache.insert(gallery.name, nativeGallery);
... ... @@ -421,7 +422,7 @@ class PP5CompareDistance : public Distance
421 422  
422 423 QScopedPointer<Output> o(Output::make(output, nativeTarget.files, nativeQuery.files));
423 424 o->setBlock(0, 0);
424   - compareNative(nativeTarget.gallery, nativeTarget.faceIDs, nativeQuery.gallery, nativeQuery.faceIDs, o.data());
  425 + compareNative(nativeTarget.gallery, nativeTarget.subjectIDs, nativeQuery.gallery, nativeQuery.subjectIDs, o.data());
425 426  
426 427 cacheRelease(targetGallery, nativeTarget);
427 428 cacheRelease(queryGallery, nativeQuery);
... ...