Commit 3ebf0f2e authored by Davis King's avatar Davis King

Refined the scan_image_pyramid interface a little. In particular, I split the

get_feature_vector() method into two separate functions so the interface
is a little simpler and more flexible.
parent 578322dc
This diff is collapsed.
...@@ -289,10 +289,22 @@ namespace dlib ...@@ -289,10 +289,22 @@ namespace dlib
been reached). been reached).
!*/ !*/
const rectangle get_best_matching_rect (
const rectangle& rect
) const;
/*!
requires
- is_loaded_with_image() == true
- get_num_detection_templates() > 0
ensures
- Since scan_image_pyramid is a sliding window classifier system, not all possible rectangles
can be represented. Therefore, this function allows you to supply a rectangle and obtain the
nearest possible sliding window rectangle.
!*/
void get_feature_vector ( void get_feature_vector (
const std::vector<rectangle>& rects, const std::vector<rectangle>& rects,
feature_vector_type& psi, feature_vector_type& psi
std::vector<rectangle>& mapped_rects
) const; ) const;
/*! /*!
requires requires
...@@ -305,7 +317,6 @@ namespace dlib ...@@ -305,7 +317,6 @@ namespace dlib
- if (rects was produced by a call to detect(), i.e. rects contains the contents of dets) then - if (rects was produced by a call to detect(), i.e. rects contains the contents of dets) then
- #psi == the sum of feature vectors corresponding to the sliding window locations contained - #psi == the sum of feature vectors corresponding to the sliding window locations contained
in rects. in rects.
- #mapped_rects == rects
- Let w denote the w vector given to detect(), then we have: - Let w denote the w vector given to detect(), then we have:
- dot(w,#psi) == sum of scores of the dets produced by detect() - dot(w,#psi) == sum of scores of the dets produced by detect()
- else - else
...@@ -313,8 +324,8 @@ namespace dlib ...@@ -313,8 +324,8 @@ namespace dlib
be output by detect(). So in the case where rects contains rectangles which could not arise be output by detect(). So in the case where rects contains rectangles which could not arise
from a call to detect(), this function will map the rectangles in rects to the nearest possible from a call to detect(), this function will map the rectangles in rects to the nearest possible
object boxes and then store the sum of feature vectors for the mapped rectangles into #psi. object boxes and then store the sum of feature vectors for the mapped rectangles into #psi.
- for all valid i: #mapped_rects[i] == the rectangle rects[i] gets mapped to for feature extraction. - for all valid i: get_best_matching_rect(rects[i]) == the rectangle rects[i] gets mapped to for
- #mapped_rects.size() == rects.size() feature extraction.
!*/ !*/
}; };
......
...@@ -156,7 +156,11 @@ namespace dlib ...@@ -156,7 +156,11 @@ namespace dlib
scanner.load(images[idx]); scanner.load(images[idx]);
psi.set_size(get_num_dimensions()); psi.set_size(get_num_dimensions());
std::vector<rectangle> mapped_rects; std::vector<rectangle> mapped_rects;
scanner.get_feature_vector(truth_rects[idx], psi, mapped_rects); scanner.get_feature_vector(truth_rects[idx], psi);
for (unsigned long i = 0; i < truth_rects[idx].size(); ++i)
{
mapped_rects.push_back(scanner.get_best_matching_rect(truth_rects[idx][i]));
}
psi(scanner.get_num_dimensions()) = -1.0*truth_rects[idx].size(); psi(scanner.get_num_dimensions()) = -1.0*truth_rects[idx].size();
// check if any of the boxes overlap. If they do then it is impossible for // check if any of the boxes overlap. If they do then it is impossible for
...@@ -328,8 +332,7 @@ namespace dlib ...@@ -328,8 +332,7 @@ namespace dlib
psi.set_size(get_num_dimensions()); psi.set_size(get_num_dimensions());
psi = 0; psi = 0;
std::vector<rectangle> mapped_rects; scanner.get_feature_vector(final_dets, psi);
scanner.get_feature_vector(final_dets, psi, mapped_rects);
psi(scanner.get_num_dimensions()) = -1.0*final_dets.size(); psi(scanner.get_num_dimensions()) = -1.0*final_dets.size();
} }
......
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