Changed the evaluate_detectors() routine so that it applies non-max suppression

to each detector individually.  This way one detector doesn't stomp on the
output of another detector.
This commit is contained in:
Davis King 2014-08-13 19:06:26 -04:00
parent cd71dab3f2
commit e1887a24f7
3 changed files with 18 additions and 5 deletions

View File

@ -814,7 +814,9 @@ namespace dlib
{
for (unsigned long i = 0; i < rects.size(); ++i)
{
if (tester(rects[i].rect, rect.rect))
// Only compare detections from the same detector. That is, we don't want
// the output of one detector to stop on the output of another detector.
if (rects[i].weight_index == rect.weight_index && tester(rects[i].rect, rect.rect))
return true;
}
return false;

View File

@ -723,8 +723,9 @@ namespace dlib
the same cell_size parameter that determines how HOG features are computed.
If different cell_size values are used then this function will not be any
faster than running the detectors individually.
- This function applies non-max suppression to the outputs from all detectors
and therefore none of the outputs will overlap with each other.
- This function applies non-max suppression individually to the output of each
detector. Therefore, the output is the same as if you ran each detector
individually and then concatenated the results.
- To be precise, this function performs object detection on the given image and
stores the detected objects into #dets. In particular, we will have that:
- #dets is sorted such that the highest confidence detections come first.

View File

@ -11,6 +11,7 @@
#include <dlib/pixel.h>
#include <dlib/svm_threaded.h>
#include <dlib/array.h>
#include <dlib/set_utils.h>
#include <dlib/array2d.h>
#include <dlib/image_keypoint.h>
#include <dlib/image_processing.h>
@ -414,11 +415,20 @@ namespace
std::vector<rectangle> dets1 = evaluate_detectors(detectors, images[0]);
std::vector<rectangle> dets2 = detector(images[0]);
DLIB_TEST(dets1.size() > 0);
DLIB_TEST(dets2.size() == dets1.size());
DLIB_TEST(dets2.size()*3 == dets1.size());
dlib::set<rectangle>::kernel_1a_c d1, d2;
for (unsigned long i = 0; i < dets1.size(); ++i)
{
DLIB_TEST(dets1[i] == dets2[i]);
if (!d1.is_member(dets1[i]))
d1.add(dets1[i]);
}
for (unsigned long i = 0; i < dets2.size(); ++i)
{
if (!d2.is_member(dets2[i]))
d2.add(dets2[i]);
}
DLIB_TEST(d1.size() == d2.size());
DLIB_TEST(set_intersection_size(d1,d2) == d1.size());
}
}