跳到主要内容

单目深度估计

gst-ai-monodepth 对视频流逐帧执行单目深度估计,生成深度图并以热力图叠加渲染。暖色调(红/橙)表示距离较近,冷色调(蓝)表示距离较远。

使用 MiDaS V2 模型。

前提条件

步骤

1. 确认模型和标签

radxa@airbox$
ls -l /etc/models/midas_quantized.tflite
ls -l /etc/labels/monodepth.json

2. 查看配置

radxa@airbox$
cat /etc/configs/config_monodepth.json

关键字段:

字段默认值说明
file-path/etc/media/video.mp4输入视频路径
ml-frameworktflite推理框架
model/etc/models/midas_quantized.tflite模型文件
labels/etc/labels/monodepth.json颜色映射文件
runtimedsp推理硬件

3. 运行

radxa@airbox$
gst-ai-monodepth --config-file=/etc/configs/config_monodepth.json

Ctrl + C 停止。

预期输出

终端输出:

Running app with model: /etc/models/midas_quantized.tflite and labels: /etc/labels/monodepth.json
Using DSP Delegate
VERBOSE: Replacing 140 out of 140 node(s) with delegate (TfLiteQnnDelegate) node, yielding 1 partitions for the whole graph.
Pipeline state changed from PAUSED to PLAYING

显示器上播放测试视频,叠加深度热力图。暖色(红/橙)表示近处物体,冷色(蓝)表示远处背景。

验证

  • Using DSP Delegate:推理在 NPU 上运行
  • Replacing 140 out of 140 node(s):全部 140 个算子委派到 DSP
  • Pipeline 进入 PLAYING 状态
  • 显示器正确显示深度热力图

工作原理

MiDaS (Monocular Depth Estimation) 以单张 RGB 图像为输入,输出每个像素的相对深度值。GStreamer pipeline:

filesrc → qtdemux → h264parse → v4l2h264dec
↓ ↓
(分流) qtimlvconverter (预处理)

qtimltflite (DSP 推理)

后处理 (深度→热力图)

qtivcomposer

waylandsink

    您需要登录 GitHub 才能发表评论。如果您已登录,请忽略此消息。

    Radxa-docs © 2026 by Radxa Computer (Shenzhen) Co.,Ltd. is licensed under CC BY 4.0