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

Function test_3

dlib/test/object_detector.cpp:880–926  ·  view source on GitHub ↗

make sure everything works even when the image isn't a dlib::array2d. So test with funny_image.

Source from the content-addressed store, hash-verified

878 // make sure everything works even when the image isn't a dlib::array2d.
879 // So test with funny_image.
880 void test_3 (
881 )
882 {
883 print_spinner();
884 dlog << LINFO << "test_3()";
885
886
887 typedef dlib::array<array2d<unsigned char> > grayscale_image_array_type;
888 typedef dlib::array<funny_image> funny_image_array_type;
889 grayscale_image_array_type images_temp;
890 funny_image_array_type images;
891 std::vector<std::vector<rectangle> > object_locations;
892 make_simple_test_data(images_temp, object_locations);
893 images.resize(images_temp.size());
894 for (unsigned long i = 0; i < images_temp.size(); ++i)
895 {
896 images[i].img.swap(images_temp[i]);
897 }
898
899 typedef scan_image_pyramid<pyramid_down_funny, very_simple_feature_extractor> image_scanner_type;
900 image_scanner_type scanner;
901 const rectangle object_box = compute_box_dimensions(1,70*70);
902 scanner.add_detection_template(object_box, create_grid_detection_template(object_box,2,2));
903 scanner.set_max_pyramid_levels(1);
904 structural_object_detection_trainer<image_scanner_type> trainer(scanner);
905 trainer.set_num_threads(4);
906 object_detector<image_scanner_type> detector = trainer.train(images, object_locations);
907
908 matrix<double> res = test_object_detection_function(detector, images, object_locations);
909 dlog << LINFO << "Test detector (precision,recall): " << res;
910 DLIB_TEST(sum(res) == 3);
911
912 res = cross_validate_object_detection_trainer(trainer, images, object_locations, 3);
913 dlog << LINFO << "3-fold cross validation (precision,recall): " << res;
914 DLIB_TEST(sum(res) == 3);
915
916 {
917 ostringstream sout;
918 serialize(detector, sout);
919 istringstream sin(sout.str());
920 object_detector<image_scanner_type> d2;
921 deserialize(d2, sin);
922 matrix<double> res = test_object_detection_function(d2, images, object_locations);
923 dlog << LINFO << "Test detector (precision,recall): " << res;
924 DLIB_TEST(sum(res) == 3);
925 }
926 }
927
928// ----------------------------------------------------------------------------------------
929

Callers 1

perform_testMethod · 0.85

Calls 15

print_spinnerFunction · 0.85
compute_box_dimensionsFunction · 0.85
make_simple_test_dataFunction · 0.70
serializeFunction · 0.70
deserializeFunction · 0.70
sumFunction · 0.50
resizeMethod · 0.45
sizeMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected