Reputation: 31
I need to synchronize and capture image from several(10-20) DSLR(Canon) via USB use Python, but I don't know how.
I got it with SparkoCam
and this python code, but it work only with one camera
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()
Does anyone knows how can I capture image from DSLR? opencv, sdk?
Upvotes: 1
Views: 5448
Reputation: 2337
If you are insistent on using opencv for this application, simply modifying your code to use multiple Videocapture objects will work
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()
Upvotes: 1