Yes, you are definitely limited by USB bandwidth. Trying to read from both devices with a complete error, you probably got the error:
libv4l2: error turning on stream: No space left on device VIDIOC_STREAMON: No space left on device Traceback (most recent call last): File "p.py", line 7, in <module> assert ret1
And then when you reduce the resolution to 160x120:
import cv2 cap0 = cv2.VideoCapture(0) cap0.set(3,160) cap0.set(4,120) cap1 = cv2.VideoCapture(1) cap1.set(3,160) cap1.set(4,120) ret0, frame0 = cap0.read() assert ret0 # succeeds ret1, frame1 = cap1.read() assert ret1 # fails?!
now it works! I am sure you have two cameras connected to the same USB-card. You can run the lsusb command to make sure, and it should point to something like:
Bus 001 Device 006: ID 046d:081b Logitech, Inc. Webcam C310 Bus 001 Device 004: ID 0409:005a NEC Corp. HighSpeed Hub Bus 001 Device 007: ID 046d:0990 Logitech, Inc. QuickCam Pro 9000 Bus 001 Device 005: ID 0409:005a NEC Corp. HighSpeed Hub Bus 001 Device 003: ID 0409:005a NEC Corp. HighSpeed Hub Bus 001 Device 002: ID 1058:0401 Western Digital Technologies, Inc. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
(Pay attention to both cameras on the same bus.) If possible, you can add another USB card to your computer to increase throughput. I have done this before to run multiple full resolution cams on the same machine. Although it was a tower workstation with accessible slots for motherboards, and, unfortunately, you may not have this option on a MacBook laptop.
Velimir Mlaker
source share