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

Function test_2

dlib/test/object_detector.cpp:796–835  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794// ----------------------------------------------------------------------------------------
795
796 void test_2 (
797 )
798 {
799 print_spinner();
800 dlog << LINFO << "test_2()";
801
802 typedef dlib::array<array2d<unsigned char> > grayscale_image_array_type;
803 grayscale_image_array_type images;
804 std::vector<std::vector<rectangle> > object_locations;
805 make_simple_test_data(images, object_locations);
806
807 typedef scan_image_pyramid<pyramid_down<5>, very_simple_feature_extractor> image_scanner_type;
808 image_scanner_type scanner;
809 const rectangle object_box = compute_box_dimensions(1,70*70);
810 scanner.add_detection_template(object_box, create_grid_detection_template(object_box,2,2));
811 scanner.set_max_pyramid_levels(1);
812 structural_object_detection_trainer<image_scanner_type> trainer(scanner);
813 trainer.set_num_threads(0);
814 object_detector<image_scanner_type> detector = trainer.train(images, object_locations);
815
816 matrix<double> res = test_object_detection_function(detector, images, object_locations);
817 dlog << LINFO << "Test detector (precision,recall): " << res;
818 DLIB_TEST(sum(res) == 3);
819
820 res = cross_validate_object_detection_trainer(trainer, images, object_locations, 3);
821 dlog << LINFO << "3-fold cross validation (precision,recall): " << res;
822 DLIB_TEST(sum(res) == 3);
823
824 {
825 ostringstream sout;
826 serialize(detector, sout);
827 istringstream sin(sout.str());
828 object_detector<image_scanner_type> d2;
829 deserialize(d2, sin);
830 matrix<double> res = test_object_detection_function(d2, images, object_locations);
831 dlog << LINFO << "Test detector (precision,recall): " << res;
832 DLIB_TEST(sum(res) == 3);
833 validate_some_object_detector_stuff(images, detector);
834 }
835 }
836
837// ----------------------------------------------------------------------------------------
838

Callers 1

perform_testMethod · 0.85

Calls 13

print_spinnerFunction · 0.85
compute_box_dimensionsFunction · 0.85
make_simple_test_dataFunction · 0.70
serializeFunction · 0.70
deserializeFunction · 0.70
sumFunction · 0.50
set_num_threadsMethod · 0.45
trainMethod · 0.45

Tested by

no test coverage detected