基于YoloV5的ROS2封装,给定模型文件和相机参数可以直接发布三维空间置进行抓取操作。
sudo apt update
sudo apt install python3-pip ros-humble-vision-msgs
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple yolov5
colcon build
source install/setup.bash
ros2 run yolov5_ros2 yolo_detect_2d --ros-args -p device:=cpu -p image_topic:=/image
使用真实相机,修改默认话题image_topic:=/image
ros2 run image_tools cam2image --ros-args -p width:=640 -p height:=480 -p frequency:=30.0 -p device_id:=-1
识别结果通过/yolo_resutl话题发布出去,包含原始的像素坐标、和归一化后的x和y坐标(相机坐标系下)。
ros2 topic echo /yolo_result
image_topic:=/image
可选的,如果你有cuda独显, cuda,cuda:0
device:=cpu
True显示,False不显示
show_result:=Flase