I'm trying to add multiple cameras using OpenCV python but in my case, it is not working. I printed out the return then one is given true and another is false. But when I use each camera as single then it works fine. I tried to solve it but the solution doesn't come. I have attached the output to this post. [Note] Python Version - 3.7.6 and OpenCV version - 4.4.0, usb cameras
import numpy as np
import cv2
video_capture_0 = cv2.VideoCapture(0, cv2.CAP_DSHOW)
video_capture_1 = cv2.VideoCapture(1, cv2.CAP_DSHOW)
while True:
# Capture frame-by-frame
ret0, frame0 = video_capture_0.read()
ret1, frame1 = video_capture_1.read()
print(ret0)
print(ret1)
cv2.imshow('Cam 1', frame1)
if (ret0):
# Display the resulting frame
cv2.imshow('Cam 0', frame0)
if (ret1):
# Display the resulting frame
cv2.imshow('Cam 1', frame1)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything is done, release the capture
video_capture_0.release()
video_capture_1.release()
cv2.destroyAllWindows()
Output Image