Commit a41e0cdb authored by Juha Reunanen's avatar Juha Reunanen Committed by Davis E. King
Browse files

Primarily match to truth rects that haven't been hit already (#1897)

parent 1264521e
...@@ -1204,7 +1204,7 @@ namespace dlib ...@@ -1204,7 +1204,7 @@ namespace dlib
const auto& det_label = options.detector_windows[dets[i].tensor_channel].label; const auto& det_label = options.detector_windows[dets[i].tensor_channel].label;
const std::pair<double,unsigned int> hittruth = find_best_match(*truth, dets[i].rect, det_label); const std::pair<double,unsigned int> hittruth = find_best_match(*truth, hit_truth_table, dets[i].rect, det_label);
final_dets.push_back(dets[i].rect); final_dets.push_back(dets[i].rect);
...@@ -1273,7 +1273,7 @@ namespace dlib ...@@ -1273,7 +1273,7 @@ namespace dlib
const auto& det_label = options.detector_windows[dets[i].tensor_channel].label; const auto& det_label = options.detector_windows[dets[i].tensor_channel].label;
const std::pair<double,unsigned int> hittruth = find_best_match(*truth, dets[i].rect, det_label); const std::pair<double,unsigned int> hittruth = find_best_match(*truth, hit_truth_table, dets[i].rect, det_label);
const double truth_match = hittruth.first; const double truth_match = hittruth.first;
if (truth_match > options.truth_match_iou_threshold) if (truth_match > options.truth_match_iou_threshold)
...@@ -1633,16 +1633,22 @@ namespace dlib ...@@ -1633,16 +1633,22 @@ namespace dlib
std::pair<double,unsigned int> find_best_match( std::pair<double,unsigned int> find_best_match(
const std::vector<mmod_rect>& boxes, const std::vector<mmod_rect>& boxes,
const std::vector<bool>& hit_truth_table,
const rectangle& rect, const rectangle& rect,
const std::string& label const std::string& label
) const ) const
{ {
double match = 0; double match = 0;
unsigned int best_idx = 0; unsigned int best_idx = 0;
for (int allow_duplicate_hit = 0; allow_duplicate_hit <= 1 && match == 0; ++allow_duplicate_hit)
{
for (unsigned long i = 0; i < boxes.size(); ++i) for (unsigned long i = 0; i < boxes.size(); ++i)
{ {
if (boxes[i].ignore || boxes[i].label != label) if (boxes[i].ignore || boxes[i].label != label)
continue; continue;
if (!allow_duplicate_hit && hit_truth_table[i])
continue;
const double new_match = box_intersection_over_union(rect, boxes[i]); const double new_match = box_intersection_over_union(rect, boxes[i]);
if (new_match > match) if (new_match > match)
...@@ -1651,6 +1657,7 @@ namespace dlib ...@@ -1651,6 +1657,7 @@ namespace dlib
best_idx = i; best_idx = i;
} }
} }
}
return std::make_pair(match,best_idx); return std::make_pair(match,best_idx);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment