5.3.2 目标检测
YOLO 模型简介
本示例展示如何基于 SpaceMiT 智算核,使用图片或视频流作为输入,执行 YOLO 系列目标检测模型的推理,并通过 ROS 2 发布检测结果(包括目标类别与边界框坐标)。
支持模型版本
- YOLOv5
- YOLOv6
- YOLOv8
- YOLOv11 等
ONNX 格式模型可通过 ⭐ Bianbu AI Demo Zoo 下载获取,所有模型基于 COCO 数据集 训练,支持 80 类常见目标,如人物、动物、水果、交通工具等。
应用优势
- 推理速度快
- 精度高,泛化能力强
- 部署简单,资源占用低
应用场景
- 自动驾驶:行人和车辆识别
- 智能家居:垃圾分类、监控识别
- 智慧安防:异常行为检测、跌倒识别
环境准备
安装依赖
sudo apt install python3-opencv ros-humble-cv-bridge ros-humble-camera-info-manager \
ros-humble-image-transport python3-spacemit-ort
导入 ROS2 环境
source /opt/bros/humble/setup.bash
模型配置查看
可执行以下命令,查看当前系统中已支持的模型配置:
ros2 launch br_perception infer_info.launch.py | grep 'detection'
示例输出:
- config/detection/yolov8.yaml
- config/detection/yolov6.yaml
- config/detection/yolov11_640.yaml
- config/detection/yolov5.yaml
- config/detection/yolov11_320.yaml
后续推理时,将 config_path
设置为相应的 .yaml
文件路径,即可使用对应 YOLO 模型。