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

Function ignore_some_truth_boxes

examples/dnn_instance_segmentation_train_ex.cpp:613–648  ·  view source on GitHub ↗

Ignore truth boxes that overlap too much, are too small, or have a large aspect ratio.

Source from the content-addressed store, hash-verified

611
612// Ignore truth boxes that overlap too much, are too small, or have a large aspect ratio.
613void 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
651std::vector<truth_image> filter_images_with_no_truth(const std::vector<truth_image>& truth_images)

Callers 1

mainFunction · 0.85

Calls 4

ignore_overlapped_boxesFunction · 0.70
test_box_overlapClass · 0.50
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected