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

本页目录

  • 如何放置
  • 输入和输出
  • 用法
  • 功能示例
  • 深度对齐
  • 校正 Alpha 缩放
  • 配置相机以实现高帧率
  • 运行时更改相机校准
  • 平台特定配置
  • 参考
Claude CodeCodexCursor
Luxonis 智能体工具包为你常用的编程智能体加载 Luxonis 上下文与技能,更快地基于 OAK 开发应用。
安装工具包

StereoDepth

最后更新
Supported on:RVC2RVC4
StereoDepth 节点根据一对 Camera 节点计算视差和/或深度。

配置立体深度

通过分步配置指南,了解如何获得最佳深度结果。
打开教程
要查看精度测量结果,请参阅 深度精度。

如何放置

Python

Python
1pipeline = dai.Pipeline()
2stereo = pipeline.create(dai.node.StereoDepth)

C++

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

输入和输出

用法

Python

Python
1pipeline = dai.Pipeline()
2stereo = pipeline.create(dai.node.StereoDepth)
3
4# Set profile preset to ROBOTICS
5stereo.setDefaultProfilePreset(dai.node.StereoDepth.PresetMode.ROBOTICS)
6# Better handling for occlusions:
7stereo.setLeftRightCheck(True)
8# Closer-in minimum depth, disparity range is doubled:
9stereo.setExtendedDisparity(True)
10# Better accuracy for longer distance, fractional disparity 32-levels:
11stereo.setSubpixel(True)
12
13# Define and configure MonoCamera nodes beforehand
14left.out.link(stereo.left)
15right.out.link(stereo.right)

C++

C++
1dai::Pipeline pipeline;
2auto stereo = pipeline.create<dai::node::StereoDepth>();
3
4// Set profile preset to ROBOTICS
5stereo->setDefaultProfilePreset(dai::node::StereoDepth::PresetMode.ROBOTICS);
6// Better handling for occlusions:
7stereo->setLeftRightCheck(true);
8// Closer-in minimum depth, disparity range is doubled:
9stereo->setExtendedDisparity(true);
10// Better accuracy for longer distance, fractional disparity 32-levels:
11stereo->setSubpixel(true);
12
13// Define and configure MonoCamera nodes beforehand
14left->out.link(stereo->left);
15right->out.link(stereo->right);

功能示例

深度对齐

图像对齐用于将深度图对齐到特定流。对于 DepthAI v3,默认的立体深度对齐方式是 RECTIFIED_LEFT。
Python
1pipeline = dai.Pipeline()
2stereo = pipeline.create(dai.node.StereoDepth)
3 # alignment to RECTIFIED_LEFT or RECTIFIED_RIGHT
4stereo.setDepthAlign(dai.StereoDepthConfig.AlgorithmControl.DepthAlign.RECTIFIED_LEFT)
或者您可以使用 ImageAlign 节点:
Python
1align = pipeline.create(dai.node.ImageAlign)
2stereo.depth.link(align.input)
3rgbOut.link(align.inputAlignTo)  # Align depth to RGB
4align.outputAligned.link(sync.inputs["depth_aligned"])

校正 Alpha 缩放

StereoDepth 暴露了 setAlphaScaling() 来控制在校正和去畸变过程中裁剪和保留完整视场之间的平衡。这对于宽视场立体对以及直接检查校正输出时特别有用。
  • alphaScaling = 0 只保留校正图像中的有效像素,裁剪更积极。
  • alphaScaling = 1 保留所有源图像像素,保留更多原始视场。
  • 在某些高畸变镜头上,或者当校正旋转图像时,小于 1 的值可以帮助去除剩余的无效边缘区域。

配置相机以实现高帧率

Stereo 节点的性能直接受 MonoCamera 配置的限制。 为了使用 StereoDepth 实现高帧率(例如 60 FPS),MonoCamera 必须配置为以所需速率传输帧。
Python
1with dai.Pipeline(device) as pipeline:
2  stereo = pipeline.create(dai.node.StereoDepth)
3  mono_left = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
4  mono_right = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
5
6  def configure_cam(cam, size_x: int, size_y: int, fps: float):
7    cap = dai.ImgFrameCapability()
8    cap.size.fixed((size_x, size_y))
9    cap.fps.fixed(fps)
10  return cam.requestOutput(cap, True)
11
12  # Configure MonoCameras for 60 FPS at 640x400
13  mono_left_out = configure_cam(mono_left, 640, 400, 60)
14  mono_right_out = configure_cam(mono_right, 640, 400, 60)
从处理的角度来看,在没有 MonoCamera 输入限制的情况下,Stereo 节点本身能够以高达 400 FPS 的速率处理图像对,当在 256×256 像素输入上操作时。 然而,默认情况下,MonoCamera 以 30 FPS 运行,这相应地限制了整体 StereoDepth 输出。

运行时更改相机校准

在运行时更改相机校准是可能的。 可以使用 device.setCalibration() 方法更改校准,并且可以与 动态校准 结合使用,如果设备立体质量由于环境因素而随时间下降。 可以使用 device.getCalibration() 获取相同的数据。

平台特定配置

选择您的平台(RVC2 或 RVC4)以查看平台特定文档、预设、配置选项和限制。

RVC2

StereoDepth 节点内部框图

software/depthai/nodes/depth_diagram.webp

深度预设

我们制作了一些深度预设,可以用于快速设置 StereoDepth 节点以适应不同的场景,而无需手动设置所有参数。 有关所有参数值的详细预设规范,请参阅 配置立体深度。有关 FPS 基准测试,请参阅 深度概述 – RVC2 立体性能。
立体深度预设用例输出分辨率运动模糊范围(米)
Default通用目的1/2 输入分辨率True0–10
Face人脸追踪,生物识别1/2 输入分辨率True0–3
High Detail3D 扫描,物体细节1/2 输入分辨率True0–15
Robotics导航,障碍物检测1/2 输入分辨率False0–15
Fast Accuracy通用目的输入分辨率False0–65
Fast Density通用目的输入分辨率False0–65
Fast Density No Subpixel通用目的输入分辨率False0–65
由于使用抽取滤波器,输出分辨率可能会减半,这意味着如果输入分辨率为 1280x800 (800P),它将减小到 640x400 (400P)。 对于某些深度预设,由于 使用抽取滤波器,输出分辨率可能会有所不同。 默认情况下,所有配置文件预设都开启了亚像素,这会产生更精细的深度细节 但会导致较低的 FPS。对于高 FPS,请关闭亚像素。 配置文件预设“高细节”和“人脸”默认开启了扩展视差。

深度配置

扩展视差

扩展视差模式允许检测给定基线下的更近距离物体。这将最大视差搜索从 96 增加到 191,这意味着范围现在是:[0..190]。
  1. 在原始尺寸图像(例如 1280x720)上计算视差。
  2. 在 2 倍缩小图像(例如 640x360)上计算视差。
  3. 在 Shave 上结合两个级别的视差,有效覆盖总共 191 像素的视差范围(相对于原始分辨率)。
