Multi-Device Setup

Discovering OAK cameras
DeviceIDs (unique identifier) and their XLink state.Python
1import depthai
2for device in depthai.Device.getAllAvailableDevices():
3 print(f"{device.getDeviceId()} {device.state}")Command Line
114442C10D13EABCE00 XLinkDeviceState.X_LINK_UNBOOTED
214442C1071659ACD00 XLinkDeviceState.X_LINK_UNBOOTED
33604808376 XLinkDeviceState.X_LINK_GATESelecting a Specific DepthAI device to be used
Python
1# Specify DeviceID, IP Address or USB path
2device_info = depthai.DeviceInfo("14442C108144F1D000") # DeviceID
3#device_info = depthai.DeviceInfo("192.168.1.44") # IP Address
4#device_info = depthai.DeviceInfo("3.3.3") # USB port name
5with depthai.Device(device_info) as device:
6 # ...Specifying POE device to be used
Timestamp syncing
DepthAI 2.24 introduces Sync node which can be used to sync messages from different streams, or messages from different sensors (eg. IMU and color frames). See Sync node for more details. The sync node does not currently support multiple device syncing, so if you want to sync messages from multiple devices, you should use the manual approach.
Multi camera demo
Python
1#!/usr/bin/env python3
2
3import cv2
4import depthai as dai
5import contextlib
6
7def createPipeline(pipeline):
8 camRgb = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_A)
9 output = camRgb.requestOutput((1280, 800), dai.ImgFrame.Type.NV12 ,dai.ImgResizeMode.CROP, 20).createOutputQueue()
10 return pipeline, output
11
12
13with contextlib.ExitStack() as stack:
14 deviceInfos = dai.Device.getAllAvailableDevices()
15 print("=== Found devices: ", deviceInfos)
16 queues = []
17 pipelines = []
18
19 for deviceInfo in deviceInfos:
20 pipeline = stack.enter_context(dai.Pipeline())
21 device = pipeline.getDefaultDevice()
22
23 print("===Connected to ", deviceInfo.getDeviceId())
24 mxId = device.getDeviceId()
25 cameras = device.getConnectedCameras()
26 usbSpeed = device.getUsbSpeed()
27 eepromData = device.readCalibration2().getEepromData()
28 print(" >>> Device ID:", mxId)
29 print(" >>> Num of cameras:", len(cameras))
30 if eepromData.boardName != "":
31 print(" >>> Board name:", eepromData.boardName)
32 if eepromData.productName != "":
33 print(" >>> Product name:", eepromData.productName)
34
35 pipeline, output = createPipeline(pipeline)
36 pipeline.start()
37 pipelines.append(pipeline)
38
39 queues.append(output)
40
41 while True:
42 for i, stream in enumerate(queues):
43 videoIn = stream.get()
44 assert isinstance(videoIn, dai.ImgFrame)
45 cv2.imshow(f"video_device{i}", videoIn.getCvFrame())
46 if cv2.waitKey(1) == ord('q'):
47 break