简体   繁体   English

OpenCV错误:内存不足

[英]OpenCV Error: Insufficient memory

I'm developing a project with opencv 2.3 in c++ style. 我正在用c ++风格的opencv 2.3开发一个项目。

In the application I load a video and process every frame and do some stuff with the Mat object. 在应用程序中,我加载视频并处理每个帧,并对Mat对象进行一些处理。 After some time I get a Insufficient memory Error. 一段时间后,我收到内存不足错误。

I capture the frame like: 我像这样捕获帧:

FCapture >> FImage; 
FDetector->execute(FImage); 

In the execute I copy the image and save it in a std::Vector list. 在执行过程中,我复制图像并将其保存在std :: Vector列表中。 And also check the imageblobs like: 并检查像这样的图像斑点:

vector<vector<Point> > contours; 
findContours(FImage, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE); 

I know its a bit difficult to answer where the problem could be, but it's impossible to post here to whole program code. 我知道很难回答问题可能在哪里,但是不可能在此处发布整个程序代码。 Maybe someone could tell me where I have to be careful to copy Mat objects or other OpenCv object that could be the reason of the error. 也许有人可以告诉我在哪里我必须小心复制Mat对象或其他OpenCv对象,这可能是错误的原因。

Interesting: 有趣:

In the execute I copy the image and save it in a std::Vector list 在执行过程中,我复制图像并将其保存在std :: Vector列表中

and this statement as well: 以及以下语句:

After some time I get a Insufficient memory Error. 一段时间后,我收到内存不足错误。

OpenCV images can be quite big depending on their size, and based on what you said, I think that your vector is growing faster then you can remove data from it , causing the insufficient memory error. OpenCV图像可能会很大,这取决于它们的大小,并且根据您所说的,我认为您的向量增长得更快,然后您就可以从其中删除数据 ,从而导致内存不足错误。

Makes sense right? 有道理吧? If you keep adding data to the vector, one day you'll run out of memory to store new data. 如果您继续向引导程序添加数据,则有一天您将用光内存来存储新数据。

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

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