| 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 |
no test coverage detected