Hi' I'm using a Raspbery Pi and Pi Camera module with OpenCV though the V4L2 driver and have noticed I'm getting sequences of identical frames returned from cv2.VideoCapture in groups of 4. It seems like the function is not waiting until a new image is captured and the duplicate frames are not being blocked. Anyone had this problem? Here is some sample code:
def open_camera(cam_id = 0):
cap = cv2.VideoCapture(cam_id)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 240);
cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 320);
return cap
def get_frame(device):
ret, img = device.read()
if (ret == False): #failed to capture
print >> sys.stderr, "Error capturing from vid dev"
return None
return img
def run(wh,sh,wh2,sh2):
find_colour(wh,sh,wh2,sh2)
dev = open_camera(0)
while True:
img = get_frame(dev) # get frame from cam
if img is not None:# if possible to get image
#program code
else:
print 'failed to capture'
controller.forward(128)#stop
break
return()