本文整理汇总了C++中AAM_Shape::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ AAM_Shape::GetWidth方法的具体用法?C++ AAM_Shape::GetWidth怎么用?C++ AAM_Shape::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AAM_Shape
的用法示例。
在下文中一共展示了AAM_Shape::GetWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FaceSynthesis
void FacePredict::FaceSynthesis(AAM_Shape &shape, CvMat* texture, IplImage* newImage)
{
double thisfacewidth = shape.GetWidth();
shape.Scale(stdwidth / thisfacewidth);
shape.Translate(-shape.MinX(), -shape.MinY());
AAM_PAW paw;
CvMat* points = cvCreateMat (1, __shape.nPoints(), CV_32FC2);
CvMemStorage* storage = cvCreateMemStorage(0);
paw.Train(shape, points, storage, __paw.GetTri(), false); //the actual shape
__AAMRefShape.Translate(-__AAMRefShape.MinX(), -__AAMRefShape.MinY()); //refShape, central point is at (0,0);translate the min to (0,0)
double minV, maxV;
cvMinMaxLoc(texture, &minV, &maxV);
cvConvertScale(texture, texture, 1/(maxV-minV)*255, -minV*255/(maxV-minV));
cvZero(newImage);
int x1, x2, y1, y2, idx1 = 0, idx2 = 0;
int tri_idx, v1, v2, v3;
int minx, miny, maxx, maxy;
minx = shape.MinX(); miny = shape.MinY();
maxx = shape.MaxX(); maxy = shape.MaxY();
for(int y = miny; y < maxy; y++)
{
y1 = y-miny;
for(int x = minx; x < maxx; x++)
{
x1 = x-minx;
idx1 = paw.Rect(y1, x1);
if(idx1 >= 0)
{
tri_idx = paw.PixTri(idx1);
v1 = paw.Tri(tri_idx, 0);
v2 = paw.Tri(tri_idx, 1);
v3 = paw.Tri(tri_idx, 2);
x2 = paw.Alpha(idx1)*__AAMRefShape[v1].x + paw.Belta(idx1)*__AAMRefShape[v2].x +
paw.Gamma(idx1)*__AAMRefShape[v3].x;
y2 = paw.Alpha(idx1)*__AAMRefShape[v1].y + paw.Belta(idx1)*__AAMRefShape[v2].y +
paw.Gamma(idx1)*__AAMRefShape[v3].y;
idx2 = __paw.Rect(y2, x2);
if(idx2 < 0) continue;
CV_IMAGE_ELEM(newImage, byte, y, 3*x) = cvmGet(texture, 0, 3*idx2);
CV_IMAGE_ELEM(newImage, byte, y, 3*x+1) = cvmGet(texture, 0, 3*idx2+1);
CV_IMAGE_ELEM(newImage, byte, y, 3*x+2) = cvmGet(texture, 0, 3*idx2+2);
}
}
}
cvReleaseMat(&points);
cvReleaseMemStorage(&storage);
}
示例2: ontrackcam
//============================================================================
void ontrackcam(int pos)
{
if(c == 0)
{
c = cvCreateMat(1, g_cam->nModes(), CV_64FC1);cvZero(c);
s = cvCreateMat(1, g_cam->__shape.nPoints()*2, CV_64FC1);
t = cvCreateMat(1, g_cam->__texture.nPixels(), CV_64FC1);
}
double var;
//registrate appearance parameters
for(int i = 0; i < n; i++)
{
var = 3*sqrt(g_cam->Var(i))*(double(b_c[i])/offset-1.0);
cvmSet(c, 0, i, var);
}
//generate shape and texture instance
g_cam->CalcLocalShape(s, c);
g_cam->CalcTexture(t, c);
//warp texture instance from base mesh to current shape instance
aam_s.Mat2Point(s);
int w = aam_s.GetWidth(), h = aam_s.MaxY()-aam_s.MinY();
aam_s.Translate(w, h);
if(image == 0)image = cvCreateImage(cvSize(w*2,h*2), 8, 3);
cvSet(image, cvScalar(128, 128, 128));
g_cam->DrawAppearance(image, aam_s, t);
cvNamedWindow("Combined Appearance Model",1);
cvShowImage("Combined Appearance Model", image);
if(cvWaitKey(10) == '27')
{
cvReleaseImage(&image);
cvReleaseMat(&s);
cvReleaseMat(&t);
cvReleaseMat(&c);
cvDestroyWindow("Parameters");
cvDestroyWindow("Combined Appearance Model");
}
}
示例3: 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);
//.........这里部分代码省略.........