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

Function test_1

dlib/test/object_detector.cpp:437–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435// ----------------------------------------------------------------------------------------
436
437 void test_1 (
438 )
439 {
440 print_spinner();
441 dlog << LINFO << "test_1()";
442
443 typedef dlib::array<array2d<unsigned char> > grayscale_image_array_type;
444 grayscale_image_array_type images;
445 std::vector<std::vector<rectangle> > object_locations;
446 make_simple_test_data(images, object_locations);
447
448 typedef hashed_feature_image<hog_image<3,3,1,4,hog_signed_gradient,hog_full_interpolation> > feature_extractor_type;
449 typedef scan_image_pyramid<pyramid_down<2>, feature_extractor_type> image_scanner_type;
450 image_scanner_type scanner;
451 const rectangle object_box = compute_box_dimensions(1,35*35);
452 scanner.add_detection_template(object_box, create_grid_detection_template(object_box,2,2));
453 setup_hashed_features(scanner, images, 9);
454 use_uniform_feature_weights(scanner);
455 structural_object_detection_trainer<image_scanner_type> trainer(scanner);
456 trainer.set_num_threads(4);
457 trainer.set_overlap_tester(test_box_overlap(0,0));
458 object_detector<image_scanner_type> detector = trainer.train(images, object_locations);
459
460 matrix<double> res = test_object_detection_function(detector, images, object_locations);
461 dlog << LINFO << "Test detector (precision,recall): " << res;
462 DLIB_TEST(sum(res) == 3);
463
464 {
465 ostringstream sout;
466 serialize(detector, sout);
467 istringstream sin(sout.str());
468 object_detector<image_scanner_type> d2;
469 deserialize(d2, sin);
470 matrix<double> res = test_object_detection_function(d2, images, object_locations);
471 dlog << LINFO << "Test detector (precision,recall): " << res;
472 DLIB_TEST(sum(res) == 3);
473
474 validate_some_object_detector_stuff(images, detector);
475 }
476 }
477
478// ----------------------------------------------------------------------------------------
479

Callers 1

perform_testMethod · 0.85

Calls 15

print_spinnerFunction · 0.85
compute_box_dimensionsFunction · 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