跳到主要内容

目标检测

gst-ai-object-detection 对视频流逐帧执行目标检测,在检测到的物体周围绘制边界框,标注类别名称和置信度。

支持 YOLOX、YOLOv8、YOLO-NAS 模型。

前提条件

步骤

1. 确认模型和标签

radxa@airbox$
ls -l /etc/models/yolox_quantized.tflite
ls -l /etc/labels/yolox.json

2. 查看配置

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

关键字段:

字段默认值说明
file-path/etc/media/video.mp4输入视频路径
ml-frameworktflite推理框架
yolo-model-typeyoloxYOLO 模型类型:yolov5 / yolov8 / yolox / yolonas
model/etc/models/yolox_quantized.tflite模型文件
labels/etc/labels/yolox.json标签文件
threshold40置信度阈值 (1-100)
runtimedsp推理硬件

3. 运行

radxa@airbox$
gst-ai-object-detection --config-file=/etc/configs/config_detection.json

Ctrl + C 停止。

预期输出

终端输出:

Running app with model: /etc/models/yolox_quantized.tflite and labels: /etc/labels/yolox.json
Using DSP Delegate
VERBOSE: Replacing 329 out of 329 node(s) with delegate (TfLiteQnnDelegate) node
Pipeline state changed from PAUSED to PLAYING

显示器上播放测试视频,检测到的物体周围显示彩色边界框,标注类别名称和置信度。

验证

  • Using DSP Delegate:推理在 NPU 上运行
  • Replacing 329 out of 329 node(s):全部 329 个算子委派到 DSP
  • Pipeline 进入 PLAYING 状态
  • 显示器正确显示边界框和标签

调整检测灵敏度

如果检测框太少(漏检),降低阈值:

radxa@airbox$
# 将 /etc/configs/config_detection.json 中 threshold 改为 20

如果误检太多,提高阈值(如 60)。

切换 YOLO 模型

修改配置文件中的模型类型和路径:

{
"yolo-model-type": "yolov8",
"model": "/etc/models/yolov8_det_quantized.tflite",
"labels": "/etc/labels/yolov8.json"
}

YOLOv8 和 YOLO-NAS 模型需要通过 Qualcomm AI Hub 单独导出。

Pipeline 流程

filesrc → qtdemux → h264parse → v4l2h264dec → qtimlvconverter

qtimltflite (DSP 推理)

qtimlvdetection (YOLO 后处理)

qtivcomposer

waylandsink

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

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