I have C ++ code - cli that captures video from a folder in opencv using capture and then retrieves frames using a cvquery frame. Then I process the frames, and as soon as all the frames are processed, I release the capture. It works fine, but when I try multithreaded, it gives me a warning and cannot capture some of the videos in the folder with the warning "insufficient blocking of the stream around avcodec_open / close ()".
//for each video in folder do
{
capture=cvCreateFileCapture(filename);
while(1)
{
img=cvqueryframe(capture)
if !img break;
///process img
}
cvreleasecapture(&capture);
}
Is there a way to fix the problem for multithreading? I was thinking about using
while(!capture)
capture=cvCreateFileCapture(filename);
but there should be a more efficient way, perhaps using Monitor :: Enter (obj) or lock (obj) lock?
source
share