Commit 5da76449 authored by Davis King's avatar Davis King

Added another constructor to object_detector that makes it easy to combine

multiple detectors together.
parent d62fac0d
...@@ -73,6 +73,10 @@ namespace dlib ...@@ -73,6 +73,10 @@ namespace dlib
const std::vector<feature_vector_type>& w_ const std::vector<feature_vector_type>& w_
); );
explicit object_detector (
const std::vector<object_detector>& detectors
);
unsigned long num_detectors ( unsigned long num_detectors (
) const { return w.size(); } ) const { return w.size(); }
...@@ -356,6 +360,32 @@ namespace dlib ...@@ -356,6 +360,32 @@ namespace dlib
} }
} }
// ----------------------------------------------------------------------------------------
template <
typename image_scanner_type
>
object_detector<image_scanner_type>::
object_detector (
const std::vector<object_detector>& detectors
)
{
DLIB_ASSERT(detectors.size() != 0,
"\t object_detector::object_detector(detectors)"
<< "\n\t Invalid inputs were given to this function "
<< "\n\t this: " << this
);
std::vector<feature_vector_type> weights;
weights.reserve(detectors.size());
for (unsigned long i = 0; i < detectors.size(); ++i)
{
for (unsigned long j = 0; j < detectors[i].num_detectors(); ++j)
weights.push_back(detectors[i].get_w(j));
}
*this = object_detector(detectors[0].get_scanner(), detectors[0].get_overlap_tester(), weights);
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
......
...@@ -110,13 +110,13 @@ namespace dlib ...@@ -110,13 +110,13 @@ namespace dlib
- w.size() > 0 - w.size() > 0
ensures ensures
- When the operator() member function is called it will invoke - When the operator() member function is called it will invoke
scanner.detect(w[i],dets,w[i](w[i].size()-1)) for all valid i. Then it get_scanner().detect(w[i],dets,w[i](w[i].size()-1)) for all valid i. Then it
will take all the detections output by the calls to detect() and suppress will take all the detections output by the calls to detect() and suppress
overlapping detections, and finally report the results. overlapping detections, and finally report the results.
- when #*this is used to detect objects, the set of output detections will - when #*this is used to detect objects, the set of output detections will
never contain any overlaps with respect to overlap_tester. That is, for never contain any overlaps with respect to overlap_tester. That is, for
all pairs of returned detections A and B, we will always have: all pairs of returned detections A and B, we will always have:
overlap_tester(A,B) == false overlap_tester(A,B) == false
- for all valid i: - for all valid i:
- #get_w(i) == w[i] - #get_w(i) == w[i]
- #num_detectors() == w.size() - #num_detectors() == w.size()
...@@ -126,6 +126,34 @@ namespace dlib ...@@ -126,6 +126,34 @@ namespace dlib
I.e. the copy is done using copy_configuration()) I.e. the copy is done using copy_configuration())
!*/ !*/
explicit object_detector (
const std::vector<object_detector>& detectors
);
/*!
requires
- detectors.size() != 0
- All the detectors must use compatibly configured scanners. That is, it
must make sense for the weight vector from one detector to be used with
the scanner from any other.
- for all valid i:
- detectors[i].get_scanner().get_num_dimensions() == detectors[0].get_scanner().get_num_dimensions()
(i.e. all the detectors use scanners that use the same kind of feature vectors.)
ensures
- Very much like the above constructor, this constructor takes all the
given detectors and packs them into #*this. That is, invoking operator()
on #*this will run all the detectors, perform non-max suppression, and
then report the results.
- When #*this is used to detect objects, the set of output detections will
never contain any overlaps with respect to overlap_tester. That is, for
all pairs of returned detections A and B, we will always have:
overlap_tester(A,B) == false
- #num_detectors() == The sum of detectors[i].num_detectors() for all valid i.
- #get_overlap_tester() == detectors[0].get_overlap_tester()
- #get_scanner() == detectors[0].get_scanner()
(note that only the "configuration" of scanner is copied. I.e. the copy
is done using copy_configuration())
!*/
unsigned long num_detectors ( unsigned long num_detectors (
) const; ) const;
/*! /*!
......
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