CVBPy Best way to access muptiple cameras?

Hi,
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:

try:
stream = vin_device_0.stream
image, status = stream.get_snapshot()
print("Status 1: ",status)
#get the size
print(image.size.height,image.size.width)
#access the image and convert it to a numpy array without copying if possible
np_array_0 = cvb.as_array(image,copy=True)
stream.try_abort()
stream = vin_device_1.stream
except Exception as e:
    print(e)
    pass
finally:
    stream.try_abort()

I am pretty confident that it is not the best solution. My questions are:

  1. 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 ?
  2. 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.
Thanks!
Piotr

Hi @piotrM,

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.

  • StreamingAsync
    Which shows asyncronos acqusition using an event loop. This method runns single threaded.
  • StreamingParallel
    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!

1 Like

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!

Hi @piotrM,

Good point.

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: