DepthAI V3

面向 OAK 和 OAK4 相机的 DepthAI v3 API 文档:安装、示例以及 Python/C++ 参考。本文档涵盖 DepthAI v3,该版本同时支持 OAK 和 OAK4 相机。如果您希望使用 DepthAI v2(仅支持 RVC2 设备),请切换到 DepthAI V2 文档

DepthAI V2 与 V3 对比

了解 V2 和 V3 API 之间的主要差异。
V2 vs V3
入门指南图标

示例

要了解 DepthAI 的实际应用,请探索 v3 OAK 示例 仓库。这些示例展示了完整的管线和应用模式,可供您在自有项目中复用。
探索 DepthAI 示例
代码图标

安装

Linux / MacOS

1. Install DepthAI v3

Command Line
1git clone https://github.com/luxonis/depthai-core.git && cd depthai-core
2python3 -m venv venv
3source venv/bin/activate
4# Installs library and requirements
5python3 examples/python/install_requirements.py
or via pip:
Command Line
1pip install depthai --force-reinstall

2. Run an example

After installing the library, you can run an example, eg. Detection Network example or Display all cameras:
Command Line
1cd examples/python
2# Run YoloV6 detection example
3python3 DetectionNetwork/detection_network.py
4# Display all camera streams
5python3 Camera/camera_all.py

Windows

1. Install DepthAI v3

Command Line
1git clone https://github.com/luxonis/depthai-core.git
2cd depthai-core
3# Create and source venv
4python -m venv venv
5.\venv\Scripts\Activate.ps1 # OR .\venv\Scripts\Activate.bat if you are using CMD
6# Install requirements
7python examples\python\install_requirements.py
or via pip:
Command Line
1pip install depthai --force-reinstall

2. Run an example

After installing the library, you can run an example, eg. Detection Network example or Display all cameras:
Command Line
1cd examples\python
2# Run YoloV6 detection example
3python DetectionNetwork\detection_network.py
4# Display all camera streams
5python Camera\camera_all.py

Developing with C++?

DepthAI v3 is largely written in C++. The build instructions are available on the depthai-core repository.
Github page

组件

DepthAI 组件

  • 节点 代表一个传感器、加速硬件或某项计算功能
  • 管线 由链接的节点组成,部署到设备上后在加速硬件模块上运行
  • 消息 用于节点间的通信,包含数据与元数据
  • 设备 代表 Luxonis 的设备——OAK 或 OAK4 相机。负责连接与通信
  • 引导加载程序 处理 RVC2 设备启动时的逻辑,使其可被连接
  • Luxonis OS 是针对 RVC4 设备(OAK4)的定制 Linux 发行版

部署 AI 模型

预训练模型

HubAI 模型库 包含许多可直接部署到 OAK4 设备的预训练模型。除示例外,我们还在 oak-examples 中提供了一些神经网络示例/应用。

自定义模型

您可以通过以下方式转换自定义模型:如果你使用的是 .dlc,可以通过编辑以下代码片段将其部署到 OAK4 上:NeuralNetwork 示例
Python
1nn = pipeline.create(dai.node.NeuralNetwork)
2nn.setModelPath('my_model.dlc')
3nn.setBackend("snpe") # 指定 SNPE NN 后端。通常会在底层自动设置
4# 指定 SNPE (RVC4) 特定设置,如 DSP 运行时和 NN 性能配置文件
5nn.setBackendProperties({"runtime": "dsp", "performance_profile": "default"})
或者,如果你使用的是 archive.tar.xz,可以用以下代码片段编辑该示例:
Python
1cam = pipeline.create(dai.node.Camera).build(socket)
2# 如果你的神经网络模型需要 640x640 的输入尺寸(BGR):
3cam_out = cam.requestOutput((640, 640), dai.ImgFrame.Type.BGR888p)
4
5nn_archive = dai.NNArchive('./my_nn_archive.tar.xz')
6nn = pipeline.create(dai.node.NeuralNetwork).build(cam_out, nn_archive)