0

我需要通过 USB 使用 Python 从几个(10-20)数码单反相机(佳能)同步和捕获图像,但我不知道如何。

我用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?

4

1 回答 1

1

如果您坚持为此应用程序使用 opencv,只需修改代码以使用多个 Videocapture 对象即可

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()
于 2017-06-27T23:51:56.293 回答