无法编译此图像旋转代码

时间:2017-04-25 08:58:11

标签: c++ opencv

// rotate the image
frame = cvQueryFrame(capture);
int dx,dy,s; 
double thetaDegree;
double thetaRadian;

//for rotation
IplImage *Rotation;
Rotation = cvCloneImage(frame);
Rotation->origin = frame->origin;
CvZero(Rotation);

//get the rotation degree

thetaRadian = atan(s);      // **the s I have algorithm to do the calculation **
thetaDegree = thetaRadian *(180 / PI);

CvMat *rot = cvgetRotationMatrix2D(center, thetaDegree, 1.0);
cvWarpAffine(frame, Rotation, rot,sizeof(frame));

cvNameWindow("Rotation",1);
cvShowImage("Rotation",Rotation);
cvReleaseImage(&Rotation);
cvReleaseMat(&rot);

现在错误是函数cvWarpAffine的参数太少而且我真的不知道为什么,因为我已经经历了这么多的例子并从中学习。拜托,有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

如果this是正确的引用,那么看起来你正在混合使用C和C ++接口。

doc提供了以下类似C的界面:

C: void cvWarpAffine(const CvArr* src, CvArr* dst, const CvMat* map_matrix,
                     int flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS,
                     CvScalar fillval=cvScalarAll(0) )

在这种情况下,您不需要大小,但我不明白为什么大小不会转换为标志。