I am trying to connect multiple cameras Teledyne nano. The idea is that all the cameras have external activation trigger (all triggered at the same time) and the pc should get the images after the acquisition ends.
My working solution to opemn cameras and get the images is:
vin_device_0 = cvb.DeviceFactory.open(cvb.install_path() + “/drivers/GenICam.vin”,port = 0)
vin_device_1 = cvb.DeviceFactory.open(cvb.install_path() + “/drivers/GenICam.vin”,port = 1)
Create a stream form device_0 get the image, convert the image to numpy array abort the stream, open another stream get the image and so on:
stream = vin_device_0.stream
image, status = stream.get_snapshot()
print("Status 1: ",status)
#get the size
#access the image and convert it to a numpy array without copying if possible
np_array_0 = cvb.as_array(image,copy=True)
stream = vin_device_1.stream
except Exception as e:
I am pretty confident that it is not the best solution. My questions are:
- How would I go about accessing multiple devices? Creating many devices, and accessing each one by one or starting many streams (I see there is .start() and .stop() methods available) and waiting for some signal from the camera that the photo was acquired or like here ?
- Is storing the images as numpy array (with copy parameter as true) a proper way if I am expecting to have multiple cameras: np_array_0 = cvb.as_array(image,copy=True)
I would appreciate any help.
sorry for the delay.
Yesterday we released the obejct oriented Bindings as addon to CVB 13.x
(previously we only published nightlys).
This is important, because the release now contains two examples that cover acquisition from multible cameras.
Which shows asyncronos acqusition using an event loop. This method runns single threaded.
Which shows asyncronos acquisition by subclassing a StreamHandler. This method runns multi threaded.
In gernal if you want to acquire multible images you should always start the stream and wait for the images to arrive. Once youre done stop it.
If the cameras are electrical syncronized, so you can be sure they run at the exact same speed you can simply start both streams and wait on each stream sequentailly. Only the first wait will acctually wait, the second one will return imediatelly.
This scenario can be handled asynconouly by the MultiStreamHandler class.
In this case your script can e.g do some monitoring during acquisition.
Please also note, that CVBpy no comes as a python wheel, which requires an aditional pip install!
Thank you for the answer @Andreas It would be most helpful if you could explain on how can I access this addon? I am currently on the newest version of CVB with python binding. Did you maybe explained it in another post and can post a link ? Thanks you!
I updated all links to the previously nightly setup, so the now provide the release and added the bindings to the download section.
A good starting point is: