I'm using Python OpenCV to read from 2 USB webcams on a Raspberry Pi4. If I'm using either of the camera individually they work fine. As soon as I initialize both cameras in the script as following:
import cv2 cap0 = cv2.VideoCapture(0); cap0.set(cv2.CAP_PROP_FRAME_WIDTH, 1280) cap0.set(cv2.CAP_PROP_FRAME_HEIGHT, 720) cap1 = cv2.VideoCapture(2); cap1.set(cv2.CAP_PROP_FRAME_WIDTH, 1280) cap1.set(cv2.CAP_PROP_FRAME_HEIGHT, 720) while True: ret0, frame1 = cap0.read() ret1, frame2 = cap1.read() print('Retval cap0: ' ,ret0) print('Retval cap1: ', ret1) if ret0: cv2.imshow('frame1', frame1) if ret1: cv2.imshow('frame2', frame2) if cv2.waitKey(1) & 0xFF == ord('q'): break cap0.release() cap1.release() cv2.destroyAllWindows() I get this ouput:
select timeout VIDIOC_DQBUF: Resource temporarily unavailable Retval cap0: True Retval cap1: False VIDIOC_QBUF: Invalid argument Retval cap0: True Retval cap1: False VIDIOC_QBUF: Invalid argument ... If I use 640x480 resolution it seems to work but I would need the HD resolution. It didn't help to add a deleay between the read steps. Using the Rpi3 Model B+ (Raspian Strech) I can run the script properly, the VIDIOC Error appeard only on Rpi4 (Raspian Buster).
VIDIOC_DQBUF: Resource temporarily unavailableerror on 9/26 release. This also is an issue onpygamefor video capture, but not for very slow image capture (?).