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

Function test_1m

dlib/test/object_detector.cpp:521–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519// ----------------------------------------------------------------------------------------
520
521 void test_1m (
522 )
523 {
524 print_spinner();
525 dlog << LINFO << "test_1m()";
526
527 typedef dlib::array<array2d<unsigned char> > grayscale_image_array_type;
528 grayscale_image_array_type images;
529 std::vector<std::vector<full_object_detection> > object_locations;
530 make_simple_test_data(images, object_locations);
531
532 typedef hashed_feature_image<hog_image<3,3,1,4,hog_signed_gradient,hog_full_interpolation> > feature_extractor_type;
533 typedef scan_image_pyramid<pyramid_down<2>, feature_extractor_type> image_scanner_type;
534 image_scanner_type scanner;
535 const rectangle object_box = compute_box_dimensions(1,35*35);
536 std::vector<rectangle> mboxes;
537 const int mbox_size = 20;
538 mboxes.push_back(centered_rect(0,0, mbox_size,mbox_size));
539 mboxes.push_back(centered_rect(0,0, mbox_size,mbox_size));
540 mboxes.push_back(centered_rect(0,0, mbox_size,mbox_size));
541 mboxes.push_back(centered_rect(0,0, mbox_size,mbox_size));
542 scanner.add_detection_template(object_box, create_grid_detection_template(object_box,1,1), mboxes);
543 setup_hashed_features(scanner, images, 9);
544 use_uniform_feature_weights(scanner);
545 structural_object_detection_trainer<image_scanner_type> trainer(scanner);
546 trainer.set_num_threads(4);
547 trainer.set_overlap_tester(test_box_overlap(0,0));
548 object_detector<image_scanner_type> detector = trainer.train(images, object_locations);
549
550 matrix<double> res = test_object_detection_function(detector, images, object_locations);
551 dlog << LINFO << "Test detector (precision,recall): " << res;
552 DLIB_TEST(sum(res) == 3);
553
554 {
555 ostringstream sout;
556 serialize(detector, sout);
557 istringstream sin(sout.str());
558 object_detector<image_scanner_type> d2;
559 deserialize(d2, sin);
560 matrix<double> res = test_object_detection_function(d2, images, object_locations);
561 dlog << LINFO << "Test detector (precision,recall): " << res;
562 DLIB_TEST(sum(res) == 3);
563
564 validate_some_object_detector_stuff(images, detector);
565 }
566 }
567
568// ----------------------------------------------------------------------------------------
569

Callers 1

perform_testMethod · 0.85

Calls 15

print_spinnerFunction · 0.85
compute_box_dimensionsFunction · 0.85
centered_rectFunction · 0.85
setup_hashed_featuresFunction · 0.85
set_overlap_testerMethod · 0.80
make_simple_test_dataFunction · 0.70
serializeFunction · 0.70
deserializeFunction · 0.70
test_box_overlapClass · 0.50

Tested by

no test coverage detected