| 31 | typename image_array_type |
| 32 | > |
| 33 | const matrix<double,1,3> test_object_detection_function ( |
| 34 | loss_mmod<SUBNET>& detector, |
| 35 | const image_array_type& images, |
| 36 | const std::vector<std::vector<mmod_rect>>& truth_dets, |
| 37 | const test_box_overlap& overlap_tester = test_box_overlap(), |
| 38 | const double adjust_threshold = 0, |
| 39 | const test_box_overlap& overlaps_ignore_tester = test_box_overlap() |
| 40 | ) |
| 41 | { |
| 42 | // make sure requires clause is not broken |
| 43 | DLIB_CASSERT( is_learning_problem(images,truth_dets) == true , |
| 44 | "\t matrix test_object_detection_function()" |
| 45 | << "\n\t invalid inputs were given to this function" |
| 46 | << "\n\t is_learning_problem(images,truth_dets): " << is_learning_problem(images,truth_dets) |
| 47 | << "\n\t images.size(): " << images.size() |
| 48 | ); |
| 49 | |
| 50 | |
| 51 | |
| 52 | double correct_hits = 0; |
| 53 | double total_true_targets = 0; |
| 54 | |
| 55 | std::vector<std::pair<double,bool> > all_dets; |
| 56 | unsigned long missing_detections = 0; |
| 57 | |
| 58 | resizable_tensor temp; |
| 59 | |
| 60 | for (unsigned long i = 0; i < images.size(); ++i) |
| 61 | { |
| 62 | std::vector<mmod_rect> hits; |
| 63 | detector.to_tensor(&images[i], &images[i]+1, temp); |
| 64 | detector.subnet().forward(temp); |
| 65 | detector.loss_details().to_label(temp, detector.subnet(), &hits, adjust_threshold); |
| 66 | |
| 67 | |
| 68 | for (auto& label : impl::get_labels(truth_dets[i], hits)) |
| 69 | { |
| 70 | std::vector<full_object_detection> truth_boxes; |
| 71 | std::vector<rectangle> ignore; |
| 72 | std::vector<std::pair<double,rectangle>> boxes; |
| 73 | // copy hits and truth_dets into the above three objects |
| 74 | for (auto&& b : truth_dets[i]) |
| 75 | { |
| 76 | if (b.ignore) |
| 77 | { |
| 78 | ignore.push_back(b); |
| 79 | } |
| 80 | else if (b.label == label) |
| 81 | { |
| 82 | truth_boxes.push_back(full_object_detection(b.rect)); |
| 83 | ++total_true_targets; |
| 84 | } |
| 85 | } |
| 86 | for (auto&& b : hits) |
| 87 | { |
| 88 | if (b.label == label) |
| 89 | boxes.push_back(std::make_pair(b.detection_confidence, b.rect)); |
| 90 | } |
no test coverage detected