MCPcopy Create free account
hub / github.com/davisking/dlib / nearest_shape_point

Function nearest_shape_point

dlib/image_processing/shape_predictor.h:122–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120 // ------------------------------------------------------------------------------------
121
122 inline unsigned long nearest_shape_point (
123 const matrix<float,0,1>& shape,
124 const dlib::vector<float,2>& pt
125 )
126 {
127 // find the nearest part of the shape to this pixel
128 float best_dist = std::numeric_limits<float>::infinity();
129 const unsigned long num_shape_parts = shape.size()/2;
130 unsigned long best_idx = 0;
131 for (unsigned long j = 0; j < num_shape_parts; ++j)
132 {
133 const float dist = length_squared(location(shape,j)-pt);
134 if (dist < best_dist)
135 {
136 best_dist = dist;
137 best_idx = j;
138 }
139 }
140 return best_idx;
141 }
142
143 // ------------------------------------------------------------------------------------
144

Callers 1

Calls 3

locationFunction · 0.85
length_squaredFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected