Commit 825ae091 authored by Davis King's avatar Davis King

merged

parents f1c734d6 c42fdead
......@@ -59,7 +59,9 @@ namespace dlib
for (long r = 0; r < v.nr(); ++r)
{
spec_samps.push_back(trans(rowm(v,r)));
spec_samps.back() /= length(spec_samps.back());
const double len = length(spec_samps.back());
if (len != 0)
spec_samps.back() /= len;
}
// Finally do the K-means clustering
pick_initial_centers(num_clusters, centers, spec_samps);
......
......@@ -341,7 +341,7 @@ namespace dlib
boxes_overlap(overlap_tester)
{
// make sure requires clause is not broken
DLIB_ASSERT(scanner_.get_num_detection_templates() > 0 && w_.size() > 0,
DLIB_CASSERT(scanner_.get_num_detection_templates() > 0 && w_.size() > 0,
"\t object_detector::object_detector(scanner_,overlap_tester,w_)"
<< "\n\t Invalid inputs were given to this function "
<< "\n\t scanner_.get_num_detection_templates(): " << scanner_.get_num_detection_templates()
......@@ -349,10 +349,9 @@ namespace dlib
<< "\n\t this: " << this
);
#ifdef ENABLE_ASSERTS
for (unsigned long i = 0; i < w_.size(); ++i)
{
DLIB_ASSERT(w_[i].size() == scanner_.get_num_dimensions() + 1,
DLIB_CASSERT(w_[i].size() == scanner_.get_num_dimensions() + 1,
"\t object_detector::object_detector(scanner_,overlap_tester,w_)"
<< "\n\t Invalid inputs were given to this function "
<< "\n\t scanner_.get_num_detection_templates(): " << scanner_.get_num_detection_templates()
......@@ -361,7 +360,6 @@ namespace dlib
<< "\n\t this: " << this
);
}
#endif
scanner.copy_configuration(scanner_);
w.resize(w_.size());
......@@ -382,7 +380,7 @@ namespace dlib
const std::vector<object_detector>& detectors
)
{
DLIB_ASSERT(detectors.size() != 0,
DLIB_CASSERT(detectors.size() != 0,
"\t object_detector::object_detector(detectors)"
<< "\n\t Invalid inputs were given to this function "
<< "\n\t this: " << this
......
This diff is collapsed.
......@@ -42,6 +42,7 @@ namespace dlib
/*!
ensures
- #num_parts() == 0
- #num_features() == 0
!*/
unsigned long num_parts (
......@@ -51,15 +52,27 @@ namespace dlib
- returns the number of parts in the shapes predicted by this object.
!*/
template <typename image_type>
unsigned long num_features (
) const;
/*!
ensures
- Returns the dimensionality of the feature vector output by operator().
This number is the total number of trees in this object times the number
of leaves on each tree.
!*/
template <typename image_type, typename T, typename U>
full_object_detection operator()(
const image_type& img,
const rectangle& rect
const rectangle& rect,
std::vector<std::pair<T,U> >& feats
) const;
/*!
requires
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
- T is some unsigned integral type (e.g. unsigned int).
- U is any scalar type capable of storing the value 1 (e.g. float).
ensures
- Runs the shape prediction algorithm on the part of the image contained in
the given bounding rectangle. So it will try and fit the shape model to
......@@ -73,6 +86,29 @@ namespace dlib
- for all valid i:
- DET.part(i) == the location in img for the i-th part of the shape
predicted by this object.
- #feats == a sparse vector that records which leaf each tree used to make
the shape prediction. Moreover, it is an indicator vector, Therefore,
for all valid i:
- #feats[i].second == 1
Further, #feats is a vector from the space of num_features() dimensional
vectors. The output shape positions can be represented as the dot
product between #feats and a weight vector. Therefore, #feats encodes
all the information from img that was used to predict the returned shape
object.
!*/
template <typename image_type>
full_object_detection operator()(
const image_type& img,
const rectangle& rect
) const;
/*!
requires
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
ensures
- Calling this function is equivalent to calling (*this)(img, rect, ignored)
where the 3d argument is discarded.
!*/
};
......@@ -359,6 +395,9 @@ namespace dlib
- images.size() > 0
- for some i: objects[i].size() != 0
(i.e. there has to be at least one full_object_detection in the training set)
- for all valid p, there must exist i and j such that:
objects[i][j].part(p) != OBJECT_PART_NOT_PRESENT.
(i.e. You can't define a part that is always set to OBJECT_PART_NOT_PRESENT.)
- for all valid i,j,k,l:
- objects[i][j].num_parts() == objects[k][l].num_parts()
(i.e. all objects must agree on the number of parts)
......@@ -370,6 +409,10 @@ namespace dlib
shape_predictor, SP, such that:
SP(images[i], objects[i][j].get_rect()) == objects[i][j]
This learned SP object is then returned.
- Not all parts are required to be observed for all objects. So if you
have training instances with missing parts then set the part positions
equal to OBJECT_PART_NOT_PRESENT and this algorithm will basically ignore
those missing parts.
!*/
};
......@@ -408,6 +451,8 @@ namespace dlib
and compare the result with the truth part positions in objects[i][j]. We
then return the average distance (measured in pixels) between a predicted
part location and its true position.
- Note that any parts in objects that are set to OBJECT_PART_NOT_PRESENT are
simply ignored.
- if (scales.size() != 0) then
- Each time we compute the distance between a predicted part location and
its true location in objects[i][j] we divide the distance by
......
......@@ -288,7 +288,7 @@ namespace dlib
struct dlib_pick_initial_centers_data
{
dlib_pick_initial_centers_data():idx(0), dist(1e200){}
dlib_pick_initial_centers_data():idx(0), dist(std::numeric_limits<double>::infinity()){}
long idx;
double dist;
bool operator< (const dlib_pick_initial_centers_data& d) const { return dist < d.dist; }
......@@ -331,7 +331,7 @@ namespace dlib
// pick the first sample as one of the centers
centers.push_back(samples[0]);
const long best_idx = static_cast<long>(samples.size() - samples.size()*percentile - 1);
const long best_idx = static_cast<long>(std::max(0.0,samples.size() - samples.size()*percentile - 1));
// pick the next center
for (long i = 0; i < num_centers-1; ++i)
......
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