opencv - opencv关闭相机

标签 opencv c++-cli

好的,我有这个代码

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/

相关文章:

multithreading - 同步线程以同时读取不同的资源

opencv - 如何在 OpenCV 中测试线的接近度(霍夫变换)

android - 使用带有 Android NDK 的 OpenCV 转换数据格式

.net - 为什么 .NET CLI 不为引用类提供合成的复制构造函数和赋值运算符?

.net - C++ IEnumerable <int> = class-> method();在WinForms中

.net - 如何在 C++/CLI 程序和 C++/CLI DLL 之间传递字节数组?

c++ - 运行 Opencv 示例代码时出错

python - 在 scikit-image 中将轮廓转换为 numpy 数组掩码的有效方法?

c# - System.Guid 到 _GUID?

c++ - 如何将参数传递给已经开始运行的线程