如何通过USB捕获多个DSLR摄像机的图像使用Python



我需要同步并通过USB使用python从几个(10-20(DSLR(10-20(DSLR(佳能(捕获图像,但是我不知道如何。

我使用SparkoCam和此Python代码获得了它,但仅与一台相机一起使用

import cv2
import numpy as np
cap = cv2.VideoCapture(1)
while True:
    ret,img=cap.read()
    cv2.imshow('video output',img)
    k=cv2.waitKey(10)& 0xff
    if k==27:
        break
cap.release()
cv2.destroyAllWindows()

有人知道如何从DSLR捕获图像?OPENCV,SDK?

如果您坚持使用OPENCV进行此应用程序,则只需修改代码以使用多个视频关注对象

import cv2
import numpy as np
cap1 = cv2.VideoCapture(1)
cap2 = cv2.VideoCapture(2) #you can check what integer code the next camera uses
cap2 = cv2.VideoCapture(2) #you can check what integer code the next camera uses
#and so on for other cameras
#You could also make this more convenient and more readable by using an array of videocapture objects
while True:
    ret1,img1=cap1.read()
    cv2.imshow('video output1',img1)
    ret2,img2=cap2.read()
    cv2.imshow('video output2',img2)
    #and so on for the other cameras
    k=cv2.waitKey(10)& 0xff
    if k==27:
        break
cap1.release()
cap2.release()
#and so on for the other cameras
cv2.destroyAllWindows()

最新更新