引言:为了提高yolo识别的质量,提高了yolo的版本,改用yolov7进行物体识别,同时系统兼容了低版本的yolo,包括基于C++的yolov3和yolov4,也有更高版本的yolov8。
简介,为了提高识别速度,系统采用了GPU进行加速,在使用7W功率的情况,大概可以稳定在20FPS,满功率情况下可以适当提高。
硬件:D435摄像头,Jetson orin nano 8G
环境:ubuntu20.04,ros-noetic, yolov7
步骤一: 启动摄像头,获取摄像头发布的图像话题
javascript
roslaunch realsense2_camera rs_camera.launch
没有出现红色报错,出现如下界面,表明摄像头启动成功
步骤二:启动yolov7识别节点
javascript
roslaunch yolov7 yolov7.launch
launch文件如下,参数device设置为cuda,因为实际使用GPU加速,不是CPU跑,另外参数img_topic是订阅的节点话题,一定要与摄像头发布的实际话题名称对应上。其他参数可以根据实际情况进行调整即可
javascript
<?xml version="1.0"?>
<launch>
<node pkg="yolov7" type="YoloV7.py" name="yolov7">
<!-- Path to your weight -->
<param name="weights_path" type="str" value="/home/cwkj/cwkj_ws/src/ros-yolov7/cfg/weights/yolov7-tiny.pt"/>
<!-- Path to a class_labels.txt file, if you leave it empty then no class labels are visualized.-->
<param name="classes_path" type="str" value="//home/cwkj/cwkj_ws/src/ros-yolov7/cfg/config/coco.txt" />
<!-- Input image topic name to subscribe to -->
<param name="img_topic" type="str" value="/camera/color/image_raw" />
<!-- [optional] Confidence threshold (default=0.25) -->
<param name="conf_thresh" type="double" value="0.20" />
<!-- [optional] Intersection over union threshold (default=0.45) -->
<param name="iou_thresh" type="double" value="0.45" />
<!-- [optional] Queue size for publishing (default=3) -->
<param name="queue_size" type="int" value="1" />
<!-- [optional] Image size to which to resize each input image before feeding into the network (the final output is rescaled to the original image size) (default=640) -->
<param name="img_size" type="int" value="640" />
<!-- [optional] Flag whether to also publish image with the visualized detections (default=false) -->
<param name="visualize" type="bool" value="true" />
<!-- [optional] Torch device 'cuda' or 'cpu' (default="cuda") -->
<param name="device" type="str" value="cuda" />
<!-- [optional] Node frequency (default=10) -->
<param name="frequency" type="int" value="10" />
</node>
</launch>
出现如下界面表示yolov7启动成功
步骤三:打开rqt工具,查看识别效果
javascript
rqt_image_view