Ejemplo n.º 1
0
void VO_FittingAAMInverseIA::VO_PParamQParam2FittingShape(  const Mat_<float>& p,
                                                            const Mat_<float>& q,
                                                            VO_Shape& oShape,
                                                            float& scale,
                                                            vector<float>& rotateAngles,
                                                            Mat_<float>& matCOG,
                                                            unsigned int mtd)
{
    switch(mtd)
    {
    case VO_Fitting2DSM::USEGLOBALSHAPENORMALIZATION:
        {
            this->VO_PParamQParam2ModelAlignedShape(p, q, this->m_VOModelAlignedShape);
            VO_Shape::GlobalShapeNormalization2D(this->m_VOModelAlignedShape, oShape, scale, -rotateAngles, matCOG);
        }
        break;
    case VO_Fitting2DSM::USESIMILARITYTRANSFORM:
    default:
        {
            this->m_VOAAMInverseIA->VO_SParamBackProjectToAlignedShape(p, this->m_VOModelAlignedShape);
            float updatescale = 1.0;
            vector<float> updateangles(1);
            Mat_<float> updatetranslation = Mat_<float>::zeros(2, 1);
            VO_Shape::GlobalShapeNormalization2SimilarityTrans(q, updatescale, updateangles, updatetranslation );
            scale *= updatescale;
            rotateAngles[0] = -rotateAngles[0]+updateangles[0];
            matCOG(0,0) += updatetranslation(0,0);
            matCOG(1,0) += updatetranslation(1,0);

            // shape adjustment by t parameters - pose transform
            VO_Shape::GlobalShapeNormalization2D(this->m_VOModelAlignedShape, oShape, scale, rotateAngles, matCOG);
        }
        break;
    }
}
Ejemplo n.º 2
0
/**
 * @author	JIA Pei
 * @version	2010-05-14
 * @brief	obtain the reconstructed real-size shape using c parameters and t parameters
 * @param	c      					Input -- PCA appearance parameters, including both shape non-rigid variance + texture variance
 * @param   t       				Input -- parameters required for global shape normalization, rigid variance, refer to "AAM Revisited equation (42)"
 * @param	modelAlignedShape		Output -- the modeled aligned shape
 * @param	modelNormalizedTexture	Output -- the modeled normalized texture
 * @param	oShape					Output -- output shape after global shape normalization. Please make sure global shape normalization is not Procrustes Analysis.
 * @param	scale					Input and Output -- scaling
 * @param	rotateAngles			Input and Output -- rotation
 * @param	matCOG					Input and Output -- translation
 */
void VO_FittingAAMBasic::VO_CParamTParam2FittingShape(	const Mat_<float>& c,
														const Mat_<float>& t,
														VO_Texture& modelNormalizedTexture,
														VO_Shape& oShape,
														float& scale,
														vector<float>& rotateAngles,
														Mat_<float>& matCOG,
														unsigned int mtd)
{
   // generate shape and texture from C parameters
    this->m_VOAAMBasic->VO_CParamBackProjectToSParamTParam(c, this->m_MatModelAlignedShapeParam, this->m_MatModelNormalizedTextureParam);
    this->m_VOAAMBasic->VO_SParamBackProjectToAlignedShape(this->m_MatModelAlignedShapeParam, this->m_VOModelAlignedShape);
    this->m_VOAAMBasic->VO_TParamBackProjectToNormalizedTexture(this->m_MatModelNormalizedTextureParam,  modelNormalizedTexture, this->m_VOAAMBasic->GetNbOfChannels() );
    //this->VO_CParamBackProjectToAlignedShape(c, this->m_MatModeledAlignedShapeInstance);
    //this->VO_CParamBackProjectToNormalizedTexture(c, this->m_MatModeledNormalizedTextureInstance);

	switch(mtd)
	{
	case VO_Fitting2DSM::USEGLOBALSHAPENORMALIZATION:
		{

		}
		break;
	case VO_Fitting2DSM::USESIMILARITYTRANSFORM:
	default:
		{
			float updatescale = 1.0;
			vector<float> updateangles(1);
			Mat_<float> updatetranslation = Mat_<float>::zeros(2, 1);
			VO_Shape::GlobalShapeNormalization2SimilarityTrans(t, updatescale, updateangles, updatetranslation );
			scale *= updatescale;
			rotateAngles[0] = -rotateAngles[0]+updateangles[0];
			matCOG(0,0) += updatetranslation(0,0);
			matCOG(1,0) += updatetranslation(1,0);

			// shape adjustment by t parameters - pose transform
			VO_Shape::GlobalShapeNormalization2D(this->m_VOModelAlignedShape, oShape, scale, rotateAngles, matCOG);
		}
		break;
	}
}