version:3.0
Dong chen
ROS_image_topic input- segment
detect
2023-10-07
v3
can use file and ROS topic input2023-10-07
v2
just for ROS image topic input2023-10-07
put the detect part of YOLOv8-TensorRT into ROS noetic
- Nvidia Jetson Orin NX
- Ubuntu 20.04 ( Jetpack 5.1.2 )
- ROS noetic
The default CMake version in jetson is too low, so you can not install onnxsim by pip.
sudo apt remove cmake
Download the source cmake-3.27.7.tar.gz
from https://cmake.org/download/, and unzip it.
# check the environment
./bootstrap
# build
sudo make
# install
sudo make install
# test
cmake --version
-
Install follow CUDA official website.CUDA
🚀 RECOMMENDED >= 11.4CUDA
-
Install follow TensorRT official website.TensorRT
🚀 RECOMMENDED >= 8.4TensorRT
-
Install python requirements.
pip install -r requirements.txt
-
Install ultralytics package for ONNX export or TensorRT API building.
pip install ultralytics
-
Prepare your own PyTorch weight such as
yolov8s.pt
oryolov8s-seg.pt
.
- Build ONNX
python3 export-det.py --weights yolov8s.pt --sim
- Build engine
# Using trtexec tools for export engine
/usr/src/tensorrt/bin/trtexec \
--onnx=yolov8s.onnx \
--saveEngine=yolov8s.engine
- catkin_make
cd ~/catkin_ws
catkin_make
# rosrun yolov8 yolov8 /path/engine /path/data or /path/data/image or /path/data/video
rosrun yolov8 yolov8 /home/orin/Downloads/yolov8_tensorrt_jetson_detect/engine/yolov8n.engine /home/orin/Downloads/yolov8_tensorrt_jetson_detect/data/bus.jpg
# rosrun yolov8 yolov8 /path/engine /ROStopic
rosrun yolov8 yolov8 /home/orin/catkin_ws/src/yolov8/engine/yolov8n.engine /usb_cam/image_raw
input type:
- video
- mp4
- avi
- m4v
- mpeg
- mov
- mkv
- image
- jpg
- jpeg
- png
In this package, you can not use the OpenCV which is in the ROS, so this part of CMakeLists.txt is very important.
file(GLOB_RECURSE OLD_OPENCV "/usr/lib/aarch64-linux-gnu/libopencv*")
list(REMOVE_ITEM catkin_LIBRARIES ${OLD_OPENCV})