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

本页目录

  • 如何放置
  • 输入和输出
  • 模型尺寸
  • 后处理
  • 畸变校正
  • 用法
  • 功能示例
  • 参考

NeuralDepth

Supported on:RVC4
NeuralDepth 节点使用神经网络而不是传统的立体匹配算法来计算立体相机对的深度。 它提供了 StereoDepth 节点的替代方案,并具有其独特的优势。底层使用了 LENS (Luxonis Edge Neural Stereo),这是一个完全在设备上运行的神经网络立体模型,针对低纹理表面、重复图案和困难光照等具有挑战性的场景进行了优化。有关更多背景信息,请参阅 LENS 入门帖子DepthAI 3.6.1 性能更新

如何放置

Python

Python
1pipeline = dai.Pipeline()
2neuralDepth = pipeline.create(dai.node.NeuralDepth)

C++

C++
1dai::Pipeline pipeline;
2auto neuralDepth = pipeline.create<dai::node::NeuralDepth>();

输入和输出

模型尺寸

NeuralDepth 支持多种模型尺寸,从高分辨率的 XL 版本到低延迟的实时预设。下面的 FPS 数据反映了 DepthAI 3.6.1 中引入的优化模型。这些新增功能使得根据您的应用程序在深度分辨率、精度和实时性能之间进行权衡更加容易。
模型 分辨率 FPS
NEURAL_DEPTH_1248X780 (NEURAL_DEPTH_EXTRA_LARGE) 1248x780 8.5
NEURAL_DEPTH_1056X660 1056x660 12.5
NEURAL_DEPTH_960X600 960x600 14
NEURAL_DEPTH_864X540 864x540 18
NEURAL_DEPTH_LARGE 768x480 22
NEURAL_DEPTH_MEDIUM 576x360 38
NEURAL_DEPTH_SMALL (默认) 480x300 56
NEURAL_DEPTH_NANO 384x240 85

后处理

NeuralDepth 提供多种后处理选项来提高深度质量:
  • 置信度阈值: 置信度低于此阈值的像素将被视为无效。有效范围为 [0, 255],默认值为 125。
  • 边缘阈值: 边缘幅度低于此值的像素将被视为无效。有效范围为 [0, 255],默认值为 10。
  • 时间滤波器: 对深度值进行时间平均以减少噪声。该滤波器具有以下参数:
    • enable: 布尔值,用于启用/禁用滤波器(默认值:false)
    • alpha: 指数移动平均平滑因子,范围为 [0, 1]。较低的值提供更多的平滑(非常适合静态场景),值为 1.0 时效果相当于直通(默认值:0.4)
    • delta: 视差变化检测的阈值,范围为 [0, 255]。仅当当前帧与前一帧的视差变化低于此值时,才会对该像素进行滤波,否则将禁用该像素的滤波(默认值:100)

畸变校正

NeuralDepth 包含一个内部畸变校正步骤。如果您的输入图像已经过畸变校正,可以使用 setRectification(false) 禁用它。

用法

Python

Python
1import depthai as dai
2
3pipeline = dai.Pipeline()
4
5# 创建单目摄像头
6monoLeft = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
7monoRight = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
8
9# 创建输出
10leftOutput = monoLeft.requestOutput((640, 400))
11rightOutput = monoRight.requestOutput((640, 400))
12
13# 创建 NeuralDepth 节点
14neuralDepth = pipeline.create(dai.node.NeuralDepth)
15neuralDepth.build(leftOutput, rightOutput, dai.DeviceModelZoo.NEURAL_DEPTH_SMALL)
16
17# 配置后处理
18neuralDepth.initialConfig.setConfidenceThreshold(125)
19neuralDepth.initialConfig.setEdgeThreshold(10)
20
21neuralDepth.initialConfig.postProcessing.temporalFilter.enable = True
22neuralDepth.initialConfig.postProcessing.temporalFilter.delta = 100
23neuralDepth.initialConfig.postProcessing.temporalFilter.alpha = 0.4
24
25# 创建输出队列
26depthQueue = neuralDepth.depth.createOutputQueue()

C++

C++
1dai::Pipeline pipeline;
2
3// 创建单目摄像头
4auto monoLeft = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_B);
5auto monoRight = pipeline.create<dai::node::Camera>()->build(dai::CameraBoardSocket::CAM_C);
6
7// 创建输出
8auto leftOutput = monoLeft->requestOutput(std::make_pair(640, 400));
9auto rightOutput = monoRight->requestOutput(std::make_pair(640, 400));
10
11// 创建 NeuralDepth 节点
12auto neuralDepth = pipeline.create<dai::node::NeuralDepth>();
13neuralDepth->build(leftOutput, rightOutput, dai::DeviceModelZoo::NEURAL_DEPTH_SMALL);
14
15// 配置后处理
16neuralDepth->initialConfig.setConfidenceThreshold(125);
17neuralDepth->initialConfig.setEdgeThreshold(10);
18
19neuralDepth->initialConfig.postProcessing.temporalFilter.enable = true;
20neuralDepth->initialConfig.postProcessing.temporalFilter.delta = 100;
21neuralDepth->initialConfig.postProcessing.temporalFilter.alpha = 0.4f;
22
23// 创建输出队列
24auto depthQueue = neuralDepth->depth.createOutputQueue();

功能示例

  • Neural Depth Minimal - 演示基本 NeuralDepth 用法的最小示例,具有视差输出可视化。
  • Neural Depth - 演示具有置信度阈值、边缘阈值和时间过滤运行时配置的 NeuralDepth 节点。
  • Neural Depth RGBD - 将 NeuralDepth 与 RGBD 节点结合以生成点云,可通过远程连接查看。
  • Neural Depth Align - 演示使用 ImageAlign 节点将 NeuralDepth 输出与 RGB 摄像头对齐。

参考

class

dai::node::NeuralDepth

#include NeuralDepth.hpp
variable
std::shared_ptr< NeuralDepthConfig > initialConfig
Initial config to use for NeuralDepth.
variable
Subnode< Sync > sync
variable
Subnode< MessageDemux > messageDemux
variable
Subnode< Rectification > rectification
variable
Subnode< NeuralNetwork > neuralNetwork
variable
Input & left
Input for left ImgFrame of left-right pair
variable
Input & right
Input for right ImgFrame of left-right pair
variable
Output & rectifiedLeft
Output for rectified left ImgFrame
variable
Output & rectifiedRight
Output for rectified right ImgFrame
variable
Input inputConfig
Input config to modify parameters in runtime.
variable
Input nnDataInput
Input NNData to parse
variable
Input leftInternal
Input left frame internal, used to extract frame info
variable
Input rightInternal
Input right frame internal, used to extract frame info
variable
Output disparity
Output disparity ImgFrame
variable
Output depth
Output depth ImgFrame
variable
Output edge
Output edge ImgFrame
variable
Output confidence
Output confidence ImgFrame
function
NeuralDepth()
function
NeuralDepth & setRectification(bool enable)
Enable or disable rectification (useful for prerectified inputs)
function
std::shared_ptr< NeuralDepth > build(Output & left, Output & right, DeviceModelZoo model)
function
void buildInternal()

需要帮助?

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