您可以使用 debugExtDispLrCheckIt1 和 debugExtDispLrCheckIt2 调试输出来进行调试/微调。

用法:

Python
1stereo.setExtendedDisparity(True)
注意: 在 RVC2 上,压缩 (costMatching.enableCompanding) 是扩展视差的替代方案:通过压缩,立体模块使用稀疏匹配,因此视差范围扩展到 176 个值,这意味着范围是 [0..175]。匹配在范围的第一部分是密集的(逐像素),对于更高的视差则逐渐稀疏(每隔 2 个像素,然后每隔 4 个像素),并且只有深度输出使用此扩展范围——视差图本身保持在正常范围。

亚像素视差

亚像素模式提高了精度,对于长距离测量特别有用。它还有助于更好地估计表面法线。在此模式下,立体相机执行:94 个深度步长 * 8 个亚像素深度步长 + 2(最小值/最大值)= 754 个深度步长。唯一深度值的数量取决于亚像素小数位数设置:
亚像素小数位数唯一值数量
3754
41506
53010

用法:

Python
1stereo.setSubpixel(True)
2stereo.initialConfig.setSubpixelFractionalBits(3)  # 3, 4 或 5

左右检查

左右检查或 LR-Check 用于消除由于物体边界处的遮挡而导致的错误计算的视差像素(左右相机视图略有不同)。
  1. 通过 R->L 方向匹配计算视差。
  2. 通过 L->R 方向匹配计算视差。
  3. 结合步骤 1 和 2 的结果,在 Shave 上运行:将每个像素 d = disparity_LR(x,y) 与 disparity_RL(x-d,y) 进行比较。如果差异超过阈值,则最终视差图中的 (x,y) 处的像素将失效。
您可以使用 debugDispLrCheckIt1 和 debugDispLrCheckIt2 调试输出来进行调试/微调。LR 检查阈值:当 LR 和 RL 视差之间的差异小于 LR 检查阈值时,视差被视为输出。

用法:

Python
1stereo.setLeftRightCheck(True)
2stereo.initialConfig.setLeftRightCheckThreshold(4)  # 设置阈值

置信度阈值

置信度阈值:立体深度算法从右相机点到左图像(沿 96 个视差级别)搜索匹配特征。在此过程中,它计算每个视差级别的成本,并选择两个视差之间的最小成本,并用它来计算每个像素的置信度。立体节点将仅在深度置信度低于置信度阈值(置信度值越低表示深度精度越好)时输出视差/深度像素。置信度分数是反向的:
  • 0 - 最大置信度,表示它包含有效值
  • 255 - 最小置信度,因此值不正确的可能性更大

用法:

Python
1stereo.initialConfig.setConfidenceThreshold(200)  # 值越低 = 精度越高,填充率越低

中值滤波器

这是一种非边缘保留中值滤波器,可用于减少噪声并平滑深度图。中值滤波器在硬件中实现,因此它是最快的滤波器。注意:当亚像素模式设置为 4 或 5 位时,中值滤波被禁用。

用法:

Python
1stereo.initialConfig.setMedianFilter(dai.MedianFilter.KERNEL_7x7)  # 选项:MEDIAN_OFF, KERNEL_3x3, KERNEL_5x5, KERNEL_7x7

斑点滤波器

斑点滤波器用于减少斑点噪声。斑点噪声是相邻视差/深度像素之间方差很大的区域,斑点滤波器试图过滤掉这个区域。

用法:

Python
1stereo.initialConfig.postProcessing.speckleFilter.enable = True
2stereo.initialConfig.postProcessing.speckleFilter.speckleRange = 48

时间滤波器

时间滤波器旨在通过根据前一帧操纵每个像素值来提高深度数据的持久性。该滤波器对数据执行单次通过,调整深度值,同时更新跟踪历史。在像素数据缺失或无效的情况下,滤波器使用用户定义的持久性模式来决定是否应使用存储的数据改进缺失值。请注意,由于其对历史数据的依赖,该滤波器可能会引入明显的运动模糊/拖影伪影,因此最适合静态场景。

用法:

Python
1stereo.initialConfig.postProcessing.temporalFilter.enable = True
2stereo.initialConfig.postProcessing.temporalFilter.alpha = 0.4  # 当前帧的权重 (0-1)
3stereo.initialConfig.postProcessing.temporalFilter.delta = 3  # 有效深度变化的阈值

空间滤波器

空间边缘保留滤波器将用有效的相邻深度像素填充无效深度像素。它执行一系列一维水平和垂直通过或迭代,以增强重建数据的平滑度。它基于 这篇研究论文。

用法:

Python
1stereo.initialConfig.postProcessing.spatialFilter.enable = True
2stereo.initialConfig.postProcessing.spatialFilter.alpha = 0.5  # 边缘保留强度
3stereo.initialConfig.postProcessing.spatialFilter.delta = 8  # 有效深度变化的阈值
4stereo.initialConfig.postProcessing.spatialFilter.holeFillingRadius = 2  # 孔洞填充半径
5stereo.initialConfig.postProcessing.spatialFilter.numIterations = 1  # 迭代次数

亮度滤波器

亮度滤波器将过滤掉(通过设置为 0 使其无效)所有输入立体相机图像像素超出配置的最小/最大亮度阈值范围的深度像素。当您处于高动态范围场景(例如晴朗的户外)或通常当立体相机可以直接看到光源时,此滤波器非常有用。它还有助于校正“伪影”,特别是当您使用广角镜头并应用 alpha 参数时。

用法:

Python
1stereo.initialConfig.postProcessing.brightnessFilter.enable = True
2stereo.initialConfig.postProcessing.brightnessFilter.minBrightness = 0  # 最小亮度阈值
3stereo.initialConfig.postProcessing.brightnessFilter.maxBrightness = 255  # 最大亮度阈值

阈值滤波器

阈值滤波器将过滤掉所有超出配置的最小/最大阈值范围的深度像素。在受控环境中,如果您确切知道场景的距离(例如 30 厘米 - 2 米),建议使用此滤波器。

用法:

Python
1stereo.initialConfig.postProcessing.thresholdFilter.minRange = 0  # 最小深度(厘米)
2stereo.initialConfig.postProcessing.thresholdFilter.maxRange = 200  # 最大深度(厘米)

抽取滤波器

抽取滤波器将对深度图进行子采样,这意味着它降低了深度场景的复杂性,并允许其他滤波器运行得更快。将 decimationFactor 设置为 2 将把 1280x800 的深度图缩小到 640x400。我们可以选择像素跳过、中值或均值抽取模式,后两种模式也有助于滤波。decimationFactor 为 1 时禁用滤波器。

用法:

Python
1stereo.initialConfig.postProcessing.decimationFilter.decimationFactor = 2  # 1 = 禁用,2 = 2 倍缩小,等等。

过滤顺序

