此页面由 AI 自动翻译。查看英文原版

本页目录

  • 演示
  • 源代码

设备信息

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

演示

Command Line
1Searching for all available devices...
2
3Found device '1.3', MxId: '18443010D116631200', State: 'UNBOOTED'
4Found device '192.168.33.201', MxId: '184430102163DB0F00', State: 'BOOTLOADER'
5Found device '192.168.33.192', MxId: '1844301011F4C51200', State: 'BOOTLOADER'
6
7Booting the first available camera (1.3)...
8Available camera sensors:  {<CameraBoardSocket.CAM_C: 2>: 'OV9282', <CameraBoardSocket.CAM_A: 0>: 'IMX378', <CameraBoardSocket.CAM_B: 1>: 'OV9282'}
9Product name: OAK-D Pro AF, board name 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}

需要帮助?

请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。