简体   繁体   English

OpenCV设置大小中的内存泄漏

[英]Memory Leak in OpenCV Set Size

I am finding a memory leak in this simple OpenCV code: 我在以下简单的OpenCV代码中发现了内存泄漏:

VideoCapture* capture = new VideoCapture(0);
Mat frame;
while (true) {
    capture->set( CV_CAP_PROP_FRAME_WIDTH, 1600 );
    capture->set(CV_CAP_PROP_FRAME_HEIGHT, 1200 );
    capture->read(frame);
}

This is the whole code. 这是整个代码。 Every time through the while loop, several MB are leaked. 每次通过while循环时,都会泄漏几MB。 I have tried frame.release() just after the read, but it doesn't help. 读完之后我已经尝试过frame.release(),但这没有帮助。 Removing the set-size lines fixes the problem, but in my real code I want to vary the size, so that isn't a solution. 删除设置大小的行可以解决此问题,但是在我的实际代码中,我想更改大小,因此这不是解决方案。 It is getting the image at the correct size. 它以正确的尺寸获取图像。

Am I doing something stupid? 我在做蠢事吗?

By the way, I am using a Logitech B910 webcam. 顺便说一句,我正在使用Logitech B910网络摄像头。

Thanks! 谢谢!

Do you need to change the readout size on every frame? 您是否需要更改每帧的读数大小?

Once it is set the camera will produce the same size until you reset it 设置好之后,相机将产生相同的尺寸,直到您将其重置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM