| 611 | // ---------------------------------------------------------------------------------------- |
| 612 | |
| 613 | void test_1_poly ( |
| 614 | ) |
| 615 | { |
| 616 | print_spinner(); |
| 617 | dlog << LINFO << "test_1_poly()"; |
| 618 | |
| 619 | typedef dlib::array<array2d<unsigned char> > grayscale_image_array_type; |
| 620 | grayscale_image_array_type images; |
| 621 | std::vector<std::vector<rectangle> > object_locations; |
| 622 | make_simple_test_data(images, object_locations); |
| 623 | |
| 624 | typedef hashed_feature_image<poly_image<2> > feature_extractor_type; |
| 625 | typedef scan_image_pyramid<pyramid_down<2>, feature_extractor_type> image_scanner_type; |
| 626 | image_scanner_type scanner; |
| 627 | const rectangle object_box = compute_box_dimensions(1,35*35); |
| 628 | scanner.add_detection_template(object_box, create_grid_detection_template(object_box,2,2)); |
| 629 | setup_hashed_features(scanner, images, 9); |
| 630 | use_uniform_feature_weights(scanner); |
| 631 | structural_object_detection_trainer<image_scanner_type> trainer(scanner); |
| 632 | trainer.set_num_threads(4); |
| 633 | trainer.set_overlap_tester(test_box_overlap(0,0)); |
| 634 | object_detector<image_scanner_type> detector = trainer.train(images, object_locations); |
| 635 | |
| 636 | matrix<double> res = test_object_detection_function(detector, images, object_locations); |
| 637 | dlog << LINFO << "Test detector (precision,recall): " << res; |
| 638 | DLIB_TEST(sum(res) == 3); |
| 639 | |
| 640 | { |
| 641 | ostringstream sout; |
| 642 | serialize(detector, sout); |
| 643 | istringstream sin(sout.str()); |
| 644 | object_detector<image_scanner_type> d2; |
| 645 | deserialize(d2, sin); |
| 646 | matrix<double> res = test_object_detection_function(d2, images, object_locations); |
| 647 | dlog << LINFO << "Test detector (precision,recall): " << res; |
| 648 | DLIB_TEST(sum(res) == 3); |
| 649 | |
| 650 | validate_some_object_detector_stuff(images, detector); |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | // ---------------------------------------------------------------------------------------- |
| 655 |
no test coverage detected