Ignore truth boxes that overlap too much, are too small, or have a large aspect ratio.
| 611 | |
| 612 | // Ignore truth boxes that overlap too much, are too small, or have a large aspect ratio. |
| 613 | void ignore_some_truth_boxes(std::vector<truth_image>& truth_images) |
| 614 | { |
| 615 | for (auto& i : truth_images) |
| 616 | { |
| 617 | auto& truth_instances = i.truth_instances; |
| 618 | |
| 619 | ignore_overlapped_boxes(truth_instances, test_box_overlap(0.90, 0.95)); |
| 620 | |
| 621 | for (auto& truth : truth_instances) |
| 622 | { |
| 623 | if (truth.mmod_rect.ignore) |
| 624 | continue; |
| 625 | |
| 626 | const auto& rect = truth.mmod_rect.rect; |
| 627 | |
| 628 | constexpr unsigned long min_width = 35; |
| 629 | constexpr unsigned long min_height = 35; |
| 630 | if (rect.width() < min_width && rect.height() < min_height) |
| 631 | { |
| 632 | truth.mmod_rect.ignore = true; |
| 633 | continue; |
| 634 | } |
| 635 | |
| 636 | constexpr double max_aspect_ratio_width_to_height = 3.0; |
| 637 | constexpr double max_aspect_ratio_height_to_width = 1.5; |
| 638 | const double aspect_ratio_width_to_height = rect.width() / static_cast<double>(rect.height()); |
| 639 | const double aspect_ratio_height_to_width = 1.0 / aspect_ratio_width_to_height; |
| 640 | const bool is_aspect_ratio_too_large |
| 641 | = aspect_ratio_width_to_height > max_aspect_ratio_width_to_height |
| 642 | || aspect_ratio_height_to_width > max_aspect_ratio_height_to_width; |
| 643 | |
| 644 | if (is_aspect_ratio_too_large) |
| 645 | truth.mmod_rect.ignore = true; |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | // Filter images that have no (non-ignored) truth |
| 651 | std::vector<truth_image> filter_images_with_no_truth(const std::vector<truth_image>& truth_images) |
no test coverage detected