过滤器的顺序很重要,因为一个滤波器的输出是下一个滤波器的输入。过滤器的顺序是可定制的:用法:
Python
1config.postProcessing.filteringOrder = [
2    dai.RawStereoDepthConfig.PostProcessing.Filter.TEMPORAL,
3    dai.RawStereoDepthConfig.PostProcessing.Filter.SPECKLE,
4    dai.RawStereoDepthConfig.PostProcessing.Filter.SPATIAL,
5    dai.RawStereoDepthConfig.PostProcessing.Filter.MEDIAN,
6    dai.RawStereoDepthConfig.PostProcessing.Filter.DECIMATION
7]
8stereo.initialConfig.set(config)

限制

  • 当亚像素模式设置为 4 或 5 位时,中值滤波被禁用。
  • 对于 RGB-深度对齐,RGB 相机必须与立体相机对齐在同一水平线上。
  • 当使用视差偏移时,RGB-深度对齐不起作用。

RVC4

StereoDepth 节点内部框图

StereoDepth 内部框图 (RVC4)

深度预设

有关所有参数值的详细预设规范,请参阅 配置立体深度。 有关 FPS 和延迟基准,请参阅 深度概述 – RVC4 立体性能。

深度配置

Alpha 缩放

在 RVC4 上,setAlphaScaling() 控制 StereoDepth 使用的校正和去畸变缩放。RVC4 现在在去畸变过程中一致地应用此缩放,因此校正后的输出遵循此处描述的相同裁剪与 FOV 权衡。
  • alphaScaling = 0 仅保留校正图像中的有效像素,裁剪更激进。
  • alphaScaling = 1 保留所有源图像像素,保留更多原始视场。
  • 在某些高畸变镜头上,或当校正旋转图像时,低于 0 的值有助于去除剩余的无效边缘区域。

用法:

Python
1stereo.setAlphaScaling(0.0)

扩展视差

扩展视差模式允许检测给定基线下的更近/更近的物体。这将最大视差搜索从 64 增加到 128,这意味着范围现在是:[0..127]。
  1. 在原始大小图像(例如 1280x800)上计算视差。
  2. 在 2 倍缩小图像(例如 640x400)上计算视差。
  3. 组合两个级别的视差。

用法:

Python
1stereo.setExtendedDisparity(True)

亚像素视差

亚像素模式提高了视差精度,对于远距离深度测量特别有用。 它还可以实现更准确的表面法线估计。在 RVC4 上,亚像素处理默认启用且无法禁用,因为它已在硬件中固定。 实现使用 4 个小数位。

左右检查

左右检查(LR-Check)用于去除由于物体边界处的遮挡而导致的错误计算的视差像素(左右相机视图略有不同)。在 RVC4 上,LR Check 纯粹在 CPU 上以软件方式运行。左右检查阈值:像素之间允许的最大视差差异。值越小,深度越稀疏(更多像素失效)。

用法:

Python
1stereo.initialConfig.algorithmControl.enableSwLeftRightCheck = True
2stereo.initialConfig.algorithmControl.leftRightCheckThreshold = 10  # 设置阈值
注意:RVC4 有一个不同的内部机制,它基本上执行 LR 检查功能——这就是遮挡置信度权重(参见下面的置信度指标部分)。遮挡置信度权重比较从左到右和从右到左搜索的视差差异,这本质上就是 LR 检查所做的。

软件置信度

软件置信度滤波器获取视差和置信度图(来自立体硬件块的每像素 8 位置信度),并应用阈值来过滤掉低置信度像素。 此过滤在 CPU 上完成,并在硬件块生成视差后应用。此过滤在 CPU 上执行,并在硬件块生成视差后应用。 当启用左右(LR)检查时,L→R 和 R→L 视差(及其相应的置信度图)都使用相同的阈值失效。值:
  • 有限过滤:50-100
  • 中等过滤:200
  • 强过滤:>200(非常依赖场景)

用法:

Python
1stereo.initialConfig.costMatching.enableSwConfidenceThresholding = True
2stereo.initialConfig.costMatching.confidenceThreshold = 200  # 根据所需的过滤级别进行调整

置信度指标(遮挡、运动矢量、平坦度)

使用三个不同的指标来计算置信度图,这些指标加在一起形成一个最终的置信度图。
  • 遮挡置信度权重
    • 基本上执行 LR 检查。比较从左到右和从右到左搜索的视差差异(前向/后向运动矢量一致性)。
  • 运动矢量(MV)置信度权重
    • MV 方差计算每个像素周围局部边缘感知窗口中的方差;给定一个约束以确保深度在同一物体内平滑且一致。
    • MV 置信度阈值:MV 方差的阈值偏移。有效范围 [0,3]。值 = 0 允许最大方差。
  • 平坦度置信度权重
    • 平坦度考虑输入图像纹理并屏蔽掉具有过于相似相邻特征的低纹理区域。所需纹理的最小量可以通过平坦度阈值进行调整。
    • 平坦度阈值:平坦区域检查的阈值。值越高,像素越有可能根据普查特征比较被检测为平坦区域。用于没有足够特征进行匹配的低纹理区域。
    • 平坦度覆盖:如果像素被检测为平坦,则将置信度设置为零。

用法:

Python
1# 置信度指标权重(RVC4 必须总和为 32)
2stereo.initialConfig.confidenceMetrics.occlusionConfidenceWeight = 12
3stereo.initialConfig.confidenceMetrics.motionVectorConfidenceWeight = 10
4stereo.initialConfig.confidenceMetrics.flatnessConfidenceWeight = 10
5
6# 阈值
7stereo.initialConfig.confidenceMetrics.motionVectorConfidenceThreshold = 1  # 有效范围 [0,3]
8stereo.initialConfig.confidenceMetrics.flatnessConfidenceThreshold = 5
9stereo.initialConfig.confidenceMetrics.flatnessOverride = True  # 如果平坦,则将置信度设置为零
注意:RVC4 的置信度指标权重必须总和为 32。

自适应中值滤波器

自适应中值滤波器仅对低于指定阈值的低置信度像素应用滤波器。自适应中值滤波器阈值:仅对低于此值的低置信度像素应用滤波器。此阈值应小于孔填充中的填充置信度阈值。

用法:

Python
1stereo.initialConfig.postProcessing.adaptiveMedianFilter.enable = True
2stereo.initialConfig.postProcessing.adaptiveMedianFilter.confidenceThreshold = 200  # 应 < 孔填充 fillConfidenceThreshold

孔填充

孔填充是一种后处理滤波器,通过将像素分组为超像素(六边形区域)并根据这些区域内的高置信度像素计算视差值来填充深度图中的间隙。此滤波器修改置信度图以标记填充区域。该滤波器的工作原理是:
  1. 将像素分组为超像素(六边形区域)
  2. 使用置信度高于高置信度阈值的像素来计算每个超像素的视差值
  3. 根据填充置信度阈值和最小有效视差要求填充孔
