ImageFilters 对类深度灰度图像(RAW8/RAW16)应用有序的后处理滤镜管道。它目前最适用于 ToF 深度管道和在主机上重放深度。该节点在一个地方提供了中值、空间、斑点和时间滤波。如果未配置任何滤镜,它将作为直通。对于标准的实时 StereoDepth 管道,请优先使用内置的 StereoDepthConfig.PostProcessing 而不是此节点(参见注意事项)。如何放置
Python
Python
1with dai.Pipeline() as pipeline:
2 imageFilters = pipeline.create(dai.node.ImageFilters)输入和输出
inputConfig— 接受用于运行时配置的ImageFiltersConfig消息
基本用法
StereoDepth 视差流:Python
Python
1with dai.Pipeline() as p:
2 left = p.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B)
3 right = p.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C)
4 outL = left.requestOutput((640, 400), fps=20)
5 outR = right.requestOutput((640, 400), fps=20)
6
7 stereo = p.create(dai.node.StereoDepth)
8 outL.link(stereo.left)
9 outR.link(stereo.right)
10
11 filters = p.create(dai.node.ImageFilters)
12 filters.setRunOnHost(True) # RVC2 上必需
13 filters.build(stereo.disparity) # 不带预设构建
14
15 # 启用单个空间滤镜(所有其他参数为默认值)
16 spatial = dai.node.ImageFilters.SpatialFilterParams()
17 spatial.enable = True
18 filters.initialConfig.filterParams = [spatial]预设
dai::ImageFiltersPresetMode / dai.ImageFiltersPresetMode(目前仅限 ToF 调优预设):TOF_LOW_RANGE— 针对约 0.2–2 米的更强时间 + 空间平滑TOF_MID_RANGE— 针对约 0.2–5 米的平衡默认值TOF_HIGH_RANGE— 针对更长距离的激进持久性 + 中值
- 这些预设是为 ToF 用途命名和调优的,并且是可选的。
- 对于通用 StereoDepth 管道,请优先定义自定义管道(参见基本用法)并根据您的场景调整参数。
滤镜参数
StereoDepth 后处理模型相同):MedianFilterParams—MEDIAN_OFF、KERNEL_3x3、KERNEL_5x5SpatialFilterParams—enable、holeFillingRadius、alpha、delta、numIterationsSpeckleFilterParams—enable、speckleRange、differenceThresholdTemporalFilterParams—enable、persistencyMode、alpha、delta
注意事项
- 支持的输入类型:仅限
RAW8和RAW16。 - 此节点中的中值核最大为 5×5(不接受 7×7)。
- 在 RVC2 上,不支持设备执行;请调用
setRunOnHost(True)。 - 如果未配置任何滤镜,该节点将作为直通。
StereoDepth(非 ToF)的建议
StereoDepth,请依赖其内置的后处理,并保持时间滤波保守或禁用。示例 (Python):Python
Python
1stereo = p.create(dai.node.StereoDepth)
2# … 链接左右 …
3stereo.initialConfig.postProcessing.temporalFilter.enable = False
4stereo.initialConfig.postProcessing.temporalFilter.delta = 100功能示例
- 立体深度滤镜 — 使用
ImageFilters和StereoDepth视差输出的示例
参考
class
dai::node::ImageFilters
variable
std::shared_ptr< ImageFiltersConfig > initialConfig
Initial config for image filters.
variable
Node::Input input
Input for image frames to be filtered
variable
Node::Output output
Filtered frame
variable
Node::Input inputConfig
Config to be set for a specific filter
function
std::shared_ptr< ImageFilters > build(Node::Output & input, ImageFiltersPresetMode presetMode)Build the node.
Parameters
- input: Input for image frames to be filtered
- presetMode: Preset mode for image filters
Returns
Shared pointer to the node
function
std::shared_ptr< ImageFilters > build(ImageFiltersPresetMode presetMode)Build the node.
Parameters
- presetMode: Preset mode for image filters
Returns
Shared pointer to the node
function
void run()function
void setRunOnHost(bool runOnHost)Specify whether to run on host or device By default, the node will run on device.
function
bool runOnHost()Check if the node is set to run on host
function
void setDefaultProfilePreset(ImageFiltersPresetMode mode)inline function
DeviceNodeCRTP()inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device)inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props)inline function
DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)inline function
DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)需要帮助?
请访问讨论论坛以获取技术支持或您可能有的任何其他问题。