OpenCV VideoCapture fails to open many files

Hi,

I have a problem to open many video files (e.g., 200) in a loop by using the
OpenCV class VideoCapture. Below you can find my code.

More specifically, my program succeeds to open a certain number of videos
(usually 171-173) but then it fails to open the others. I even tried to open
always the same file (like in the example below) but the behaviour is the same.

In my opinion it should not be a memory leak problem (actually there is memory
leak, but consumes only about 50MB in total). I think it is related to the fact
that, when each video is opened, several threads are also opened and never
closed, so they accumulate. But I don't know if this is the real reason or, if
it is, how to solve it.

I'm using Visual Studio to compile, Windows 7 OS, and OpenCV 2.3.

Please let me know if you have any clue and/or solution. Thank you in advance.

1
2
3
4
5
6
7
8
9
10
11
string video_filenae = "MyVideo.mp4";
for(int j=0; j<200; j++)
{
    VideoCapture video(video_filename);
    if(!video.isOpened())
    {
        cout << "Video #" << j << " could not be opened" << endl;
    }

    video.release(); // I've tried also to comment this out
}


P.S.: I think you can easily try to reproduce this problem, as the code is very
simple.
Topic archived. No new replies allowed.