参数:
  • 高置信度阈值 - 置信度高于此阈值的像素用于计算每个超像素的视差值。如果设置为最大值(255),则不应形成超像素。
  • 填充置信度阈值 - 置信度低于此值的像素将被过滤掉(如果 invalidateDisparities 设置为 True)或成为超像素计算的一部分。
  • 最小有效视差 - 决定区域中需要有多少比例的像素具有高于高置信度阈值的置信度才能包含在计算超像素的视差中。值:1 (50%)、2 (25%) 或 3 (12.5%)。最小有效视差越高,超像素越大(六边形越多)。
  • 使视差失效 - 如果设置为 True,则置信度低于填充置信度阈值的像素将从最终视差图中过滤掉。

用法:

Python
1stereo.initialConfig.postProcessing.holeFilling.enable = True
2stereo.initialConfig.postProcessing.holeFilling.highConfidenceThreshold = 200
3stereo.initialConfig.postProcessing.holeFilling.fillConfidenceThreshold = 210
4stereo.initialConfig.postProcessing.holeFilling.minValidDisparity = 1  # 1, 2, or 3
5stereo.initialConfig.postProcessing.holeFilling.invalidateDisparities = True

中值滤波器

这是一种非边缘保留中值滤波器,可用于减少噪声并平滑深度图。在 RVC4 上:中值滤波器在软件(CPU)中实现,并且仅支持 3x3 或 5x5 内核大小。如果请求 7x7,它会自动降级为 5x5。

用法:

Python
1stereo.initialConfig.setMedianFilter(dai.MedianFilter.KERNEL_3x3)  # 选项:MEDIAN_OFF, KERNEL_3x3, KERNEL_5x5

斑点滤波器

斑点滤波器用于减少斑点噪声。斑点噪声是相邻视差/深度像素之间方差很大的区域,斑点滤波器试图过滤掉这个区域。

用法:

Python
1stereo.initialConfig.postProcessing.speckleFilter.enable = True
2stereo.initialConfig.postProcessing.speckleFilter.speckleRange = 48

时间滤波器

时间滤波器旨在通过根据前一帧操纵每像素值来提高深度数据的持久性。该滤波器对数据执行单次通过,调整深度值,同时更新跟踪历史。在像素数据缺失或无效的情况下,滤波器使用用户定义的持久性模式来决定是否应使用存储的数据改进缺失值。请注意,由于其依赖于历史数据,该滤波器可能会引入可见的运动模糊/拖影伪影,因此最适合静态场景。

用法:

Python
1stereo.initialConfig.postProcessing.temporalFilter.enable = True
2stereo.initialConfig.postProcessing.temporalFilter.alpha = 0.4  # 当前帧的权重 (0-1)
3stereo.initialConfig.postProcessing.temporalFilter.delta = 3  # 有效深度变化的阈值

空间滤波器

空间边缘保留滤波器将用有效的相邻深度像素填充无效深度像素。它执行一系列一维水平和垂直通过或迭代,以增强重建数据的平滑度。它基于 这篇研究论文。

用法:

Python
1stereo.initialConfig.postProcessing.spatialFilter.enable = True
2stereo.initialConfig.postProcessing.spatialFilter.alpha = 0.5  # 边缘保留强度
3stereo.initialConfig.postProcessing.spatialFilter.delta = 8  # 有效深度变化的阈值
4stereo.initialConfig.postProcessing.spatialFilter.holeFillingRadius = 2  # 孔填充半径
5stereo.initialConfig.postProcessing.spatialFilter.numIterations = 1  # 迭代次数

亮度滤波器

亮度滤波器将过滤掉(通过设置为 0 使其失效)所有深度像素,这些像素的输入立体相机图像像素超出配置的最小/最大亮度阈值。当您有高动态范围场景时,例如在晴朗的白天室外,或者通常当立体相机可以直接看到光源时,此滤波器很有用。它还有助于校正“伪影”,特别是当您有广角 FOV 镜头并应用 alpha 参数时。

用法:

Python
1stereo.initialConfig.postProcessing.brightnessFilter.enable = True
2stereo.initialConfig.postProcessing.brightnessFilter.minBrightness = 0  # 最小亮度阈值
3stereo.initialConfig.postProcessing.brightnessFilter.maxBrightness = 255  # 最大亮度阈值

阈值滤波器

阈值滤波器将过滤掉所有超出配置的最小/最大阈值范围的深度像素。在受控环境中,如果您确切知道场景的距离(例如 30 厘米 - 2 米),建议使用此滤波器。

用法:

Python
1stereo.initialConfig.postProcessing.thresholdFilter.minRange = 0  # 最小深度(厘米)
2stereo.initialConfig.postProcessing.thresholdFilter.maxRange = 200  # 最大深度(厘米)

抽取滤波器

抽取滤波器将对深度图进行子采样,这意味着它减少了深度场景的复杂性,并允许其他滤波器运行得更快。将 decimationFactor 设置为 2 将把 1280x800 深度图缩小到 640x400。我们可以选择像素跳过、中值或均值抽取模式,后两种模式也有助于过滤。decimationFactor 1 禁用滤波器。

用法:

Python
1stereo.initialConfig.postProcessing.decimationFilter.decimationFactor = 2  # 1 = 禁用,2 = 2 倍缩小,等等。

过滤顺序

滤波器的顺序很重要,因为一个滤波器的输出是下一个滤波器的输入。滤波器的顺序是可定制的:

用法:

Python
1config.postProcessing.filteringOrder = [
2    dai.RawStereoDepthConfig.PostProcessing.Filter.TEMPORAL,
3    dai.RawStereoDepthConfig.PostProcessing.Filter.SPECKLE,
4    dai.RawStereoDepthConfig.PostProcessing.Filter.SPATIAL,
5    dai.RawStereoDepthConfig.PostProcessing.Filter.MEDIAN,
6    dai.RawStereoDepthConfig.PostProcessing.Filter.DECIMATION
7]
8stereo.initialConfig.set(config)

限制

  • 中值滤波器:在 RVC4 上,中值滤波器在软件(CPU)中实现,并且仅支持 3x3 或 5x5 内核大小。如果请求 7x7,它会自动降级为 5x5。
  • 亚像素:在 RVC4 上固定为 4 位(不能更改为 3 或 5 位)。
  • LR 检查:纯粹在 CPU 上以软件方式运行(不像 RVC2 那样硬件加速)。

参考

class

dai::node::StereoDepth

