Commit e882744df2d2b3dabb95a8424ee9c01a296ab757
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,7 +309,7 @@ class PP5CompareDistance : public Distance | ||
| 309 | struct NativeGallery | 309 | struct NativeGallery |
| 310 | { | 310 | { |
| 311 | FileList files; | 311 | FileList files; |
| 312 | - QList<int> faceIDs; | 312 | + QList<int> subjectIDs; |
| 313 | ppr_gallery_type gallery; | 313 | ppr_gallery_type gallery; |
| 314 | }; | 314 | }; |
| 315 | 315 | ||
| @@ -322,7 +322,7 @@ class PP5CompareDistance : public Distance | @@ -322,7 +322,7 @@ class PP5CompareDistance : public Distance | ||
| 322 | ppr_free_gallery(gallery.gallery); | 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 | TemplateList targetList; | 327 | TemplateList targetList; |
| 328 | targetList.append(target); | 328 | targetList.append(target); |
| @@ -338,10 +338,10 @@ class PP5CompareDistance : public Distance | @@ -338,10 +338,10 @@ class PP5CompareDistance : public Distance | ||
| 338 | ppr_gallery_type target_gallery, query_gallery; | 338 | ppr_gallery_type target_gallery, query_gallery; |
| 339 | ppr_create_gallery(context, &target_gallery); | 339 | ppr_create_gallery(context, &target_gallery); |
| 340 | ppr_create_gallery(context, &query_gallery); | 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 | ppr_free_gallery(target_gallery); | 345 | ppr_free_gallery(target_gallery); |
| 346 | ppr_free_gallery(query_gallery); | 346 | ppr_free_gallery(query_gallery); |
| 347 | } | 347 | } |
| @@ -351,12 +351,12 @@ class PP5CompareDistance : public Distance | @@ -351,12 +351,12 @@ class PP5CompareDistance : public Distance | ||
| 351 | ppr_similarity_matrix_type simmat; | 351 | ppr_similarity_matrix_type simmat; |
| 352 | TRY(ppr_compare_galleries(context, query, target, &simmat)) | 352 | TRY(ppr_compare_galleries(context, query, target, &simmat)) |
| 353 | for (int i=0; i<queryIDs.size(); i++) { | 353 | for (int i=0; i<queryIDs.size(); i++) { |
| 354 | - int query_face_id = queryIDs[i]; | 354 | + int query_subject_id = queryIDs[i]; |
| 355 | for (int j=0; j<targetIDs.size(); j++) { | 355 | for (int j=0; j<targetIDs.size(); j++) { |
| 356 | - int target_face_id = targetIDs[j]; | 356 | + int target_subject_id = targetIDs[j]; |
| 357 | float score = -std::numeric_limits<float>::max(); | 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 | output->setRelative(score, i, j); | 361 | output->setRelative(score, i, j); |
| 362 | } | 362 | } |
| @@ -364,19 +364,20 @@ class PP5CompareDistance : public Distance | @@ -364,19 +364,20 @@ class PP5CompareDistance : public Distance | ||
| 364 | ppr_free_similarity_matrix(simmat); | 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 | foreach (const Template &src, templates) { | 370 | foreach (const Template &src, templates) { |
| 371 | if (src.m().data) { | 371 | if (src.m().data) { |
| 372 | ppr_face_type face; | 372 | ppr_face_type face; |
| 373 | createFace(src, &face); | 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 | face_id++; | 377 | face_id++; |
| 377 | ppr_free_face(face); | 378 | ppr_free_face(face); |
| 378 | } else { | 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,7 +391,7 @@ class PP5CompareDistance : public Distance | ||
| 390 | } else { | 391 | } else { |
| 391 | ppr_create_gallery(context, &nativeGallery.gallery); | 392 | ppr_create_gallery(context, &nativeGallery.gallery); |
| 392 | TemplateList templates = TemplateList::fromGallery(gallery); | 393 | TemplateList templates = TemplateList::fromGallery(gallery); |
| 393 | - enroll(templates, &nativeGallery.gallery, nativeGallery.faceIDs); | 394 | + enroll(templates, &nativeGallery.gallery, nativeGallery.subjectIDs); |
| 394 | nativeGallery.files = templates.files(); | 395 | nativeGallery.files = templates.files(); |
| 395 | if (gallery.get<bool>("retain")) | 396 | if (gallery.get<bool>("retain")) |
| 396 | cache.insert(gallery.name, nativeGallery); | 397 | cache.insert(gallery.name, nativeGallery); |
| @@ -421,7 +422,7 @@ class PP5CompareDistance : public Distance | @@ -421,7 +422,7 @@ class PP5CompareDistance : public Distance | ||
| 421 | 422 | ||
| 422 | QScopedPointer<Output> o(Output::make(output, nativeTarget.files, nativeQuery.files)); | 423 | QScopedPointer<Output> o(Output::make(output, nativeTarget.files, nativeQuery.files)); |
| 423 | o->setBlock(0, 0); | 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 | cacheRelease(targetGallery, nativeTarget); | 427 | cacheRelease(targetGallery, nativeTarget); |
| 427 | cacheRelease(queryGallery, nativeQuery); | 428 | cacheRelease(queryGallery, nativeQuery); |