6
5

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.

OAK-D-Lite をROS Noeticで動かす

Last updated at Posted at 2022-01-02

はじめに

OAK-D-Liteが届いたのでROS Noeticで動かしてみた

以下はOAK-DのROSパッケージのリンク

環境

OS : ubuntu20.04.03.LTS
ROS : Noeitc
OpenCV : 4.2.0

ROS Noeticのインストール

まだROSをインストールしていない場合は公式の手順通りにインストールする。

パッケージのインストール

基本的に以下のREADME通り

依存パッケージのインストール

sudo wget -qO- https://raw.githubusercontent.com/luxonis/depthai-ros/main/install_dependencies.sh | sudo bash

ワークスペースの作成

mkdir -p depthai_ws/src

ROSパッケージのインストール

cd depthai_ws/
wget https://raw.githubusercontent.com/luxonis/depthai-ros/main/underlay.repos
vcs import src < underlay.repos
rosdep install --from-paths src --ignore-src -r -y
source /opt/ros/noetic/setup.bash
catkin build 
source devel/setup.bash

ROSノードの実行

ステレオカメラの画像を使う

source ~/depthai_ws/devel/setup.bash
roslaunch depthai_examples stereo_node.launch camera_model:=OAK-D-LITE

rvizが起動し、カメラ画像、RobotModel、DeothCloudが表示される。

rviz_screenshot_2022_03_27-15_03_27.png

RGB画像を使う

source ~/depthai_ws/devel/setup.bash
roslaunch depthai_examples rgb_publisher.launch camera_model:=OAK-D-LITE

/rgb_publisher/color/image , /rgb_publisher/color/image/compressedにカラー画像が出力される

PointCloudを使う

source ~/depthai_ws/devel/setup.bash
roslaunch depthai_examples stereo_nodelet.launch camera_model:=OAK-D-LITE

実行するとrvizが起動する。
/stereo_publisher/stereo/pointsというトピックにPointCloud2型の点群が出力される。

rviz_screenshot_2022_01_01-13_21_08.png

YOLOv4で物体検出する

source ~/depthai_ws/devel/setup.bash
roslaunch depthai_examples yolov4_publisher.launch 

/yolov4_publisher/color/yolov4_Spatial_detectionsというトピックに物体検出結果が出力される。
以下で検出結果の確認。
画像はID:0 のpersonを検出した時の出力例

source ~/depthai_ws/devel/setup.bash 
rostopic echo /yolov4_publisher/color/yolov4_Spatial_detections

Screenshot from 2022-01-01 20-30-24.png

検出できる物体のクラスの一覧(depthai_example/ros1_src/yolov4_spatial_publisher.cpp 内の配列)

yolov4_spatial_publisher.cpp
const std::vector<std::string> label_map = {"person",         "bicycle",    "car",           "motorbike",     "aeroplane",   "bus",           "train",
             "truck",          "boat",       "traffic light", "fire hydrant",  "stop sign",   "parking meter", "bench",
             "bird",           "cat",        "dog",           "horse",         "sheep",       "cow",           "elephant",
             "bear",           "zebra",      "giraffe",       "backpack",      "umbrella",    "handbag",       "tie",
             "suitcase",       "frisbee",    "skis",          "snowboard",     "sports ball", "kite",          "baseball bat",
             "baseball glove", "skateboard", "surfboard",     "tennis racket", "bottle",      "wine glass",    "cup",
             "fork",           "knife",      "spoon",         "bowl",          "banana",      "apple",         "sandwich",
             "orange",         "broccoli",   "carrot",        "hot dog",       "pizza",       "donut",         "cake",
             "chair",          "sofa",       "pottedplant",   "bed",           "diningtable", "toilet",        "tvmonitor",
             "laptop",         "mouse",      "remote",        "keyboard",      "cell phone",  "microwave",     "oven",
             "toaster",        "sink",       "refrigerator",  "book",          "clock",       "vase",          "scissors",
             "teddy bear",     "hair drier", "toothbrush"};

おわりに

OAK-D-Liteでもすべてのexampleを実行することができた。

参考

6
5
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
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?