在使用BBX3捕获视频时,在while语句中有如下代码段,
... ...
IplImage *imgLeft, *imgRight;
IplImage *imgLeftCalib, *imgRightCalib;
... ...
while( true )
{
... ...
Mat rectL(rgbImageL.GetRows()/2,rgbImageL.GetCols()/2,CV_8UC3);
Mat rectR(rgbImageR.GetRows()/2,rgbImageR.GetCols()/2,CV_8UC3);
imgLeft = &IplImage(rectL);
imgRight = &IplImage(rectR);//Mat格式转IplImage格式
imgLeftCalib = cvCloneImage(imgLeft);
imgRightCalib = cvCloneImage(imgRight);
... ...
cvReleaseImage(&imgLeft);
cvReleaseImage(&imgRight);
cvReleaseImage(&imgLeftCalib);
cvReleaseImage(&imgRightCalib);
}
... ...
运行程序提示cvReleaseImage释放内存出错,把下面这两行注释掉后程序执行成功。
cvReleaseImage(&imgLeft);
cvReleaseImage(&imgRight);
Mat格式与IplImage格式互相转换代码如下:
Mat imgMat;
IplImage *imgIpl;
imgMat = Mat(imgIpl);
imgIpl = &IplImage(imgMat);