Commit 77f6c9f2 authored by Davis King's avatar Davis King

Made num_separable_filters() work with multi-filter object detectors.

parent d02e6472
...@@ -874,8 +874,8 @@ namespace dlib ...@@ -874,8 +874,8 @@ namespace dlib
DLIB_ASSERT(weight_index < detector.num_detectors(), DLIB_ASSERT(weight_index < detector.num_detectors(),
"\t matrix draw_fhog()" "\t matrix draw_fhog()"
<< "\n\t Invalid arguments were given to this function. " << "\n\t Invalid arguments were given to this function. "
<< "\n\t cell_draw_size: " << cell_draw_size << "\n\t weight_index: " << weight_index
<< "\n\t detector.num_detectors(): " << detector.num_detectors() << "\n\t detector.num_detectors(): " << detector.num_detectors()
); );
DLIB_ASSERT(cell_draw_size > 0 && detector.get_w(weight_index).size() >= detector.get_scanner().get_num_dimensions(), DLIB_ASSERT(cell_draw_size > 0 && detector.get_w(weight_index).size() >= detector.get_scanner().get_num_dimensions(),
"\t matrix draw_fhog()" "\t matrix draw_fhog()"
...@@ -896,18 +896,25 @@ namespace dlib ...@@ -896,18 +896,25 @@ namespace dlib
typename Pyramid_type typename Pyramid_type
> >
unsigned long num_separable_filters ( unsigned long num_separable_filters (
const object_detector<scan_fhog_pyramid<Pyramid_type> >& detector const object_detector<scan_fhog_pyramid<Pyramid_type> >& detector,
const unsigned long weight_index = 0
) )
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
DLIB_ASSERT(detector.get_w().size() >= detector.get_scanner().get_num_dimensions() , DLIB_ASSERT(weight_index < detector.num_detectors(),
"\t unsigned long num_separable_filters()"
<< "\n\t Invalid arguments were given to this function. "
<< "\n\t weight_index: " << weight_index
<< "\n\t detector.num_detectors(): " << detector.num_detectors()
);
DLIB_ASSERT(detector.get_w(weight_index).size() >= detector.get_scanner().get_num_dimensions() ,
"\t unsigned long num_separable_filters()" "\t unsigned long num_separable_filters()"
<< "\n\t Invalid arguments were given to this function. " << "\n\t Invalid arguments were given to this function. "
<< "\n\t detector.get_w().size(): " << detector.get_w().size() << "\n\t detector.get_w(weight_index).size(): " << detector.get_w(weight_index).size()
<< "\n\t detector.get_scanner().get_num_dimensions(): " << detector.get_scanner().get_num_dimensions() << "\n\t detector.get_scanner().get_num_dimensions(): " << detector.get_scanner().get_num_dimensions()
); );
typename scan_fhog_pyramid<Pyramid_type>::fhog_filterbank fb = detector.get_scanner().build_fhog_filterbank(detector.get_w()); typename scan_fhog_pyramid<Pyramid_type>::fhog_filterbank fb = detector.get_scanner().build_fhog_filterbank(detector.get_w(weight_index));
return fb.num_separable_filters(); return fb.num_separable_filters();
} }
......
...@@ -24,7 +24,7 @@ namespace dlib ...@@ -24,7 +24,7 @@ namespace dlib
requires requires
- cell_draw_size > 0 - cell_draw_size > 0
- weight_index < detector.num_detectors() - weight_index < detector.num_detectors()
- detector.get_w().size() >= detector.get_scanner().get_num_dimensions() - detector.get_w(weight_index).size() >= detector.get_scanner().get_num_dimensions()
(i.e. the detector must have been populated with a HOG filter) (i.e. the detector must have been populated with a HOG filter)
ensures ensures
- Converts the HOG filters in the given detector (specifically, the filters in - Converts the HOG filters in the given detector (specifically, the filters in
...@@ -40,15 +40,18 @@ namespace dlib ...@@ -40,15 +40,18 @@ namespace dlib
typename Pyramid_type typename Pyramid_type
> >
unsigned long num_separable_filters ( unsigned long num_separable_filters (
const object_detector<scan_fhog_pyramid<Pyramid_type> >& detector const object_detector<scan_fhog_pyramid<Pyramid_type> >& detector,
const unsigned long weight_index = 0
); );
/*! /*!
requires requires
- detector.get_w().size() >= detector.get_scanner().get_num_dimensions() - weight_index < detector.num_detectors()
- detector.get_w(weight_index).size() >= detector.get_scanner().get_num_dimensions()
(i.e. the detector must have been populated with a HOG filter) (i.e. the detector must have been populated with a HOG filter)
ensures ensures
- Returns the number of separable filters necessary to represent the HOG - Returns the number of separable filters necessary to represent the HOG
filters in the given detector. filters in the given detector's weight_index'th filter. This is the filter
defined by detector.get_w(weight_index).
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
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