| 216 | } |
| 217 | |
| 218 | static Shape AlignMeanShapeToLeftEyeMouth( |
| 219 | const DetectorParameter& detpar, // in |
| 220 | const Shape& meanshape) // in |
| 221 | { |
| 222 | if (trace_g) |
| 223 | lprintf("AlignToLeftEyeMouth "); |
| 224 | |
| 225 | CV_Assert(NSIZE(meanshape) > 0 && PointUsed(meanshape, 0)); |
| 226 | CV_Assert(Valid(detpar.lex)); // left eye valid? |
| 227 | CV_Assert(!Valid(detpar.rex)); // right eye invalid? (else why are we here?) |
| 228 | CV_Assert(Valid(detpar.mouthx)); // mouth valid? |
| 229 | |
| 230 | Shape meanline(2, 2), detline(2, 2); // line from eye to mouth |
| 231 | |
| 232 | const Shape shape17(Shape17(meanshape)); |
| 233 | |
| 234 | const double x_meanmouth = |
| 235 | (shape17(L17_CTopOfTopLip, IX) + shape17(L17_CBotOfBotLip, IX)) / 2; |
| 236 | |
| 237 | const double y_meanmouth = |
| 238 | (shape17(L17_CTopOfTopLip, IY) + shape17(L17_CBotOfBotLip, IY)) / 2; |
| 239 | |
| 240 | meanline(0, IX) = shape17(L17_LPupil, IX); // left eye |
| 241 | meanline(0, IY) = shape17(L17_LPupil, IY); |
| 242 | meanline(1, IX) = x_meanmouth; // mouth |
| 243 | meanline(1, IY) = y_meanmouth; |
| 244 | |
| 245 | detline(0, IX) = detpar.lex; // left eye |
| 246 | detline(0, IY) = detpar.ley; |
| 247 | detline(1, IX) = detpar.mouthx; // mouth |
| 248 | detline(1, IY) = detpar.mouthy; |
| 249 | |
| 250 | return TransformShape(meanshape, AlignmentMat(meanline, detline)); |
| 251 | } |
| 252 | |
| 253 | static Shape AlignMeanShapeToRightEyeMouth( |
| 254 | const DetectorParameter& detpar, // in |
no test coverage detected