I am having a camera, which I am reading frames from, using cv::VideoCapture. Those frames are then saved into a Q, which another Thread is reading from, doing some image modification and writing them into a Video File using cv::VideoWriter.
Once upon a time it seems VideoWriter.write() and VideoCapture.read() happen at the same time. I thought, this should have no interaction, however in these events VideoCapture.read() returns false and an empty image (took me quite some time to figure that out). My programm storage for the new image to be read and for the old image to be written is for sure not the same. Is there any interdependency within those two classes, that leads to VideoCapture.read() failing, when VideoWriter.write() is doing it’s magic?
I tried to look into the source Code but only found, that both call CV_INSTRUMENT_REGION(), but did not get very deep, before getting completely confused.
Thanks for your answers!
Is there any other possible way VideoCapture.read() can fail immediately (without timeout), when it worked several times before and also works thereafter (I am using OpenCV 4.8 on Linux compiled without GStreamer)?
Also this only happens in the VideoWriter Context. When I modify the Writer Thread and it does not write the images into a Video FIle, but just grabs and discards the images a Million Frames go by just fine. No exception otherwise also. It just returns false every let’s say 500-1000 Frames. Any idea, that could lead me on the right track?