I am running OpenCV 3.1.0 on my Raspberry Pi 3 (with Raspbian Jessie). I'm using the Python 2.7 bindings.
As I request frames from a VideoCapture, occasionally (apparently at random) the frame will have an awful blocky artifact as seen below.
This never occurs when I use the webcam on my PC, nor does it occur when I view the webcam with a program like Cheese on the Raspberry Pi, so I have to conclude that it's either an OpenCV problem, or I'm using openCV incorrectly.
Further, the bad frames happen MUCH more often when the Pi is doing other things as well (for example, if I open a web browser while it's capturing).
Below is a sample script where I encounter the problem.
import cv2
cap = cv2.VideoCapture(0)
while(True):
res, im = cap.read()
cv2.imshow("foo", im)
cv2.waitKey(1)
My suspicion is that it has something to do with trying to retrieve the image buffer while the buffer is in the process of being updated, or something like that.
Am I doing something wrong here?
Again, I've only seen this issue occur with OpenCV on the Pi (to be clear, I have not yet tried it on my desktop or laptop with OpenCV... I'm downloading it now to my laptop. I will update with an indication of whether or not it works there)