Multiple DepthAI per Host

Learn how to discover DepthAI devices connected to your system, and use them individually.

face

Shown on the left is Luxonis uAI (BW1093) which is actually plugged into a Raspberry Pi Compute Module Edition (BW1097).

So in this case, everything is running on the (single) Raspberry Pi 3B+ which is in the back of the BW1097.

Demo code

You can find demo code here. The demo will find all devices connected to the host and display an RGB preview from each of them.

Dependencies

You have already set up the Python API on your system (if you have a Raspberry Pi Compute Module it came pre-setup). See here if you have not yet installed the DepthAI Python API on your system.

Discover DepthAI-USB Port Mapping

The DepthAI multi-device support is currently done by selecting the device mx_id (serial number) of a connected DepthAI device.

If you’d like to associate a given DepthAI device with specific code (e.g. neural model) to be run on it, it is recommended to plug in one device at a time, and then use the following code to determine which device is on which port:

import depthai
for device in depthai.Device.getAllAvailableDevices():
    print(f"{device.getMxId()} {device.state}")

Example results for 2x DepthAI on a system:

14442C10D13EABCE00 XLinkDeviceState.X_LINK_UNBOOTED
14442C1071659ACD00 XLinkDeviceState.X_LINK_UNBOOTED

Selecting a Specific DepthAI device to be used.

From the Detected devices(s) above, use the following code to select the device you would like to use with your pipeline. For example, if the first device is desirable from above use the following code:

found, device_info = depthai.Device.getDeviceByMxId("14442C10D13EABCE00")

if not found:
    raise RuntimeError("Device not found!")

You can then use the device_info to specify on which device you want to run your pipeline:

with depthai.Device(pipeline, device_info) as device:

And you can use this code as a basis for your own use cases, such that you can run differing neural models on different DepthAI/uAI models.

Now use as many DepthAI devices as you need!

And since DepthAI does all the heavy lifting, you can usually use quite a few of them with very little burden to the host.

Got questions?

We’re always happy to help with code or other questions you might have.