c++ - 使用 OpenCV C++ 接口(interface),我是否需要释放使用 VideoCapture(int 设备?)

标签 c++ c opencv

文档什么都没说...但是这个,但是cvCapture是一个C类型。

" 注意

In C API, when you finished working with video, release
 CvCapture structure with      cvReleaseCapture(), or 
use Ptr<CvCapture> that calls cvReleaseCapture() automa
tically in the destructor."

我认为 VideoCapture 是一个对象,但不是吗?

最佳答案

VideoCapture 的析构函数是

VideoCapture::~VideoCapture() 
{
    cap.release();
}

所以没有必要释放它。

如果你想释放而不破坏调用 VideoCapture 对象上的 release() 方法的对象,你会得到相同的效果:

void VideoCapture::release()
{
    cap.release();
}

关于c++ - 使用 OpenCV C++ 接口(interface),我是否需要释放使用 VideoCapture(int 设备?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20049081/

相关文章:

c++ - 堆栈结构中的动态数组(在堆上)会发生什么情况?

c++ - 在多线程代码中转发

c - 浮点除法计算器

c - C中的一个小困惑

c - 为什么我的 C 循环双端队列程序无法退出打印功能?

python - 确定颜色是否在轮廓 OpenCV 内

c++ - 如何特化模板

c++ - 如果 count() 是 constexpr 函数,为什么 std::array<int, count()> 不能编译?

c++ - 使用 Opencv/c++ 在 Stream 中的两点之间画一条线

android - 为 Android 使用 OpenCv contrib 模块