Commit 99d5702f authored by Davis King's avatar Davis King

Gave test_object_detection_function() an option to set how ignore box overlap is tested.

parent cb42b8fb
...@@ -19,7 +19,8 @@ namespace dlib ...@@ -19,7 +19,8 @@ namespace dlib
const image_array_type& images, const image_array_type& images,
const std::vector<std::vector<mmod_rect>>& truth_dets, const std::vector<std::vector<mmod_rect>>& truth_dets,
const test_box_overlap& overlap_tester = test_box_overlap(), const test_box_overlap& overlap_tester = test_box_overlap(),
const double adjust_threshold = 0 const double adjust_threshold = 0,
const test_box_overlap& overlaps_ignore_tester = test_box_overlap()
) )
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
...@@ -62,7 +63,7 @@ namespace dlib ...@@ -62,7 +63,7 @@ namespace dlib
for (auto&& b : hits) for (auto&& b : hits)
boxes.push_back(std::make_pair(b.detection_confidence, b.rect)); boxes.push_back(std::make_pair(b.detection_confidence, b.rect));
correct_hits += impl::number_of_truth_hits(truth_boxes, ignore, boxes, overlap_tester, all_dets, missing_detections); correct_hits += impl::number_of_truth_hits(truth_boxes, ignore, boxes, overlap_tester, all_dets, missing_detections, overlaps_ignore_tester);
total_true_targets += truth_boxes.size(); total_true_targets += truth_boxes.size();
} }
......
...@@ -25,7 +25,8 @@ namespace dlib ...@@ -25,7 +25,8 @@ namespace dlib
const std::vector<std::pair<double,rectangle> >& boxes, const std::vector<std::pair<double,rectangle> >& boxes,
const test_box_overlap& overlap_tester, const test_box_overlap& overlap_tester,
std::vector<std::pair<double,bool> >& all_dets, std::vector<std::pair<double,bool> >& all_dets,
unsigned long& missing_detections unsigned long& missing_detections,
const test_box_overlap& overlaps_ignore_tester
) )
/*! /*!
ensures ensures
...@@ -74,7 +75,7 @@ namespace dlib ...@@ -74,7 +75,7 @@ namespace dlib
for (unsigned long i = 0; i < boxes.size(); ++i) for (unsigned long i = 0; i < boxes.size(); ++i)
{ {
// only out put boxes if they match a truth box or are not ignored. // only out put boxes if they match a truth box or are not ignored.
if (used[i] || !overlaps_any_box(overlap_tester, ignore, boxes[i].second)) if (used[i] || !overlaps_any_box(overlaps_ignore_tester, ignore, boxes[i].second))
{ {
all_dets.push_back(std::make_pair(boxes[i].first, used[i])); all_dets.push_back(std::make_pair(boxes[i].first, used[i]));
} }
...@@ -83,6 +84,18 @@ namespace dlib ...@@ -83,6 +84,18 @@ namespace dlib
return count; return count;
} }
inline unsigned long number_of_truth_hits (
const std::vector<full_object_detection>& truth_boxes,
const std::vector<rectangle>& ignore,
const std::vector<std::pair<double,rectangle> >& boxes,
const test_box_overlap& overlap_tester,
std::vector<std::pair<double,bool> >& all_dets,
unsigned long& missing_detections
)
{
return number_of_truth_hits(truth_boxes, ignore, boxes, overlap_tester, all_dets, missing_detections, overlap_tester);
}
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
} }
......
...@@ -142,7 +142,8 @@ namespace dlib ...@@ -142,7 +142,8 @@ namespace dlib
const image_array_type& images, const image_array_type& images,
const std::vector<std::vector<mmod_rect>>& truth_dets, const std::vector<std::vector<mmod_rect>>& truth_dets,
const test_box_overlap& overlap_tester = test_box_overlap(), const test_box_overlap& overlap_tester = test_box_overlap(),
const double adjust_threshold = 0 const double adjust_threshold = 0,
const test_box_overlap& overlaps_ignore_tester = test_box_overlap()
); );
/*! /*!
requires requires
...@@ -159,7 +160,7 @@ namespace dlib ...@@ -159,7 +160,7 @@ namespace dlib
truth_dets[i] that are marked ignore are ignored. That is, detections truth_dets[i] that are marked ignore are ignored. That is, detections
matching an ignore box do not count as a false alarm and similarly if any matching an ignore box do not count as a false alarm and similarly if any
ignored box in truth_dets goes undetected it does not count as a missed ignored box in truth_dets goes undetected it does not count as a missed
detection. detection. To test if a box overlaps an ignore box, we use overlaps_ignore_tester.
- In particular, returns a matrix M such that: - In particular, returns a matrix M such that:
- M(0) == the precision of the detector object. This is a number - M(0) == the precision of the detector object. This is a number
in the range [0,1] which measures the fraction of detector outputs in the range [0,1] which measures the fraction of detector outputs
......
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