ON THIS PAGE

  • Multi-Device Setup
  • Discovering OAK cameras
  • Selecting a Specific DepthAI device to be used
  • Specifying POE device to be used
  • Timestamp syncing
  • Multi camera demo
  • Multi camera calibration

Multi-Device Setup

You can find Demo scripts here. Learn how to discover multiple OAK cameras connected to your system, and use them individually.

Discovering OAK cameras

You can use DepthAI to discover all connected OAK cameras, either via USB or through the LAN (OAK POE cameras). The code snippet below finds all OAK cameras and prints their DeviceIDs (unique identifier) and their XLink state.
Python
1import depthai
2for device in depthai.Device.getAllAvailableDevices():
3    print(f"{device.getDeviceId()} {device.state}")
Example results for 3x DepthAI on a system:
Command Line
114442C10D13EABCE00 XLinkDeviceState.X_LINK_UNBOOTED
214442C1071659ACD00 XLinkDeviceState.X_LINK_UNBOOTED
33604808376 XLinkDeviceState.X_LINK_GATE

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:
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    # ...
And you can use this code as a basis for your own use cases, such that you can run differing neural models on different OAK models.

Specifying POE device to be used

You can specify the POE device to be used by the IP address as well, as shown in the code snippet above.Now use as many OAK cameras 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.

Timestamp syncing

Timestamp synchronization, alternatively referred to as message syncing, involves aligning messages from various sensors, including frames, IMU packets, ToF data, and more.More information about timestamp synchronization can be found on the Frame synchronization page .

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

Multi camera calibration

This example demonstrates how to compute extrinsic parameters (pose of the camera) for multiple cameras. It provides a practical illustration of how to determine the relative positions and orientations of different cameras in a multi-camera setup. By accurately estimating the extrinsic parameters, we can ensure that the images captured by each camera are correctly aligned and can be effectively combined for further processing and analysis.

Multiple camera calibration on GitHub

GitHub logo