import cv2 cameraCapture0 = cv2.VideoCapture(0)# open camera 0, 1 cameraCapture1 = cv2.VideoCapture(1) success0, frame0 = cameraCapture0.read() success1, frame1 = cameraCapture1.read() print(success0,success1) while (success0 or success1) and cv2.waitKey(1) == -1 :# 1ms delay if success0: cv2.imshow("L",frame0) success0, frame0 = cameraCapture0.read()# output frame by frame if success1: cv2.imshow("R",frame1) success1, frame1 = cameraCapture1.read() cv2.waitKey(0) cv2.destroyAllWindows()
測試截圖以下: python