I am new to Python, and I am learning the hard way. I'm using OpenCV to do this on a raspberry Pi 4 with 4 USB webcams for now. I am getting video, but I am unable to get 4 videos in one frame. Most of the code that I have found does not work. I am using Visual Studio to do this. This is one example that I am using.
import cv2.
import NumPy as np.
# initializer
cam0 = cv2.VideoCapture(0)
cam2 = cv2.VideoCapture(1)
cam3 = cv2.VideoCapture(3)
cam4 = cv2.VideoCapture(5)
while True:
ret1, frame1 = cam0.read()
ret2, frame2 = cam2.read()
ret3, frame3 = cam3.read()
ret4, frame4 = cam4.read()
if ret1:
cv2.imshow("cam0", frame1)
if ret2:
cv2.imshow("cam2", frame2)
if ret3:
cv2.imshow("cam3", frame3)
if ret4:
cv2.imshow("cam4", frame4)
if cv2.waitKey(1) == Ord('q'):
break
cam0.release()
cam2.release()
cam3.release()
cam4.release()
cv2.destroyAllWindows()