当前位置: 首页>>代码示例>>C++>>正文


C++ AAM_Shape::AlignTo方法代码示例

本文整理汇总了C++中AAM_Shape::AlignTo方法的典型用法代码示例。如果您正苦于以下问题:C++ AAM_Shape::AlignTo方法的具体用法?C++ AAM_Shape::AlignTo怎么用?C++ AAM_Shape::AlignTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AAM_Shape的用法示例。


在下文中一共展示了AAM_Shape::AlignTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: predict

IplImage* FacePredict::predict(const AAM_Shape& Shape, const IplImage& curImage,
					const AAM_Shape& ShapeF, const IplImage& ImageF, double RatioF,
					const AAM_Shape& ShapeM, const IplImage& ImageM, double RatioM,
					int curAgeG, int newAgeG, bool save)
{
	if (newAgeG > NGROUPS || curAgeG > NGROUPS)
	{
		fprintf(stderr, "ERROE(%s, %d): Age group larger than %d\n",
			__FILE__, __LINE__, NGROUPS);
		exit(0);
	}

	if(curImage.nChannels != 3 || curImage.depth != 8)
	{
		fprintf(stderr, "ERROR(%s: %d): The image channels must be 3, "
			"and the depth must be 8!\n", __FILE__, __LINE__);
		exit(0);
	}


	/*get the current shape parameters*/
	AAM_Shape curShape = Shape;
	curShape.Centralize();
	double thisfacewidth = curShape.GetWidth();
	if(stdwidth < thisfacewidth) 
		curShape.Scale(stdwidth / thisfacewidth);
	curShape.AlignTo(__AAMRefShape);
	
	CvMat* p = cvCreateMat(1, __nShapeModes, CV_64FC1);
	CvMat* pq = cvCreateMat(1, 4+__nShapeModes, CV_64FC1);
	__shape.CalcParams(curShape, pq);
	cvGetCols(pq, p, 4, 4+__nShapeModes);

	/*get the current texture parameters*/
	CvMat* curTexture = cvCreateMat(1, __paw.nPix() * 3, CV_64FC1);
	__paw.FasterGetWarpTextureFromShape(Shape, &curImage, curTexture, false);
	__texture.AlignTextureToRef(__MeanT, curTexture);
	CvMat* lamda = cvCreateMat(1, __nTextureModes, CV_64FC1);
	__texture.CalcParams(curTexture, lamda);


	//father
	CvMat* pF = cvCreateMat(1, __nShapeModes, CV_64FC1);
	CvMat* lamdaF = cvCreateMat(1, __nTextureModes, CV_64FC1);
	if (RatioF == 0) {
		cvZero(pF);
		cvZero(lamdaF);
	}
	else {
		AAM_Shape shapeF = ShapeF;
		shapeF.Centralize();
		thisfacewidth = ShapeF.GetWidth();
		if(stdwidth < thisfacewidth) 
			shapeF.Scale(stdwidth / thisfacewidth);
		shapeF.AlignTo(__AAMRefShape);
		CvMat* pqF = cvCreateMat(1, 4+__nShapeModes, CV_64FC1);
		__shape.CalcParams(shapeF, pqF);
		cvGetCols(pqF, pF, 4, 4+__nShapeModes);

		CvMat* TextureF = cvCreateMat(1, __paw.nPix() * 3, CV_64FC1);
		__paw.FasterGetWarpTextureFromShape(ShapeF, &ImageF, TextureF, false);
		__texture.AlignTextureToRef(__MeanT, TextureF);
		__texture.CalcParams(TextureF, lamdaF);
	}


	//mother
	CvMat* pM = cvCreateMat(1, __nShapeModes, CV_64FC1);
	CvMat* lamdaM = cvCreateMat(1, __nTextureModes, CV_64FC1);
	if (RatioM == 0) {
		cvZero(pM);
		cvZero(lamdaM);
	}
	else {
		AAM_Shape shapeM = ShapeM;
		shapeM.Centralize();
		thisfacewidth = ShapeM.GetWidth();
		if(stdwidth < thisfacewidth) 
			shapeM.Scale(stdwidth / thisfacewidth);
		shapeM.AlignTo(__AAMRefShape);
		CvMat* pqM = cvCreateMat(1, 4+__nShapeModes, CV_64FC1);
		__shape.CalcParams(shapeM, pqM);
		cvGetCols(pqM, pM, 4, 4+__nShapeModes);

		CvMat* TextureM = cvCreateMat(1, __paw.nPix() * 3, CV_64FC1);
		__paw.FasterGetWarpTextureFromShape(ShapeM, &ImageM, TextureM, false);
		__texture.AlignTextureToRef(__MeanT, TextureM);
		__texture.CalcParams(TextureM, lamdaM);
	}

	/*caculate new shape and texture parameters*/
	CvMat newShapeParams;
	CvMat* newpq = cvCreateMat(1, 4+__nShapeModes, CV_64FC1);
	cvmSet(newpq, 0, 0, cvmGet(pq, 0, 0));	cvmSet(newpq, 0, 1, cvmGet(pq, 0, 1));
	cvmSet(newpq, 0, 2, cvmGet(pq, 0, 2));	cvmSet(newpq, 0, 3, cvmGet(pq, 0, 3));
	cvGetCols(newpq, &newShapeParams, 4, 4+__nShapeModes);
	CvMat* newSP = cvCreateMat(1, __nShapeModes, CV_64FC1);
	FacePredict::CalcNewShapeParams(p, newSP, curAgeG, newAgeG);
	FacePredict::CalcParamsByRatio(newSP, pF, RatioF, pM, RatioM, &newShapeParams);

//.........这里部分代码省略.........
开发者ID:timedcy,项目名称:face,代码行数:101,代码来源:FacePredict.cpp


注:本文中的AAM_Shape::AlignTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。