#include StereoDepth.hpp
using
MedianFilter = dai::StereoDepthConfig::MedianFilter
variable
std::shared_ptr< StereoDepthConfig > initialConfig
Initial config to use for StereoDepth.
variable
Input inputConfig
Input StereoDepthConfig message with ability to modify parameters in runtime.
variable
Input inputAlignTo
Input align to message. Default queue is non-blocking with size 1.
variable
Input left
Input for left ImgFrame of left-right pair
variable
Input right
Input for right ImgFrame of left-right pair
variable
Output depth
Outputs ImgFrame message that carries RAW16 encoded (0..65535) depth data in depth units (millimeter by default).Non-determined / invalid depth values are set to 0
variable
Output disparity
Outputs ImgFrame message that carries RAW8 / RAW16 encoded disparity data: RAW8 encoded (0..95) for standard mode; RAW8 encoded (0..190) for extended disparity mode; RAW16 encoded for subpixel disparity mode:
  • 0..760 for 3 fractional bits (by default)
  • 0..1520 for 4 fractional bits
  • 0..3040 for 5 fractional bits
variable
Output syncedLeft
Passthrough ImgFrame message from 'left' Input.
variable
Output syncedRight
Passthrough ImgFrame message from 'right' Input.
variable
Output rectifiedLeft
Outputs ImgFrame message that carries RAW8 encoded (grayscale) rectified frame data.
variable
Output rectifiedRight
Outputs ImgFrame message that carries RAW8 encoded (grayscale) rectified frame data.
variable
Output outConfig
Outputs StereoDepthConfig message that contains current stereo configuration.
variable
Output debugDispLrCheckIt1
Outputs ImgFrame message that carries left-right check first iteration (before combining with second iteration) disparity map. Useful for debugging/fine tuning.
variable
Output debugDispLrCheckIt2
Outputs ImgFrame message that carries left-right check second iteration (before combining with first iteration) disparity map. Useful for debugging/fine tuning.
variable
Output debugExtDispLrCheckIt1
Outputs ImgFrame message that carries extended left-right check first iteration (downscaled frame, before combining with second iteration) disparity map. Useful for debugging/fine tuning.
variable
Output debugExtDispLrCheckIt2
Outputs ImgFrame message that carries extended left-right check second iteration (downscaled frame, before combining with first iteration) disparity map. Useful for debugging/fine tuning.
variable
Output debugDispCostDump
Outputs ImgFrame message that carries cost dump of disparity map. Useful for debugging/fine tuning.
variable
Output confidenceMap
Outputs ImgFrame message that carries RAW8 confidence map. Lower values mean lower confidence of the calculated disparity value. RGB alignment, left-right check or any postprocessing (e.g., median filter) is not performed on confidence map.
function
StereoDepth()
inline function
std::shared_ptr< StereoDepth > build(Node::Output & left, Node::Output & right, PresetMode presetMode)
function
std::shared_ptr< StereoDepth > build(bool autoCreateCameras, PresetMode presetMode, const std::pair< int, int > & size, std::optional< float > fps)
Create StereoDepth node. Note that this API is global and if used autocreated cameras can't be reused.
Parameters
  • autoCreateCameras: If true, will create left and right nodes if they don't exist
  • presetMode: Preset mode for stereo depth
function
void loadMeshFiles(const std::filesystem::path & pathLeft, const std::filesystem::path & pathRight)
Specify local filesystem paths to the mesh calibration files for 'left' and 'right' inputs.When a mesh calibration is set, it overrides the camera intrinsics/extrinsics matrices. Overrides useHomographyRectification behavior. Mesh format: a sequence of (y,x) points as 'float' with coordinates from the input image to be mapped in the output. The mesh can be subsampled, configured by setMeshStep.With a 1280x800 resolution and the default (16,16) step, the required mesh size is:width: 1280 / 16 + 1 = 81height: 800 / 16 + 1 = 51
function
void loadMeshData(const std::vector< std::uint8_t > & dataLeft, const std::vector< std::uint8_t > & dataRight)
Specify mesh calibration data for 'left' and 'right' inputs, as vectors of bytes. Overrides useHomographyRectification behavior. See loadMeshFiles for the expected data format
function
void setMeshStep(int width, int height)
Set the distance between mesh points. Default: (16, 16)
function
void setInputResolution(int width, int height)
Specify input resolution sizeOptional if MonoCamera exists, otherwise necessary
function
void setInputResolution(const std::tuple< int, int > & resolution)
Specify input resolution sizeOptional if MonoCamera exists, otherwise necessary
function
void setOutputSize(int width, int height)
Specify disparity/depth output resolution size, implemented by scaling.Currently only applicable when aligning to RGB camera
function
void setOutputKeepAspectRatio(bool keep)
Specifies whether the frames resized by setOutputSize should preserve aspect ratio, with potential cropping when enabled. Default true
function
void setDepthAlign(Properties::DepthAlign align)
Parameters
  • align: Set the disparity/depth alignment: centered (between the 'left' and 'right' inputs), or from the perspective of a rectified output stream
function
void setDepthAlign(CameraBoardSocket camera)
Parameters
  • camera: Set the camera from whose perspective the disparity/depth will be aligned
function
void setRectification(bool enable)
Rectify input images or not.
function
void setLeftRightCheck(bool enable)
Computes and combines disparities in both L-R and R-L directions, and combine them.For better occlusion handling, discarding invalid disparity values
function
void setSubpixel(bool enable)
Computes disparity with sub-pixel interpolation (3 fractional bits by default).Suitable for long range. Currently incompatible with extended disparity
function
void setSubpixelFractionalBits(int subpixelFractionalBits)
Number of fractional bits for subpixel mode. Default value: 3. Valid values: 3,4,5. Defines the number of fractional disparities: 2^x. Median filter postprocessing is supported only for 3 fractional bits.
function
void setExtendedDisparity(bool enable)
Disparity range increased from 0-95 to 0-190, combined from full resolution and downscaled images.Suitable for short range objects. Currently incompatible with sub-pixel disparity
function
void setRectifyEdgeFillColor(int color)
Fill color for missing data at frame edges
Parameters
  • color: Grayscale 0..255, or -1 to replicate pixels
function
void setRuntimeModeSwitch(bool enable)
Enable runtime stereo mode switch, e.g. from standard to LR-check. Note: when enabled resources allocated for worst case to enable switching to any mode.
function
void setNumFramesPool(int numFramesPool)
Specify number of frames in pool.
Parameters
  • numFramesPool: How many frames should the pool have
function
void setPostProcessingHardwareResources(int numShaves, int numMemorySlices)
Specify allocated hardware resources for stereo depth. Suitable only to increase post processing runtime.
Parameters
  • numShaves: Number of shaves.
  • numMemorySlices: Number of memory slices.
function
void setDefaultProfilePreset(PresetMode mode)
Sets a default preset based on specified option.
Parameters
  • mode: Stereo depth preset mode
Warning
If using alpha scaling on RVC4 the DEFAULT, DENSITY, and FAST_DENSITY presets can produce inaccurate depth in black padded regions, as they prioritize coverage.
function
void useHomographyRectification(bool useHomographyRectification)
Use 3x3 homography matrix for stereo rectification instead of sparse mesh generated on device. Default behaviour is AUTO, for lenses with FOV over 85 degrees sparse mesh is used, otherwise 3x3 homography. If custom mesh data is provided through loadMeshData or loadMeshFiles this option is ignored.
Parameters
  • useHomographyRectification: true: 3x3 homography matrix generated from calibration data is used for stereo rectification, can't correct lens distortion. false: sparse mesh is generated on-device from calibration data with mesh step specified with setMeshStep (Default: (16, 16)), can correct lens distortion. Implementation for generating the mesh is same as opencv's initUndistortRectifyMap function. Only the first 8 distortion coefficients are used from calibration data.
