玩玩AI(2)-ncnn_ros功能包

参考项目

GitHub - Tencent/ncnn: ncnn is a high-performance neural network inference framework optimized for the mobile platform

GitHub - nilseuropa/ros_ncnn: ROS wrapper for NCNN neural inference framework

ncnn_ros功能包参考了ncnn中的demo和ros_ncnn项目,相比于ros_ncnn,主要改动是

1、适配了nanodet、yolov3、yolo5、yolox和yolov7几种分类算法和yolact分割算法

2、移除了代码中GUI显示部分,改为ROS话题发布

3、增加影响检测速度的参数调节配置接口

4、单独定义了消息类型,方便跨设备订阅话题

安装

Noet:安装前需要已经正常编译ncnn框架

获取ncnn_ros和object_information_msgs源码

cd ~/catkin_ws/src/
git clone https://gitee.com/bingda_ai/ncnn_ros.git
git clone https://gitee.com/bingda_ai/object_information_msgs.git

编译工作空间

cd ~/catkin_ws/ &&  catkin_make --pkg object_information_msgs ncnn_ros

准备模型文件

将模型文件放在用户主目录中

方法1:

如果github访问通畅,可以从nihui大佬的仓库直接clone(注意,这个仓库比较大,约1G,另外就是没有包含yolox的模型文件,需要单独获取,然后拷贝至ncnn-assets/models目录中)

cd ~
git clone https://github.com/nihui/ncnn-assets.git

yolox模型地址
 https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s_ncnn.tar.gz

方法2:

也可以下载我精简后的压缩包,然后解压到用户主目录

ncnn-assets.zip

cd ~
unzip unzip ncnn-assets

运行Demo

启动摄像头

roslaunch ncnn_ros camera.launch

启动一个检测节点,例如NanoDet

roslaunch ncnn_ros nanodet.launch

参数调整

camera_topic 节点订阅的话题名

enable_gpu 是否启用GPU,默认值false

target_size 目标尺寸,默认值640(不同节点有差异,参考launch文件)

display_output 是否输出检测后图像话题,默认值true

powersave CPU模式,默认值0,可选0,1,2

thread 线程数,默认2

不严谨的性能测试

测试是便开发边做的,运行的参数可能不完全一样,所以不具备绝对的对比价值

NanoDet

YOLO V3

YOLO V5

YOLO X

YOLO V7

YOLOACT

备注

全志H6

6.5 FPS

2.0 FPS

1.9 FPS

1.6FPS

1.6 FPS

0.1 FPS

powersave:=0 thread:=4

树莓派4B

3.3FPS

powersave:=0 thread:=4

RK3399

13.5 FPS

5.2 FPS

5.0 FPS

4.0 FPS

4.3 FPS

powersave:=0 thread:=4

旭日X3

8.7 FPS

3.6 FPS

3.3FPS

2.8 FPS

3.1 FPS

powersave:=0 thread:=4

RK3588

48.0 FPS

37.0 FPS

22.0 FPS

33.0 FPS

33.0 FPS

powersave:=2 thread:=4

猜你喜欢

转载自blog.csdn.net/bingda_robot/article/details/128315864