MCPcopy Create free account
hub / github.com/davisking/dlib / test_shape_predictor

Function test_shape_predictor

dlib/image_processing/shape_predictor.h:441–502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439 typename image_array
440 >
441 double test_shape_predictor (
442 const shape_predictor& sp,
443 const image_array& images,
444 const std::vector<std::vector<full_object_detection> >& objects,
445 const std::vector<std::vector<double> >& scales
446 )
447 {
448 // make sure requires clause is not broken
449#ifdef ENABLE_ASSERTS
450 DLIB_CASSERT( images.size() == objects.size() ,
451 "\t double test_shape_predictor()"
452 << "\n\t Invalid inputs were given to this function. "
453 << "\n\t images.size(): " << images.size()
454 << "\n\t objects.size(): " << objects.size()
455 );
456 for (unsigned long i = 0; i < objects.size(); ++i)
457 {
458 for (unsigned long j = 0; j < objects[i].size(); ++j)
459 {
460 DLIB_CASSERT(objects[i][j].num_parts() == sp.num_parts(),
461 "\t double test_shape_predictor()"
462 << "\n\t Invalid inputs were given to this function. "
463 << "\n\t objects["<<i<<"]["<<j<<"].num_parts(): " << objects[i][j].num_parts()
464 << "\n\t sp.num_parts(): " << sp.num_parts()
465 );
466 }
467 if (scales.size() != 0)
468 {
469 DLIB_CASSERT(objects[i].size() == scales[i].size(),
470 "\t double test_shape_predictor()"
471 << "\n\t Invalid inputs were given to this function. "
472 << "\n\t objects["<<i<<"].size(): " << objects[i].size()
473 << "\n\t scales["<<i<<"].size(): " << scales[i].size()
474 );
475
476 }
477 }
478#endif
479
480 running_stats<double> rs;
481 for (unsigned long i = 0; i < objects.size(); ++i)
482 {
483 for (unsigned long j = 0; j < objects[i].size(); ++j)
484 {
485 // Just use a scale of 1 (i.e. no scale at all) if the caller didn't supply
486 // any scales.
487 const double scale = scales.size()==0 ? 1 : scales[i][j];
488
489 full_object_detection det = sp(images[i], objects[i][j].get_rect());
490
491 for (unsigned long k = 0; k < det.num_parts(); ++k)
492 {
493 if (objects[i][j].part(k) != OBJECT_PART_NOT_PRESENT)
494 {
495 double score = length(det.part(k) - objects[i][j].part(k))/scale;
496 rs.add(score);
497 }
498 }

Callers 4

mainFunction · 0.85
perform_testMethod · 0.85
mainFunction · 0.85

Calls 6

lengthFunction · 0.50
sizeMethod · 0.45
num_partsMethod · 0.45
get_rectMethod · 0.45
addMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected