5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

RealSenseAdvent Calendar 2023

Day 24

YOLOX-ROSとRealSenseで物体検出

Last updated at Posted at 2023-12-24

はじめに

Docker環境でRealSense のRGB画像を使ってYOLOX-ROSで物体検出する手順

YOLOX-ROSについて

YOLOXをROS 2 Humbleに対応させたもの
詳細は作者のAr-Ray氏の記事を見てください。

動作確認環境

項目
CPU Intel® Core™ i7-12700H
GPU GeForce RTX 3050 Ti Mobile
Ubuntu 22.04
Kernel 6.2.0-36-generic
docker 24.0.6
docker compose v2.21.0

YOLOX-ROSのDockerイメージの作成

こちらのonnxruntimeのDockerfileとdocker-compose.ymlを使う (Tensor RT, OpenVINOは動作未確認)
docker コンテナ内でRealSenseにアクセスできるように docker-compose.ymlに以下を追加

        privileged: true

ワークスペースに移動して、YOLOX-ROSのリポジトリをクローンします。

cd ~/ros2_ws/src
git clone --recursive https://github.com/Ar-Ray-code/YOLOX-ROS -b humble
cd YOLOX-ROS/yolox_ros_cpp/docker/onnxruntime/

Docker イメージの作成

docker compose up --build

Dockerコンテナに入って、YOLOX-ROSのセットアップ

docker exec -it yolox_onnxruntime bash
cd ~/ros2_ws
./src/YOLOX-ROS/weights/onnx/download.bash all
source /opt/ros/humble/setup.bash
colcon build --cmake-args -DYOLOX_USE_ONNXRUNTIME=ON

サンプルの実行

ros2 launch yolox_ros_cpp yolox_openvino.launch.py

RealSenseで動かす

コンテナ内にlibrealsense とrealsense_ros のインストール

sudo apt update
sudo apt install ros-humble-librealsense2 ros-humble-realsense2-camera

realsense-rosとYOLOX-ROSの実行 

ros2 launch realsense2_camera rs_launch.py
ros2 launch yolox_ros_cpp yolox_onnxruntime.launch.py src_image_topic_name:="/camera/color/image_raw"

model を変更する場合 (デフォルトはyolox_tiny)

ros2 launch yolox_ros_cpp yolox_onnxruntime.launch.py src_image_topic_name:="/camera/color/image_raw" model_path:='./src/YOLOX-ROS/weights/onnx/yolox_m.onnx'
5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?