基于OpenCV的多相机图像获取与显示

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()

测试截图如下:

基于OpenCV的多相机图像获取与显示_第1张图片


你可能感兴趣的:(python,opencv,双目视觉)