This seems to have come up a few times, but I haven't seen any conclusive resolutions (and nothing recently). I'm trying to connect to multiple cameras simultaneously, but I can't seem to make this reliable. Even using the example from depthai-experiments/gen2-multiple-devices I can't get two cameras to connect reliably (and I'm actually trying to connect 4-12). Usually failures happen one of two ways.

  1. The device creation (e.g. device: dai.Device = stack.enter_context(dai.Device(openvino_version, dev_info, False))) never returns (this seems to happen more when I try > 2 cameras), or
  2. I get the error [depthai] [warning] Monitor thread (device: 1844301081A8630F00 [169.254.1.240]) - ping was missed, closing the device connection.

I've tried checking for dai.XLinkDeviceState.X_LINK_BOOTLOADER state before trying to connect, and adding

os.environ["DEPTHAI_WATCHDOG_INITIAL_DELAY"] = "60000"
os.environ["DEPTHAI_BOOTUP_TIMEOUT"] = "60000"

to no avail. Is there some trick I'm missing?

It does appear to be something to do with multithreading the startup; if I call the worker function of the example directly, I don't seem to have the same problems (but obviously starting 4-12 cameras serially is not ideal from a timing perspective).

I saw that thread, but if I click on the link to the script it says it has expired.

 Check every second for new devices
while True:
    device_infos = dai.Device.getAllAvailableDevices()
    for device_info in device_infos:
        if device_info.state != dai.XLinkDeviceState.X_LINK_BOOTLOADER:
            continue
    # Start thread here
    sleep(1)