gpt4 book ai didi

opencv - 垫到IplImage崩溃

转载 作者:行者123 更新时间:2023-12-02 17:52:19 27 4
gpt4 key购买 nike

当我运行代码时,相机不断崩溃。尝试将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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com