Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv 垫板到仪表板碰撞_Opencv - Fatal编程技术网

Opencv 垫板到仪表板碰撞

Opencv 垫板到仪表板碰撞,opencv,Opencv,当我运行我的代码时,相机一直在崩溃。正在尝试将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* imgY

当我运行我的代码时,相机一直在崩溃。正在尝试将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);
这将成为:

//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不是用来混合C++和C API的。CV::是C++、CVFoWoE()和IPLIMAGE *,通常是FoO*是C API。选择一个并坚持使用。
IplImage*test=cvCloneImage(&(IplImage)画布)好,所以在C中,如果我想把图像绘制到透明背景,你知道它是否可能像C++一样?@安德烈,基本上任何C(旧)函数都有C++等价物。还有维切维萨,谢谢你的回答。也许如果我解释一下我想做什么,我会更清楚为什么我要复制。我正在尝试创建一个透明的背景,这样当我添加imgYellowThresh1图像时,它将位于此图像之上,而不是我的网络摄像头图像。
//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);