| 60 | // ---------------------------------------------------------------------------------------- |
| 61 | |
| 62 | class test_box_overlap |
| 63 | { |
| 64 | public: |
| 65 | test_box_overlap ( |
| 66 | ) : iou_thresh(0.5), percent_covered_thresh(1.0) |
| 67 | {} |
| 68 | |
| 69 | explicit test_box_overlap ( |
| 70 | double iou_thresh_, |
| 71 | double percent_covered_thresh_ = 1.0 |
| 72 | ) : iou_thresh(iou_thresh_), percent_covered_thresh(percent_covered_thresh_) |
| 73 | { |
| 74 | // make sure requires clause is not broken |
| 75 | DLIB_ASSERT(0 <= iou_thresh && iou_thresh <= 1 && |
| 76 | 0 <= percent_covered_thresh && percent_covered_thresh <= 1, |
| 77 | "\t test_box_overlap::test_box_overlap(iou_thresh, percent_covered_thresh)" |
| 78 | << "\n\t Invalid inputs were given to this function " |
| 79 | << "\n\t iou_thresh: " << iou_thresh |
| 80 | << "\n\t percent_covered_thresh: " << percent_covered_thresh |
| 81 | << "\n\t this: " << this |
| 82 | ); |
| 83 | |
| 84 | } |
| 85 | |
| 86 | bool operator() ( |
| 87 | const dlib::rectangle& a, |
| 88 | const dlib::rectangle& b |
| 89 | ) const |
| 90 | { |
| 91 | const double inner = a.intersect(b).area(); |
| 92 | if (inner == 0) |
| 93 | return false; |
| 94 | |
| 95 | const double outer = (a+b).area(); |
| 96 | if (inner/outer > iou_thresh || |
| 97 | inner/a.area() > percent_covered_thresh || |
| 98 | inner/b.area() > percent_covered_thresh) |
| 99 | return true; |
| 100 | else |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | double get_percent_covered_thresh ( |
| 105 | ) const |
| 106 | { |
| 107 | return percent_covered_thresh; |
| 108 | } |
| 109 | |
| 110 | double get_iou_thresh ( |
| 111 | ) const |
| 112 | { |
| 113 | return iou_thresh; |
| 114 | } |
| 115 | |
| 116 | private: |
| 117 | double iou_thresh; |
| 118 | double percent_covered_thresh; |
| 119 | }; |
no outgoing calls