| 371 | // ---------------------------------------------------------------------------------------- |
| 372 | |
| 373 | void test_fhog_pyramid ( |
| 374 | ) |
| 375 | { |
| 376 | print_spinner(); |
| 377 | dlog << LINFO << "test_fhog_pyramid()"; |
| 378 | |
| 379 | typedef dlib::array<array2d<unsigned char> > grayscale_image_array_type; |
| 380 | grayscale_image_array_type images; |
| 381 | std::vector<std::vector<rectangle> > object_locations; |
| 382 | make_simple_test_data(images, object_locations); |
| 383 | |
| 384 | typedef scan_fhog_pyramid<pyramid_down<2> > image_scanner_type; |
| 385 | image_scanner_type scanner; |
| 386 | scanner.set_detection_window_size(35,35); |
| 387 | structural_object_detection_trainer<image_scanner_type> trainer(scanner); |
| 388 | trainer.set_num_threads(4); |
| 389 | trainer.set_overlap_tester(test_box_overlap(0,0)); |
| 390 | object_detector<image_scanner_type> detector = trainer.train(images, object_locations); |
| 391 | |
| 392 | matrix<double> res = test_object_detection_function(detector, images, object_locations); |
| 393 | dlog << LINFO << "Test detector (precision,recall): " << res; |
| 394 | DLIB_TEST(sum(res) == 3); |
| 395 | |
| 396 | { |
| 397 | ostringstream sout; |
| 398 | serialize(detector, sout); |
| 399 | istringstream sin(sout.str()); |
| 400 | object_detector<image_scanner_type> d2; |
| 401 | deserialize(d2, sin); |
| 402 | matrix<double> res = test_object_detection_function(d2, images, object_locations); |
| 403 | dlog << LINFO << "Test detector (precision,recall): " << res; |
| 404 | DLIB_TEST(sum(res) == 3); |
| 405 | |
| 406 | validate_some_object_detector_stuff(images, detector, 1e-6); |
| 407 | } |
| 408 | |
| 409 | { |
| 410 | std::vector<object_detector<image_scanner_type> > detectors; |
| 411 | detectors.push_back(detector); |
| 412 | detectors.push_back(detector); |
| 413 | detectors.push_back(detector); |
| 414 | |
| 415 | std::vector<rectangle> dets1 = evaluate_detectors(detectors, images[0]); |
| 416 | std::vector<rectangle> dets2 = detector(images[0]); |
| 417 | DLIB_TEST(dets1.size() > 0); |
| 418 | DLIB_TEST(dets2.size()*3 == dets1.size()); |
| 419 | dlib::set<rectangle>::kernel_1a_c d1, d2; |
| 420 | for (unsigned long i = 0; i < dets1.size(); ++i) |
| 421 | { |
| 422 | if (!d1.is_member(dets1[i])) |
| 423 | d1.add(dets1[i]); |
| 424 | } |
| 425 | for (unsigned long i = 0; i < dets2.size(); ++i) |
| 426 | { |
| 427 | if (!d2.is_member(dets2[i])) |
| 428 | d2.add(dets2[i]); |
| 429 | } |
| 430 | DLIB_TEST(d1.size() == d2.size()); |
no test coverage detected