I have a c++-cli code that is capturing videos from a folder in opencv using capture and then retrieving frames using cvquery frame. I then process frames and once all frames are processed i release the capture. It works fine but when I try to multithread it gives me a warning and cannot capture some of the videos in the folder with warning " insufficient thread locking 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 of using
while(!capture)
capture=cvCreateFileCapture(filename);
but there should a more efficient way, maybe using locking Monitor::Enter(obj) or lock(obj)?