好的,我有这个代码
IplImage *frame;
CvCapture *capture = cvCaptureFromCAM(0);
frame = cvQueryFrame(capture);
cvSaveImage("sample.jpg",frame);
cvReleaseImage(&frame);
保存图像,但是保存该图像后,我想释放该相机以使其关闭。现在相机保持开启状态,直到程序停止运行,我想在
cvReleaseImage(&frame);
之后释放并完全关闭相机我试过了
cvReleaseCapture(&capture)
但是它给了我一个运行时错误:
the application has requested the Runtime to terminate in an unusual way
和这个错误OpenCV Error: Bad argument (unrecognized or unsupported array type) in unknown function, file ......\modules\core\src\array.cpp, line 996
最佳答案
我不太确定。但是,请尝试删除cvReleaseImage调用。
我记得cvQueryImage方法检索的图像指针始终指向相同的地址。所以我的猜测是该图像数据由捕获管理。因此,释放它是在释放捕获时完成的。
编辑:
在这里找到:
http://opencv.jp/opencv-1.0.0_org/docs/ref/opencvref_highgui.htm
The function cvQueryFrame grabs a frame from camera or video file, decompresses and returns it. This function is just a combination of cvGrabFrame and cvRetrieveFrame in one call. The returned image should not be released or modified by user.
关于opencv - opencv关闭相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7076819/