function
void enableDistortionCorrection(bool enableDistortionCorrection)
Equivalent to useHomographyRectification(!enableDistortionCorrection)
function
void setFrameSync(bool enableFrameSync)
Whether to enable frame syncing inside stereo node or not. Suitable if inputs are known to be synced.
function
void setBaseline(float baseline)
Override baseline from calibration. Used only in disparity to depth conversion. Units are centimeters.
function
void setFocalLength(float focalLength)
Override focal length from calibration. Used only in disparity to depth conversion. Units are pixels.
function
void setDisparityToDepthUseSpecTranslation(bool specTranslation)
Use baseline information for disparity to depth conversion from specs (design data) or from calibration. Default: true
function
void setRectificationUseSpecTranslation(bool specTranslation)
Obtain rectification matrices using spec translation (design data) or from calibration in calculations. Should be used only for debugging. Default: false
function
void setDepthAlignmentUseSpecTranslation(bool specTranslation)
Use baseline information for depth alignment from specs (design data) or from calibration. Default: true
function
void setAlphaScaling(float alpha)
Free scaling parameter between 0 (when all the pixels in the undistorted image are valid) and 1 (when all the source image pixels are retained in the undistorted image). On some high distortion lenses, and/or due to rectification (image rotated) invalid areas may appear even with alpha=0, in these cases alpha < 0.0 helps removing invalid areas. See getOptimalNewCameraMatrix from opencv for more details.
enum

std::uint32_t PresetMode

Preset modes for stereo depth.
enumerator
FAST_ACCURACY
DeprecatedThis mode is deprecated and will be removed in a future release. Prefers accuracy over density. More invalid depth values, but less outliers. This mode does not turn on any post-processing and is light on resources.
enumerator
FAST_DENSITY
DeprecatedThis mode is deprecated and will be removed in a future release. Prefers density over accuracy. Less invalid depth values, but more outliers. This mode does not turn on any post-processing and is light on resources.
enumerator
DEFAULT
enumerator
FACE
enumerator
HIGH_DETAIL
enumerator
ROBOTICS
enumerator
DENSITY
enumerator
ACCURACY
class

dai::StereoDepthConfig

#include StereoDepthConfig.hpp
using
MedianFilter = filters::params::MedianFilter
variable
AlgorithmControl algorithmControl
Controls the flow of stereo algorithm - left-right check, subpixel etc.
variable
PostProcessing postProcessing
Controls the postprocessing of disparity and/or depth map.
variable
CensusTransform censusTransform
Census transform settings.
variable
CostMatching costMatching
Cost matching settings.
variable
CostAggregation costAggregation
Cost aggregation settings.
variable
ConfidenceMetrics confidenceMetrics
Confidence metrics settings. RVC4 only.
variable
dai::ProcessorType filtersBackend
Compute backend for post-processing filters. RVC4 only.
function
StereoDepthConfig()
Construct StereoDepthConfig message.
function
~StereoDepthConfig()
function
StereoDepthConfig & setDepthAlign(AlgorithmControl::DepthAlign align)
Parameters
  • align: Set the disparity/depth alignment: centered (between the 'left' and 'right' inputs), or from the perspective of a rectified output stream
function
StereoDepthConfig & setConfidenceThreshold(int confThr)
Confidence threshold for disparity calculation
Parameters
  • confThr: Confidence threshold value 0..255
function
int getConfidenceThreshold()
Get confidence threshold for disparity calculation
function
StereoDepthConfig & setMedianFilter(MedianFilter median)
Parameters
  • median: Set kernel size for disparity/depth median filtering, or disable
function
MedianFilter getMedianFilter()
Get median filter setting
function
StereoDepthConfig & setBilateralFilterSigma(uint16_t sigma)
A larger value of the parameter means that farther colors within the pixel neighborhood will be mixed together, resulting in larger areas of semi-equal color.
Parameters
  • sigma: Set sigma value for 5x5 bilateral filter. 0..65535
function
uint16_t getBilateralFilterSigma()
Get sigma value for 5x5 bilateral filter
function
StereoDepthConfig & setLeftRightCheckThreshold(int threshold)
Parameters
  • threshold: Set threshold for left-right, right-left disparity map combine, 0..255
function
int getLeftRightCheckThreshold()
Get threshold for left-right check combine
function
StereoDepthConfig & setLeftRightCheck(bool enable)
Computes and combines disparities in both L-R and R-L directions, and combine them.For better occlusion handling, discarding invalid disparity values
function
bool getLeftRightCheck()
Get left-right check setting
function
StereoDepthConfig & setExtendedDisparity(bool enable)
Disparity range increased from 95 to 190, combined from full resolution and downscaled images. Suitable for short range objects
function
bool getExtendedDisparity()
Get extended disparity setting
function
StereoDepthConfig & setSubpixel(bool enable)
Computes disparity with sub-pixel interpolation (3 fractional bits by default).Suitable for long range. Currently incompatible with extended disparity
function
bool getSubpixel()
Get subpixel setting
function
StereoDepthConfig & setSubpixelFractionalBits(int subpixelFractionalBits)
Number of fractional bits for subpixel mode. Default value: 3. Valid values: 3,4,5. Defines the number of fractional disparities: 2^x. Median filter postprocessing is supported only for 3 fractional bits.
function
int getSubpixelFractionalBits()
Get number of fractional bits for subpixel mode
function
StereoDepthConfig & setDepthUnit(AlgorithmControl::DepthUnit depthUnit)
Set depth unit of depth map.Meter, centimeter, millimeter, inch, foot or custom unit is available.
function
AlgorithmControl::DepthUnit getDepthUnit()
Get depth unit of depth map.
function
StereoDepthConfig & setCustomDepthUnitMultiplier(float multiplier)
Set custom depth unit multiplier relative to 1 meter.
function
float getCustomDepthUnitMultiplier()
Get custom depth unit multiplier relative to 1 meter.
function
StereoDepthConfig & setDisparityShift(int disparityShift)
Shift input frame by a number of pixels to increase minimum depth. For example shifting by 48 will change effective disparity search range from (0,95] to [48,143]. An alternative approach to reducing the minZ. We normally only recommend doing this when it is known that there will be no objects farther away than MaxZ, such as having a depth camera mounted above a table pointing down at the table surface.
function
StereoDepthConfig & setNumInvalidateEdgePixels(int32_t numInvalidateEdgePixels)
Invalidate X amount of pixels at the edge of disparity frame. For right and center alignment X pixels will be invalidated from the right edge, for left alignment from the left edge.
function
StereoDepthConfig & setFiltersComputeBackend(dai::ProcessorType filtersBackend)
Set filters compute backend RVC4 only.
function
dai::ProcessorType getFiltersComputeBackend()
Get filters compute backend RVC4 only.
function
float getMaxDisparity()
Useful for normalization of the disparity map.
Returns
Maximum disparity value that the node can return
function
void serialize(std::vector< std::uint8_t > & metadata, DatatypeEnum & datatype)
inline function
DatatypeEnum getDatatype()
Get the datatype of this specific message.
Returns
DatatypeEnum
function
struct

