We are trying to simultaneously run 6 cameras on a Raspberry Pi 3B+ with an add-on 4 port USB hub that has an external power supply. The cameras are set at 15 FPS with a colour image size of 640 X 480. I found that it just works properly when I opened 2 cameras simultaneously. When I add a third camera I get this error message: "select timeout".
Below is the test code I'm using :
import cv2
import sys
print sys.argv
if len(sys.argv) < 2:
print "Usage : > python video.py [camno1] [camno2]"
sys.exit(0)
cam = []
cap = []
for i in range(len(sys.argv) - 1):
cam.append(int(sys.argv[i+1]))
cap.append(cv2.VideoCapture(cam[i]))
while True:
for i in range(len(cam)):
print "cam"+str(i)+" read"
ret, frame = cap[i].read()
if ret :
cv2.imshow("frame"+str(i), frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
for i in range(len(cam)):
cap[i].release()
My goal is to get a still image from each camera, one-by-one, and I don't need higher than 15 FPS. When I try to open/read and close each camera, one-by-one, it takes too long to start them all (around 1.5 sec per camera) so that the total time is more than 10 secs. So I am looking for a solution to either keep all 6 cameras open at the same time or to speed up the: open/read/close times for each camera so that my total rotation time is around one second. Anyone have any ideas?