VideoCapture read non blocking?
I am programming in Python, Pygame from what I understand uses opencv for its webcam functions. There is a query_image() available that polls the camera so you can start fetching a frame only when there is a frame to fetch, for example:
pygame.init()
pygame.camera.init()
webcam = pygame.camera.Camera("/dev/video0",(320,240))
webcam.start()
if(webcam.query_image()):
image = webcam.get_image()
When I use the following code with opencv:
cap = cv2.VideoCapture(0)
rval, frame = cap.read()
It waits until the frame is fetched which is for me undesirable, is there a way to poll the camera before trying to fetch to see if there is a frame available?
not know at all python .. but i think if cap.open() first is needed ... any how normally the detection works in a separate thread ....