本文整理汇总了C++中AAM_Shape::MaxX方法的典型用法代码示例。如果您正苦于以下问题:C++ AAM_Shape::MaxX方法的具体用法?C++ AAM_Shape::MaxX怎么用?C++ AAM_Shape::MaxX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AAM_Shape
的用法示例。
在下文中一共展示了AAM_Shape::MaxX方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DrawAppearance
//============================================================================
void AAM_CAM::DrawAppearance(IplImage* image, const AAM_Shape& Shape, CvMat* Texture)
{
AAM_PAW paw;
int x1, x2, y1, y2, idx1 = 0, idx2 = 0;
int tri_idx, v1, v2, v3;
int minx, miny, maxx, maxy;
paw.Train(Shape, __Points, __Storage, __paw.GetTri(), false);
AAM_Shape refShape = __paw.__referenceshape;
double minV, maxV;
cvMinMaxLoc(Texture, &minV, &maxV);
cvConvertScale(Texture, Texture, 1/(maxV-minV)*255, -minV*255/(maxV-minV));
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)*refShape[v1].x + paw.Belta(idx1)*refShape[v2].x +
paw.Gamma(idx1)*refShape[v3].x;
y2 = paw.Alpha(idx1)*refShape[v1].y + paw.Belta(idx1)*refShape[v2].y +
paw.Gamma(idx1)*refShape[v3].y;
idx2 = __paw.Rect(y2, x2);
if(idx2 < 0) continue;
CV_IMAGE_ELEM(image, byte, y, 3*x) = cvmGet(Texture, 0, 3*idx2);
CV_IMAGE_ELEM(image, byte, y, 3*x+1) = cvmGet(Texture, 0, 3*idx2+1);
CV_IMAGE_ELEM(image, byte, y, 3*x+2) = cvmGet(Texture, 0, 3*idx2+2);
}
}
}
}
示例3: AlignShape
void AAMBody::AlignShape(AAM_Shape& pStartShape, const AAM_Shape& pDetShape, const AAM_Shape& pMeanShape)
{
AAM_Shape baseShape, alignedShape;
baseShape.resize(2);
alignedShape.resize(2);
double meanCenter = (pMeanShape.MinY() + pMeanShape.MaxY()) * 0.5;
baseShape[0].x = pMeanShape.MinX();
baseShape[0].y = meanCenter;
baseShape[1].x = pMeanShape.MaxX();
baseShape[1].y = meanCenter;
double yMean = (pDetShape[1].y + pDetShape[0].y) * 0.5;
alignedShape[0].x = pDetShape[0].x;
alignedShape[0].y = yMean;
alignedShape[1].x = pDetShape[1].x;
alignedShape[1].y = yMean;
double a, b, tx, ty;
baseShape.AlignTransformation(alignedShape, a, b, tx, ty);
pStartShape = pMeanShape;
pStartShape.TransformPose(a, b, tx, ty);
}
示例4: DrawAppearance
//============================================================================
void AAM_Basic::DrawAppearance(IplImage* image)
{
AAM_Shape Shape; Shape.Mat2Point(__current_s);
AAM_PAW paw;
paw.Train(Shape, __cam.__Points, __cam.__Storage, __cam.__paw.GetTri(), false);
int x1, x2, y1, y2, idx1, idx2;
int tri_idx, v1, v2, v3;
int xby3, idxby3;
int minx, miny, maxx, maxy;
AAM_Shape refShape; refShape.Mat2Point(__cam.__MeanS);
refShape.Translate(-refShape.MinX(), -refShape.MinY());
double minV, maxV;
cvMinMaxLoc(__t_m, &minV, &maxV);
cvConvertScale(__t_m, __t_m, 255/(maxV-minV), -minV*255/(maxV-minV));
byte* pimg;
double* fastt = __t_m->data.db;
minx = Shape.MinX(); miny = Shape.MinY();
maxx = Shape.MaxX(); maxy = Shape.MaxY();
if( minx < 0 )
minx = 0;
else if(minx >= image->width)
minx = image->width - 1;
if( miny < 0 )
miny = 0;
else if(miny >= image->height)
miny = image->height - 1;
if( maxx < 0 )
maxx = 0;
else if(maxx >= image->width)
maxx = image->height - 1;
if( maxy < 0 )
maxy = 0;
else if(maxy >= image->height)
maxy = image->height - 1;
for(int y = miny; y < maxy; y++)
{
y1 = y-miny;
pimg = (byte*)(image->imageData + image->widthStep*y);
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]*refShape[v1].x + paw.__belta[idx1]*refShape[v2].x +
paw.__gamma[idx1]*refShape[v3].x;
y2 = paw.__alpha[idx1]*refShape[v1].y + paw.__belta[idx1]*refShape[v2].y +
paw.__gamma[idx1]*refShape[v3].y;
xby3 = 3*x;
idx2 = __cam.__paw.__rect[y2][x2]; idxby3 = 3*idx2;
pimg[xby3] = fastt[idxby3];
pimg[xby3+1] = fastt[idxby3+1];
pimg[xby3+2] = fastt[idxby3+2];
}
}
}
}