透视变化

来源:互联网 发布:eclipse和java的关系 编辑:程序博客网 时间:2024/04/28 20:21

CvPoint2D32f ptSource[4],ptPrespective[4];

for(i=0;i<4;i++) ptSource[i]=cvPoint2D32f(ptSource[i].x,ptSource[i].y);

ptPrespective[TOPLEFT]=cvPoint2D32f(0,0);
ptPrespective[TOPRIGHT]=cvPoint2D32f(dst->640,0);
ptPrespective[BOTTOMRIGHT]=cvPoint2D32f(0,dst->480);
ptPrespective[BOTTOMLEFT]=cvPoint2D32f(dst->640,dst->480);

float newm[9];
CvMat mat=cvMat(3,3,CV_32F,newm);

cvWarpPerspectiveQMatrix(ptSource,ptPrespective,&mat);

cvWarpPerspective(src,dst,&mat,CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS,cvScalarAll(0));