本页目录

  • 演示
  • 源代码

设备信息

本示例展示了如何查询设备信息。代码的第一部分查询所有可用设备,而无需实际启动任何设备。对于找到的每个设备,它会打印以下信息:
  • 设备名称:对于 OAK PoE 相机,为 IP 地址;对于 OAK USB 相机,为 USB 路径。
  • MxId:唯一的 Mx(芯片)识别码。
  • 状态:设备的状态。请注意,OAK PoE 相机已烧录引导加载程序,该程序会初始化网络堆栈。
然后,该示例启动找到的第一个设备,并打印可用的相机传感器,同时读取校准数据和 EEPROM 数据,其中存储了产品名称和板卡名称。

演示

Command Line
1正在搜索所有可用设备...
2
3找到设备 '1.3',MxId: '18443010D116631200',状态: 'UNBOOTED'
4找到设备 '192.168.33.201',MxId: '184430102163DB0F00',状态: 'BOOTLOADER'
5找到设备 '192.168.33.192',MxId: '1844301011F4C51200',状态: 'BOOTLOADER'
6
7正在启动第一个可用相机 (1.3)...
8可用的相机传感器: {<CameraBoardSocket.CAM_C: 2>: 'OV9282', <CameraBoardSocket.CAM_A: 0>: 'IMX378', <CameraBoardSocket.CAM_B: 1>: 'OV9282'}
9产品名称: OAK-D Pro AF,板卡名称 DM9098
这个示例需要DepthAI v3 API,参见安装说明

源代码

Python

Python
GitHub
1import depthai as dai
2from typing import List
3
4print('Searching for all available devices...\n')
5# Query all available devices (USB and POE OAK cameras)
6infos: List[dai.DeviceInfo] = dai.DeviceBootloader.getAllAvailableDevices()
7
8if len(infos) == 0:
9    print("Couldn't find any available devices.")
10    exit(-1)
11
12
13for info in infos:
14    # Converts enum eg. 'XLinkDeviceState.X_LINK_UNBOOTED' to 'UNBOOTED'
15    state = str(info.state).split('X_LINK_')[1]
16
17    print(f"Found device '{info.name}', MxId: '{info.mxid}', State: '{state}'")
18
19
20# Connect to a specific device. We will just take the first one
21print(f"\nBooting the first available camera ({infos[0].name})...")
22with dai.Device(dai.Pipeline(), infos[0], usb2Mode=False) as device:
23    print("Available camera sensors: ", device.getCameraSensorNames())
24    calib = device.readCalibration()
25    eeprom = calib.getEepromData()
26    print(f"Product name: {eeprom.productName}, board name {eeprom.boardName}")

C++

1#include <iostream>
2
3// Includes common necessary includes for development using depthai library
4#include "depthai/depthai.hpp"
5
6int main() {
7    std::cout << "Searching for all available devices...\n\n";
8    auto infos = dai::Device::getAllAvailableDevices();
9
10    if(infos.size() <= 0) {
11        std::cout << "Couldn't find any available devices.\n";
12        return -1;
13    }
14
15    for(auto& info : infos) {
16        std::cout << "Found device: " << info.name << " mxid: " << info.mxid << " state: " << info.state << std::endl;
17    }
18
19    // Connect to device and start pipeline
20    std::cout << "\nBooting the first available camera (" << infos[0].name << ")...\n";
21    dai::Device device(dai::Pipeline(), infos[0]);
22    std::cout << "Available camera sensors: ";
23    for(auto& sensor : device.getCameraSensorNames()) {
24        std::cout << "Socket: " << sensor.first << " - " << sensor.second << ", ";
25    }
26    std::cout << std::endl;
27
28    auto eeprom = device.readCalibration2().getEepromData();
29    std::cout << "Product name: " << eeprom.productName << ", board name: " << eeprom.boardName << std::endl;
30
31    return 0;
32}

需要帮助?

请前往 OAKChina 官网 获取技术支持或解答您的任何疑问。