FCOS
功能介绍
FCOS目标检测算法示例使用图片作为输入,利用BPU进行算法推理,发布包含目标类别和检测框的智能msg。
FCOS是D-Robotics开源的Onnx模型,使用COCO数据集进行训练,支持的目标检测类型包括人、动物、水果、交通工具等共80种类型。
代码仓库: (https://github.com/D-Robotics/hobot_dnn)
应用场景:FCOS发布于2019年,是一款单阶段的目标检测算法,可实现行人检测、车辆检测等功能,主要应用于自动驾驶、智能家居等领域。
多光谱的目标检测案例: (https://github.com/hdjsjyl/Multispectral-FCOS)
支持平台
平台 | 运行方式 | 示例功能 |
---|---|---|
RDK X3, RDK X3 Module, RDK X5 | Ubuntu 20.04 (Foxy), Ubuntu 22.04 (Humble) | · 启动MIPI/USB摄像头,并通过web展示推理渲染结果 · 使用本地回灌,渲染结果保存在本地 |
X86 | Ubuntu 20.04 (Foxy) | · 使用本地回灌,渲染结果保存在本地 |
准备工作
RDK平台
-
RDK已烧录好Ubuntu 20.04/Ubuntu 22.04系统镜像。
-
RDK已成功安装TogetheROS.Bot。
-
RDK已安 装MIPI或者USB摄像头,无摄像头的情况下通过回灌本地JPEG/PNG格式图片或者MP4、H.264和H.265的视频方式体验算法效果。
-
确认PC机能够通过网络访问RDK。
X86平台
-
X86环境已配置好Ubuntu 20.04系统镜像。
-
X86环境系统已成功安装tros.b。
使用介绍
RDK平台
使用MIPI摄像头发布图片
FCOS目标检测算法示例订阅sensor package发布的图片,经过推理后发布算法msg,通过websocket package实现在PC端浏览器上渲染显示发布的图片和对应的算法结果。
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 配置MIPI摄像头
export CAM_TYPE=mipi
# 启动launch文件
ros2 launch dnn_node_example dnn_node_example.launch.py dnn_example_config_file:=config/fcosworkconfig.json dnn_example_image_width:=480 dnn_example_image_height:=272
使用USB摄像头发布图片
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 配置USB摄像头
export CAM_TYPE=usb
# 启动launch文件
ros2 launch dnn_node_example dnn_node_example.launch.py dnn_example_config_file:=config/fcosworkconfig.json dnn_example_image_width:=480 dnn_example_image_height:=272
使用本地图片回灌
FCOS目标检测算法示例使用本地JPEG/PNG格式图片回灌,经过推理后将算法结果渲染后的图片存储在运行路径下。
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 启动launch文件
ros2 launch dnn_node_example dnn_node_example_feedback.launch.py dnn_example_config_file:=config/fcosworkconfig.json dnn_example_image:=config/target.jpg
X86平台
使用本地图片回灌
FCOS目标检测算法示例使用本地JPEG/PNG格式图片回灌,经过推理后将算法结果渲染后的图片存储在本地的运行路径下。
# 配置tros.b环境
source /opt/tros/setup.bash
# 启动launch文件
ros2 launch dnn_node_example dnn_node_example_feedback.launch.py dnn_example_config_file:=config/fcosworkconfig.json dnn_example_image:=config/target.jpg
结果分析
使用摄像头发布图片
在运行终端输出如下信息:
[example-3] [WARN] [1655092908.847609539] [example]: Create ai msg publisher with topic_name: hobot_dnn_detection
[example-3] [WARN] [1655092908.849393011] [example]: Create img hbmem_subscription with topic_name: /hbmem_img
[example-3] [WARN] [1655092543.834432739] [img_sub]: Sub img fps 31.16
[example-3] [WARN] [1655092543.864126080] [example]: Smart fps 31.56
[example-3] [WARN] [1655092544.867603759] [img_sub]: Sub img fps 30.01
[example-3] [WARN] [1655092544.899715339] [example]: Smart fps 29.95
[example-3] [WARN] [1655092545.900991853] [img_sub]: Sub img fps 30.01
[example-3] [WARN] [1655092545.931518037] [example]: Smart fps 30.07
[example-3] [WARN] [1655092546.901658559] [img_sub]: Sub img fps 30.00
[example-3] [WARN] [1655092546.938970895] [example]: Smart fps 29.79
[example-3] [WARN] [1655092547.934894494] [img_sub]: Sub img fps 30.01
[example-3] [WARN] [1655092547.973566486] [example]: Smart fps 29.98
[example-3] [WARN] [1655092548.967549745] [img_sub]: Sub img fps 30.10
[example-3] [WARN] [1655092548.997125216] [example]: Smart fps 30.30
输出log显示,发布算法推理结果的topic为hobot_dnn_detection
,订阅图片的topic为/hbmem_img
,订阅到的图片和算法推理输出帧率约为30fps。
在PC端的浏览器输入http://IP:8000 即可查看图像和算法渲染效果(IP为RDK的IP地址):