| 226 | } |
| 227 | |
| 228 | Shape Mod::ModSearch_( // returns coords of the facial landmarks |
| 229 | const Shape& startshape, // in: startshape roughly positioned on face |
| 230 | const Image& img, // in: grayscale image (typically just ROI) |
| 231 | const Shape* pinnedshape) // in: pinned landmarks, NULL if nothing pinned |
| 232 | const |
| 233 | { |
| 234 | Image scaledimg; // image scaled to fixed eye-mouth distance |
| 235 | const double imgscale = GetPrescale(startshape); |
| 236 | |
| 237 | // TODO This resize is quite slow (cv::INTER_NEAREST is even slower, why?). |
| 238 | cv::resize(img, scaledimg, |
| 239 | cv::Size(), imgscale, imgscale, cv::INTER_LINEAR); |
| 240 | |
| 241 | TraceShape(startshape * imgscale, scaledimg, 0, -1, "start"); |
| 242 | |
| 243 | vector<Image> pyr; // image pyramid (a vec of images, one for each pyr lev) |
| 244 | CreatePyr(pyr, scaledimg, N_PYR_LEVS); |
| 245 | |
| 246 | Shape shape(startshape * imgscale * GetPyrScale(N_PYR_LEVS)); |
| 247 | |
| 248 | Shape pinned; // pinnedshape scaled to current pyr lev |
| 249 | if (pinnedshape) |
| 250 | pinned = *pinnedshape * imgscale * GetPyrScale(N_PYR_LEVS); |
| 251 | |
| 252 | for (int ilev = N_PYR_LEVS-1; ilev >= 0; ilev--) |
| 253 | { |
| 254 | shape *= PYR_RATIO; // scale shape to this pyr lev |
| 255 | pinned *= PYR_RATIO; |
| 256 | |
| 257 | LevSearch_(shape, |
| 258 | ilev, pyr[ilev], pinned); |
| 259 | } |
| 260 | return shape / imgscale; |
| 261 | } |
| 262 | |
| 263 | } // namespace stasm |
no test coverage detected