AAM_Shape AAMBody::InitShape(const AAM_Shape& pMeanShape) { cv::Size imgSize = imageMessageIn_->GetSize(); AAM_Shape detShape; AAM_Shape startShape; detShape.resize(2); detShape[0].x = param_->boundingBox.x < 0 ? 0 : param_->boundingBox.x; detShape[0].y = param_->boundingBox.y < 0 ? 0 : param_->boundingBox.y; if(detShape[0].x > imgSize.width) detShape[0].x = imgSize.width - param_->boundingBox.width; if(detShape[0].y > imgSize.height) detShape[0].y = imgSize.height - param_->boundingBox.height; detShape[1].x = detShape[0].x + param_->boundingBox.width; detShape[1].y = detShape[0].y + param_->boundingBox.height; if(detShape[1].x > imgSize.width) detShape[1].x = imgSize.width - param_->boundingBox.width; if(detShape[1].y > imgSize.height) detShape[1].y = imgSize.height - param_->boundingBox.height; AdjustShape(detShape); AlignShape(startShape, detShape, pMeanShape); return startShape; }
//============================================================================ void AAM_PDM::CalcMeanShape(AAM_Shape &MeanShape, const std::vector<AAM_Shape> &AllShapes) { MeanShape.resize(AllShapes[0].NPoints()); MeanShape = 0; for(int i = 0; i < (int)AllShapes.size(); i++) MeanShape += AllShapes[i]; MeanShape /= AllShapes.size(); }
static AAM_Shape ShapeAAMFromASM(const asm_shape& shape) { AAM_Shape s; s.resize(shape.NPoints()); for(int i = 0; i < shape.NPoints(); i++) { s[i].x = shape[i].x; s[i].y = shape[i].y; } return s; }
AAM_Shape AAMFit::InitShape( const AAM_Shape& pMeanShape, CvRect *pR, int pType = 0 ) { AAM_Shape detShape; AAM_Shape startShape; detShape.resize(2); detShape[0].x = pR->x; detShape[0].y = pR->y; detShape[1].x = detShape[0].x + pR->width; detShape[1].y = detShape[0].y + pR->height; if( pType == AAM_FIT_FACE ) AdjustFaceShape(detShape); else if( pType == AAM_FIT_MOUTH ) AdjustMouthShape(detShape); AlignShape(startShape, detShape, pMeanShape); return startShape; }