Device information

This example shows how you can query device information.

The first part of the code queries all available devices without actually booting any device. For each found device, it prints the following information:

  • Device name: Either IP, in case of OAK PoE cameras, or USB path in case of OAK USB cameras

  • MxId: Unique Mx (chip) identification code

  • State: State of the device. Note that OAK PoE cameras have bootloader flashed which initializes the network stack

Afterwards, the example boots into the first found device and prints available camera sensors, and reads calibration and eeprom data which stores product and board names.

Demo

Searching for all available devices...

Found device '1.3', MxId: '18443010D116631200', State: 'UNBOOTED'
Found device '192.168.33.201', MxId: '184430102163DB0F00', State: 'BOOTLOADER'
Found device '192.168.33.192', MxId: '1844301011F4C51200', State: 'BOOTLOADER'

Booting the first available camera (1.3)...
Available camera sensors:  {<CameraBoardSocket.CAM_C: 2>: 'OV9282', <CameraBoardSocket.CAM_A: 0>: 'IMX378', <CameraBoardSocket.CAM_B: 1>: 'OV9282'}
Product name: OAK-D Pro AF, board name DM9098

Setup

Please run the install script to download all required dependencies. Please note that this script must be ran from git context, so you have to download the depthai-python repository first and then run the script

git clone https://github.com/luxonis/depthai-python.git
cd depthai-python/examples
python3 install_requirements.py

For additional information, please follow installation guide

Source code

Also available on GitHub

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import depthai as dai
from typing import List

print('Searching for all available devices...\n')
# Query all available devices (USB and POE OAK cameras)
infos: List[dai.DeviceInfo] = dai.DeviceBootloader.getAllAvailableDevices()

if len(infos) == 0:
    print("Couldn't find any available devices.")
    exit(-1)


for info in infos:
    # Converts enum eg. 'XLinkDeviceState.X_LINK_UNBOOTED' to 'UNBOOTED'
    state = str(info.state).split('X_LINK_')[1]

    print(f"Found device '{info.name}', MxId: '{info.mxid}', State: '{state}'")


# Connect to a specific device. We will just take the first one
print(f"\nBooting the first available camera ({infos[0].name})...")
with dai.Device(dai.Pipeline(), infos[0], usb2Mode=False) as device:
    print("Available camera sensors: ", device.getCameraSensorNames())
    calib = device.readCalibration()
    eeprom = calib.getEepromData()
    print(f"Product name: {eeprom.productName}, board name {eeprom.boardName}")

Also available on GitHub

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>

// Includes common necessary includes for development using depthai library
#include "depthai/depthai.hpp"

int main() {
    std::cout << "Searching for all available devices...\n\n";
    auto infos = dai::Device::getAllAvailableDevices();

    if(infos.size() <= 0) {
        std::cout << "Couldn't find any available devices.\n";
        return -1;
    }

    for(auto& info : infos) {
        std::cout << "Found device: " << info.name << " mxid: " << info.mxid << " state: " << info.state << std::endl;
    }

    // Connect to device and start pipeline
    std::cout << "\nBooting the first available camera (" << infos[0].name << ")...\n";
    dai::Device device(dai::Pipeline(), infos[0]);
    std::cout << "Available camera sensors: ";
    for(auto& sensor : device.getCameraSensorNames()) {
        std::cout << "Socket: " << sensor.first << " - " << sensor.second << ", ";
    }
    std::cout << std::endl;

    auto eeprom = device.readCalibration2().getEepromData();
    std::cout << "Product name: " << eeprom.productName << ", board name: " << eeprom.boardName << std::endl;

    return 0;
}

Got questions?

Head over to Discussion Forum for technical support or any other questions you might have.