如何使用cv :: warpPerspective进行透视图转换? [英] How to use cv::warpPerspective for the perspective transformation?
本文介绍了如何使用cv :: warpPerspective进行透视图转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试纠正图像.我有点对应关系,并且我计算了矩阵F1和F2.之后,我要纠正.以下是我的代码
I am trying to rectify images. I have point correspondences and I computed both of the matrices F1 and F2. After that, I want to rectify. following is my code
cv::Mat F1(4,4, CV_64FC1);
cv::Mat F2(4,4, CV_64FC1);
CvMat* points1 = cvCreateMat(8,1,CV_64FC2);
CvMat* points2 = cvCreateMat(8,1,CV_64FC2);
for (int i=0; i<8; i++) {
cvSet2D(points1,i,0,cvScalar(gt[i].xL,gt[i].yL));
cvSet2D(points2,i,0,cvScalar(gt[i].xR,gt[i].yR));
}
cv::Size size (imgL->width, imgL->height);
cv::stereoRectifyUncalibrated(points1, points2, F, size, F1, F2);
IplImage* rectL = cvCreateImage(cvSize(imgL->width,imgL->height), imgL->depth, imgL->nChannels);
cv::warpPerspective(imgL, rectL , F1, size);
cvSaveImage("rectL.jpg", rectL);
错误如下
error: in passing argument 2 of ‘void cv::warpPerspective(const cv::Mat&, cv::Mat&, const cv::Mat&, cv::Size, int, int, const cv::Scalar&)’
如果我确实按如下方式创建CvMat
And if I do create a CvMat as follows
CvMat* rectified1 = cvCreateMat(imgL->width,imgL->height,imgL->depth);
cv::warpPerspective(imgL, *rectified1, F1,size);
cvSaveImage("rectified1.png", imgL);
然后错误是保存图像.它说无法识别此数组.
Then the error is in saving the image. It say that this array is not recognized.
我想知道是否有人可以帮助我.
I am wondering if someone could please help me in this.
非常感谢.
推荐答案
cvMat
和cv::Mat
是两件事. cvMat
已过时.如果将所有内容都转换为cv :: Mat,它应该解决您的问题.
cvMat
and cv::Mat
are two different things. cvMat
is obsolete. If you convert everything to cv::Mat it should take care of your problem.
这篇关于如何使用cv :: warpPerspective进行透视图转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文