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

Function test_1_poly_nn

dlib/test/object_detector.cpp:705–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

703// ----------------------------------------------------------------------------------------
704
705 void test_1_poly_nn (
706 )
707 {
708 print_spinner();
709 dlog << LINFO << "test_1_poly_nn()";
710
711 typedef dlib::array<array2d<unsigned char> > grayscale_image_array_type;
712 grayscale_image_array_type images;
713 std::vector<std::vector<rectangle> > object_locations;
714 make_simple_test_data(images, object_locations);
715
716 typedef nearest_neighbor_feature_image<poly_image<5> > feature_extractor_type;
717 typedef scan_image_pyramid<pyramid_down<2>, feature_extractor_type> image_scanner_type;
718 image_scanner_type scanner;
719
720 setup_grid_detection_templates(scanner, object_locations, 2, 2);
721 feature_extractor_type nnfe;
722 pyramid_down<2> pyr_down;
723 poly_image<5> polyi;
724 nnfe.set_basis(randomly_sample_image_features(images, pyr_down, polyi, 80));
725 scanner.copy_configuration(nnfe);
726
727 structural_object_detection_trainer<image_scanner_type> trainer(scanner);
728 trainer.set_num_threads(4);
729 object_detector<image_scanner_type> detector = trainer.train(images, object_locations);
730
731 matrix<double> res = test_object_detection_function(detector, images, object_locations);
732 dlog << LINFO << "Test detector (precision,recall): " << res;
733 DLIB_TEST(sum(res) == 3);
734
735 {
736 ostringstream sout;
737 serialize(detector, sout);
738 istringstream sin(sout.str());
739 object_detector<image_scanner_type> d2;
740 deserialize(d2, sin);
741 matrix<double> res = test_object_detection_function(d2, images, object_locations);
742 dlog << LINFO << "Test detector (precision,recall): " << res;
743 DLIB_TEST(sum(res) == 3);
744
745 validate_some_object_detector_stuff(images, detector);
746 }
747 }
748
749// ----------------------------------------------------------------------------------------
750

Callers 1

perform_testMethod · 0.85

Calls 14

print_spinnerFunction · 0.85
make_simple_test_dataFunction · 0.70
serializeFunction · 0.70
deserializeFunction · 0.70
sumFunction · 0.50
set_basisMethod · 0.45
copy_configurationMethod · 0.45
set_num_threadsMethod · 0.45

Tested by

no test coverage detected