当我运行代码时,相机不断崩溃。尝试将cv::mat转换为IplImage。

cv::Mat canvas(320, 240, CV_8UC3, Scalar(255,255,255));

 IplImage test =canvas;

  while(true )
{

 canvas =cvQueryFrame(capture);
 imgScribble = cvCreateImage(cvGetSize(&test), 8, 3);

 IplImage* imgYellowThresh1 = GetThresholdedImage1(&test);

cvAdd(&test,imgScribble,&test);

cvShowImage("video", &test);

最佳答案

//This is the only line that uses the C++ API, so I assume you want to use the C API instead
cv::Mat canvas(320, 240, CV_8UC3, Scalar(255,255,255));
//I have used OpenCV for quite a while now and I've always declared IplImage*, and never IplImage. Use it safely as a rule of thumb, * always goes after IplImage
 IplImage test =canvas;

这将变为:
//although why you need to clone a newly created
//blank image is a valid concern
IplImage* canvas = cvCreateImage(....);
IplImage* test = cvClone(canvas);
cvZero(test);
//don't forget to release resources at some point
cvReleaseImage(&canvas);
cvReleaseImage(&test);

关于opencv - 垫到IplImage崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17835289/

10-13 03:54