dai::StereoDepthConfig::AlgorithmControl

using
DepthUnit = dai::DepthUnit
variable
DepthAlign depthAlign
Set the disparity/depth alignment to the perspective of a rectified output, or center it
variable
DepthUnit depthUnit
Measurement unit for depth data. Depth data is integer value, multiple of depth unit.
variable
float customDepthUnitMultiplier
Custom depth unit multiplier, if custom depth unit is enabled, relative to 1 meter. A multiplier of 1000 effectively means depth unit in millimeter.
variable
bool enableLeftRightCheck
Computes and combines disparities in both L-R and R-L directions, and combine them. For better occlusion handling
variable
bool enableSwLeftRightCheck
Enables software left right check. RVC4 only.
variable
bool enableExtended
Disparity range increased from 95 to 190, combined from full resolution and downscaled images. Suitable for short range objects
variable
bool enableSubpixel
Computes disparity with sub-pixel interpolation (5 fractional bits), suitable for long range RVC2 only.
variable
std::int32_t leftRightCheckThreshold
Left-right check threshold for left-right, right-left disparity map combine, 0..128 Used only when left-right check mode is enabled. Defines the maximum difference between the confidence of pixels from left-right and right-left confidence maps
variable
std::int32_t subpixelFractionalBits
Number of fractional bits for subpixel modeValid values: 3,4,5Defines the number of fractional disparities: 2^xMedian filter postprocessing is supported only for 3 fractional bits RVC2 only.
variable
std::int32_t disparityShift
Shift input frame by a number of pixels to increase minimum depth. For example shifting by 48 will change effective disparity search range from (0,95] to [48,143]. An alternative approach to reducing the minZ. We normally only recommend doing this when it is known that there will be no objects farther away than MaxZ, such as having a depth camera mounted above a table pointing down at the table surface. RVC2 only.
variable
std::optional< float > centerAlignmentShiftFactor
variable
std::int32_t numInvalidateEdgePixels
Invalidate X amount of pixels at the edge of disparity frame. For right and center alignment X pixels will be invalidated from the right edge, for left alignment from the left edge. RVC2 only.
function
enum

int32_t DepthAlign

Align the disparity/depth to the perspective of a rectified output, or center it
enumerator
AUTO
enumerator
RECTIFIED_RIGHT
enumerator
RECTIFIED_LEFT
enumerator
CENTER
enumerator
RIGHT
enumerator
LEFT
struct

dai::StereoDepthConfig::CensusTransform

#include StereoDepthConfig.hpp
variable
KernelSize kernelSize
Census transform kernel size. RVC2 only.
variable
uint64_t kernelMask
Census transform mask, default - auto, mask is set based on resolution and kernel size. Disabled for 400p input resolution. Enabled for 720p. 0XA82415 for 5x5 census transform kernel. 0XAA02A8154055 for 7x7 census transform kernel. 0X2AA00AA805540155 for 7x9 census transform kernel. Empirical values. RVC2 only.
variable
bool enableMeanMode
If enabled, each pixel in the window is compared with the mean window value instead of the central pixel. RVC2 only.
variable
uint32_t threshold
Census transform comparison threshold value. RVC2 only.
variable
int8_t noiseThresholdOffset
Used to reduce small fixed levels of noise across all luminance values in the current image. Valid range is [0,127]. Default value is 1. RVC4 only.
variable
int8_t noiseThresholdScale
Used to reduce noise values that increase with luminance in the current image. Valid range is [-128,127]. Default value is 1. RVC4 only.
function
enum

std::int32_t KernelSize

Census transform kernel size possible values.
enumerator
AUTO
enumerator
KERNEL_5x5
enumerator
KERNEL_7x7
enumerator
KERNEL_7x9
struct

dai::StereoDepthConfig::ConfidenceMetrics

#include StereoDepthConfig.hpp
variable
uint8_t occlusionConfidenceWeight
Weight used with occlusion estimation to generate final confidence map. Valid range is [0,32]
variable
uint8_t motionVectorConfidenceWeight
Weight used with local neighborhood motion vector variance estimation to generate final confidence map. Valid range is [0,32].
variable
uint8_t motionVectorConfidenceThreshold
Threshold offset for MV variance in confidence generation. A value of 0 allows most variance. Valid range is [0,3].
variable
uint8_t flatnessConfidenceWeight
Weight used with flatness estimation to generate final confidence map. Valid range is [0,32].
variable
uint8_t flatnessConfidenceThreshold
Threshold for flatness check in SGM block. Valid range is [1,7].
variable
bool flatnessOverride
Flag to indicate whether final confidence value will be overidden by flatness value. Valid range is {true,false}.
function
struct

dai::StereoDepthConfig::CostAggregation

#include StereoDepthConfig.hpp
variable
uint8_t divisionFactor
Cost calculation linear equation parameters. RVC2 only.
variable
uint16_t horizontalPenaltyCostP1
Horizontal P1 penalty cost parameter. RVC2 only.
variable
uint16_t horizontalPenaltyCostP2
Horizontal P2 penalty cost parameter. RVC2 only.
variable
uint16_t verticalPenaltyCostP1
Vertical P1 penalty cost parameter. RVC2 only.
variable
uint16_t verticalPenaltyCostP2
Vertical P2 penalty cost parameter. RVC2 only.
variable
P1Config p1Config
Adaptive P1 penalty configuration. RVC4 only.
variable
P2Config p2Config
Adaptive P2 penalty configuration. RVC4 only.
function
struct

dai::StereoDepthConfig::CostAggregation::P1Config

#include StereoDepthConfig.hpp
variable
bool enableAdaptive
Used to disable/enable adaptive penalty.
variable
uint8_t defaultValue
Used as the default penalty value when nAdapEnable is disabled. A bigger value enforces higher smoothness and reduced noise at the cost of lower edge accuracy. This value must be smaller than P2 default penalty. Valid range is [10,50].
variable
uint8_t edgeValue
Penalty value on edges when nAdapEnable is enabled. A smaller penalty value permits higher change in disparity. This value must be smaller than or equal to P2 edge penalty. Valid range is [10,50].
variable
uint8_t smoothValue
Penalty value on low texture regions when nAdapEnable is enabled. A smaller penalty value permits higher change in disparity. This value must be smaller than or equal to P2 smoothness penalty. Valid range is [10,50].
variable
uint8_t edgeThreshold
Threshold value on edges when nAdapEnable is enabled. A bigger value permits higher neighboring feature dissimilarity tolerance. This value is shared with P2 penalty configuration. Valid range is [8,16].
variable
uint8_t smoothThreshold
Threshold value on low texture regions when nAdapEnable is enabled. A bigger value permits higher neighboring feature dissimilarity tolerance. This value is shared with P2 penalty configuration. Valid range is [2,12].
function
struct

