static Shape EstartEyes( const DetPar& detpar_roi, // in: detpar wrt the ROI const Image& face_roi, // in const Shape& meanshape) // in { Shape startshape; Shape meanshape1(meanshape); if (Valid(detpar_roi.lex) && Valid(detpar_roi.rex)) // both eyes available? { FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols); // TODO Tune the following code, what approach is best? if (detpar_roi.eyaw == EYAW00) startshape = AlignMeanShapeToBothEyesEstMouth(detpar_roi, meanshape1); else startshape = AlignMeanShapeToBothEyesNoMouth(detpar_roi, meanshape1); FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols); } else // at least one eye is missing, use the face det rectangle { startshape = AlignMeanShapeToFaceDet(detpar_roi, meanshape1, FACERECT_SCALE_WHEN_NO_EYES, face_roi); } return startshape; }
static Shape StartShapeFromDetPar( const DetPar& detpar_roi, // in: detpar wrt the ROI const Image& face_roi, // in const Shape& meanshape, // in ESTART estart) // in: use mouth etc. to posn start shape? { CV_Assert(estart == ESTART_RECT_ONLY || estart == ESTART_EYES || estart == ESTART_EYE_AND_MOUTH); Shape startshape; Shape meanshape1(meanshape); if (estart == ESTART_EYE_AND_MOUTH && // use both eyes and mouth? Valid(detpar_roi.mouthx) && Valid(detpar_roi.lex) && Valid(detpar_roi.rex)) { FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols); startshape = AlignMeanShapeToBothEyesAndMouth(detpar_roi, meanshape1); FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols); } else if (Valid(detpar_roi.lex) && // use both eyes? Valid(detpar_roi.rex)) { FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols); // TODO Tune the following code, what approach is best? if (detpar_roi.eyaw == EYAW00) startshape = AlignMeanShapeToBothEyesEstMouth(detpar_roi, meanshape1); else startshape = AlignMeanShapeToBothEyesNoMouth(detpar_roi, meanshape1); FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols); } else if (estart == ESTART_EYE_AND_MOUTH && // use left eye and mouth? Valid(detpar_roi.mouthx) && Valid(detpar_roi.lex)) { FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols); startshape = AlignMeanShapeToLeftEyeAndMouth(detpar_roi, meanshape1); FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols); } else if (estart == ESTART_EYE_AND_MOUTH && // use right eye and mouth? Valid(detpar_roi.mouthx) && Valid(detpar_roi.rex)) { FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols); startshape = AlignMeanShapeToRightEyeAndMouth(detpar_roi, meanshape1); FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols); } else // last resort: use the face det rectangle (can't use facial features) { startshape = AlignMeanShapeToFaceDetRect(detpar_roi, meanshape1, FACERECT_SCALE_WHEN_NO_EYES, face_roi); } return JitterPointsAt00(startshape); }
static Shape EstartEyeMouth( const DetPar& detpar_roi, // in: detpar wrt the ROI const Image& face_roi, // in const Shape& meanshape) // in { Shape startshape; Shape meanshape1(meanshape); if (Valid(detpar_roi.mouthx) && // both eyes and mouth? Valid(detpar_roi.lex) && Valid(detpar_roi.rex)) { FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols); startshape = AlignMeanShapeToBothEyesMouth(detpar_roi, meanshape1); FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols); } else if (Valid(detpar_roi.lex) && // both eyes? Valid(detpar_roi.rex)) { FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols); // TODO Tune the following code, what approach is best? if (detpar_roi.eyaw == EYAW00) startshape = AlignMeanShapeToBothEyesEstMouth(detpar_roi, meanshape1); else startshape = AlignMeanShapeToBothEyesNoMouth(detpar_roi, meanshape1); FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols); } else if (Valid(detpar_roi.mouthx) && // left eye and mouth? Valid(detpar_roi.lex)) { FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols); startshape = AlignMeanShapeToLeftEyeMouth(detpar_roi, meanshape1); FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols); } else if (Valid(detpar_roi.mouthx) && // right eye and mouth? Valid(detpar_roi.rex)) { FlipIfLeftFacing(meanshape1, detpar_roi.eyaw, face_roi.cols); startshape = AlignMeanShapeToRightEyeMouth(detpar_roi, meanshape1); FlipIfLeftFacing(startshape, detpar_roi.eyaw, face_roi.cols); } else // last resort: use the face det rectangle (can't use facial features) { startshape = AlignMeanShapeToFaceDet(detpar_roi, meanshape1, FACERECT_SCALE_WHEN_NO_EYES, face_roi); } return startshape; }