dai::StereoDepthConfig::CostAggregation::P2Config

#include StereoDepthConfig.hpp
variable
bool enableAdaptive
Used to disable/enable adaptive penalty.
variable
uint8_t defaultValue
Used as the default penalty value when nAdapEnable is disabled. A bigger value enforces higher smoothness and reduced noise at the cost of lower edge accuracy. This value must be larger than P1 default penalty. Valid range is [20,100].
variable
uint8_t edgeValue
Penalty value on edges when nAdapEnable is enabled. A smaller penalty value permits higher change in disparity. This value must be larger than or equal to P1 edge penalty. Valid range is [20,100].
variable
uint8_t smoothValue
Penalty value on low texture regions when nAdapEnable is enabled. A smaller penalty value permits higher change in disparity. This value must be larger than or equal to P1 smoothness penalty. Valid range is [20,100].
function
struct

dai::StereoDepthConfig::CostMatching

#include StereoDepthConfig.hpp
variable
DisparityWidth disparityWidth
Disparity search range, default 96 pixels. RVC2 only.
variable
bool enableCompanding
Disparity companding using sparse matching. Matching pixel by pixel for N disparities. Matching every 2nd pixel for M disparitites. Matching every 4th pixel for T disparities. In case of 96 disparities: N=48, M=32, T=16. This way the search range is extended to 176 disparities, by sparse matching. Note: when enabling this flag only depth map will be affected, disparity map is not. RVC2 only.
variable
uint8_t invalidDisparityValue
Used only for debug purposes, SW postprocessing handled only invalid value of 0 properly. RVC2 only.
variable
uint8_t confidenceThreshold
Disparities with confidence value over this threshold are accepted.
variable
bool enableSwConfidenceThresholding
Enable software confidence thresholding. RVC4 only.
variable
LinearEquationParameters linearEquationParameters
Cost calculation linear equation parameters. RVC2 only.
function
struct

dai::StereoDepthConfig::CostMatching::LinearEquationParameters

#include StereoDepthConfig.hpp
variable
uint8_t alpha
variable
uint8_t beta
variable
uint8_t threshold
function
DEPTHAI_SERIALIZE(LinearEquationParameters, alpha, beta, threshold)
enum

std::uint32_t DisparityWidth

Disparity search range: 64 or 96 pixels are supported by the HW.
enumerator
DISPARITY_64
enumerator
DISPARITY_96
struct

dai::StereoDepthConfig::PostProcessing

#include StereoDepthConfig.hpp
using
using
using
using
variable
std::array< Filter, 5 > filteringOrder
Order of filters to be applied if filtering is enabled.
variable
MedianFilter median
Set kernel size for disparity/depth median filtering, or disable
variable
std::int16_t bilateralSigmaValue
Sigma value for bilateral filter. 0 means disabled. A larger value of the parameter means that farther colors within the pixel neighborhood will be mixed together. RVC2 only.
variable
SpatialFilter spatialFilter
Edge-preserving filtering: This type of filter will smooth the depth noise while attempting to preserve edges.
variable
TemporalFilter temporalFilter
Temporal filtering with optional persistence.
variable
ThresholdFilter thresholdFilter
Threshold filtering. Filters out distances outside of a given interval.
variable
BrightnessFilter brightnessFilter
Brightness filtering. If input frame pixel is too dark or too bright, disparity will be invalidated. The idea is that for too dark/too bright pixels we have low confidence, since that area was under/over exposed and details were lost.
variable
SpeckleFilter speckleFilter
Speckle filtering. Removes speckle noise.
variable
DecimationFilter decimationFilter
Decimation filter. Reduces disparity/depth map x/y complexity, reducing runtime complexity for other filters.
variable
HoleFilling holeFilling
Hole-filling configuration. RVC4 only.
variable
AdaptiveMedianFilter adaptiveMedianFilter
Adaptive median filter configuration. RVC4 only.
function
struct

dai::StereoDepthConfig::PostProcessing::AdaptiveMedianFilter

#include StereoDepthConfig.hpp
variable
bool enable
Flag to enable adaptive median filtering for a final pass of filtering on low confidence pixels.
variable
uint8_t confidenceThreshold
Confidence threshold for adaptive median filtering. Should be less than nFillConfThresh value used in evaDfsHoleFillConfig. Valid range is [0,255].
function
struct

dai::StereoDepthConfig::PostProcessing::BrightnessFilter

#include StereoDepthConfig.hpp
variable
std::int32_t minBrightness
Minimum pixel brightness. If input pixel is less or equal than this value the depth value is invalidated.
variable
std::int32_t maxBrightness
Maximum range in depth units. If input pixel is less or equal than this value the depth value is invalidated.
function
struct

dai::StereoDepthConfig::PostProcessing::DecimationFilter

#include StereoDepthConfig.hpp
variable
std::uint32_t decimationFactor
Decimation factor. Valid values are 1,2,3,4. Disparity/depth map x/y resolution will be decimated with this value.
variable
DecimationMode decimationMode
Decimation algorithm type.
function
enum

int32_t DecimationMode

Decimation algorithm type.
enumerator
PIXEL_SKIPPING
enumerator
NON_ZERO_MEDIAN
enumerator
NON_ZERO_MEAN
struct

dai::StereoDepthConfig::PostProcessing::HoleFilling

#include StereoDepthConfig.hpp
variable
bool enable
Flag to enable post-processing hole-filling.
variable
uint8_t highConfidenceThreshold
Pixels with confidence higher than this value are used to calculate an average disparity per superpixel. Valid range is [1,255]
variable
uint8_t fillConfidenceThreshold
Pixels with confidence below this value will be filled with the average disparity of their corresponding superpixel. Valid range is [1,255].
variable
uint8_t minValidDisparity
Represents the required percentange of pixels with confidence value above nHighConfThresh that are used to calculate average disparity per superpixel, where 1 means 50% or half, 2 means 25% or a quarter and 3 means 12.5% or an eighth. If the required number of pixels are not found, the holes will not be filled.
variable
bool invalidateDisparities
If enabled, sets to 0 the disparity of pixels with confidence below nFillConfThresh, which did not pass nMinValidPixels criteria. Valid range is {true, false}.
function
enum

int32_t Filter

enumerator
NONE
enumerator
DECIMATION
enumerator
SPECKLE
enumerator
MEDIAN
enumerator
SPATIAL
enumerator
TEMPORAL
enumerator
FILTER_COUNT

需要帮助?

请访问讨论论坛以获取技术支持或您可能有的任何其他问题。