LoginSignup
62
47

More than 3 years have passed since last update.

OpenCV AI Kitの到着に備えよう

Last updated at Posted at 2020-12-22

はじめに

https://www.kickstarter.com/projects/opencv/opencv-ai-kitでOpenCV AI KitのPre-orderが始まりました(現在はkickstarterだけでなく、https://store.opencv.ai/からもPre-orderできるようになっているようです)。この記事を読んでいる方でPre-order済で到着を心待ちにしている方も多いのではないでしょうか?完全に余談ですが筆者はOpenCV Tシャツも勢いで注文してしまいました。

これから一家に一台(?)となるかもしれないOpenCV AI Kitに関して、web上にある公開情報を調べてみたのでこの記事で情報共有しようと思います。

OpenCV AI Kitとは

https://www.kickstarter.com/projects/opencv/opencv-ai-kitの冒頭で

To celebrate OpenCV’s 20th anniversary we are proud to introduce the OpenCV AI Kit (OAK), an MIT-licensed open source software and Myriad X-based hardware solution for computer vision at any scale.

という説明があります。どうも、Myriad Xベースのハードウェア、MITライセンスのCVアルゴリズムのソフトウェアから構成されるソリューションを「OpenCV AI Kit (OAK)」と言っていそうです。

加えてこのページにはOpenCV AI Kitには

  • OAK-1
  • OAK-D

という2種類のデバイスがあることと、それぞれのデバイスのハードウェアスペックの説明があります。

まずはOAK-1についてです。RGBカメラが付いているモデルです。
※下図はhttps://www.kickstarter.com/projects/opencv/opencv-ai-kitから引用したものです。

RGBカメラでの撮影サンプルは以下の動画を観るとよいでしょう。

続いてOAK-Dについてです。こちらはRGBカメラだけでなくステレオカメラが付いています。
※下図はhttps://www.kickstarter.com/projects/opencv/opencv-ai-kitから引用したものです。

また、それぞれのデバイスでできることになる機能は以下のように紹介されています。
OAK-1、OAK-DともにDNNのinferenceだけでなく、オブジェクトトラッキング、Apriltag検出などができるようです。OAK-Dだとステレオカメラが付いているということもあり、depthを使った処理ができるようになっています。
※下図はhttps://www.kickstarter.com/projects/opencv/opencv-ai-kitから引用したものです。

ハードウェア

https://luxonis.com/depthaiにはデータパスの情報がもう少し詳細に載っています。
以下にデータパスの図を引用します。

この図を読むと、カメラ画像(RGBカメラ、ステレオカメラ)をMIPI経由で転送し、Myrad X上でコンピュータビジョン、画像処理関連の処理を行い、USB経由でホスト側で受け取るというデータの流れのようです。この図から見るとホスト側からOpenCV AI Kit側に処理を戻すことはできないように見えます。

OAK-1

(おそらく)OAK-1のモジュール情報は以下にまとまっています。
https://github.com/luxonis/depthai-hardware/tree/master/BK1096_OAK-1_Modular

このページにある情報を以下に抜粋します。

  • IMP378 12MP Camera
  • USB 3.1 Gen1 Type-C data and power
  • AUX 5V connector
  • Access to SoM 1.8V I2C and UART

DepthAIのページでもPDF資料が公開されています。
https://drive.google.com/file/d/1z7QiCn6SF3Yx977oH41Kcq68Ay6e9h3_/

OAK-D

(おそらく)OAK-Dのモジュール情報は以下にまとまっています。
https://github.com/luxonis/depthai-hardware/tree/master/BW1098OBC_DepthAI_USB3C

このページにある情報を以下に抜粋します。現時点でUART、GPIOをどういう用途で使うのかはイメージが付かないので届いてから要確認といった感じです。

  • USB 3.1 Gen1 Type-C
  • Optional resistor-jumper for USB power
  • Pads for DepthAI SoM 1.8V SPI
  • Pads for DepthAI SoM 3.3V SDIO
  • Pads for DepthAI SoM 1.8V Aux Signals (I2C, UART, GPIO)
  • 5V barrel jack input
  • Support for 5V fan

DepthAIのページでもPDF資料が公開されています。
https://drive.google.com/file/d/1g0bQDLNnpVC_1-AGaPmC8BaXtGaNNdTR/

https://www.kickstarter.com/projects/opencv/opencv-ai-kit/faqsに重量に関する情報があります。

  • OAK-1: ~1.0 oz. (29 grams)
  • OAK-D: ~1.5 oz. (43 grams)

また、電源供給についても以下の記載があります。

It heavily depends on the modes of operation, but OAK-1 is about 2.5W and OAK-D is about 4W.

The OAK-D is designed with an ideal-diode-or between the barrel jack 5V power and the USB power.

ソフトウェア

個人的には現時点でSDKに関してはDepthAI公式ドキュメントであるhttps://docs.luxonis.com/en/latest/が一番まとまっているように感じています。また、現時点ではC++、PythonでAPIが提供されているようです。

ここでは現時点で情報が最も多いPython APIを軽く紹介することにします。

Python API

APIリファレンスはhttps://docs.luxonis.com/en/latest/pages/api/#api-referenceを参照ください。https://docs.luxonis.com/en/latest/pages/samples/minimal/にあるサンプルコードでシンプルな使い方がイメージできそうなのでこちらを用いて基本的な使い方を見てみましょう。

import cv2
import depthai

# デバイス検知
device = depthai.Device('', False)

# パイプライン作成(DNNモデル情報、カメラのストリーム設定など)
p = device.create_pipeline(config={
    "streams": ["metaout", "previewout"],
    "ai": {
        "blob_file": "/path/to/depthai/resources/nn/mobilenet-ssd/mobilenet-ssd.blob",
        "blob_file_config": "/path/to/depthai/resources/nn/mobilenet-ssd/mobilenet-ssd.json"
    }
})

if p is None:
    raise RuntimeError("Error initializing pipelne")

detections = []

while True:
    # デバイスからパケットを取得
    nnet_packets, data_packets = p.get_available_nnet_and_data_packets()

    # object detectionの結果を取り出す
    for nnet_packet in nnet_packets:
        detections = list(nnet_packet.getDetectedObjects())

    for packet in data_packets:
        if packet.stream_name == 'previewout':
            # RGBカメラ画像を取り出す
            data = packet.getData()

            # CHW -> HWCに変換
            data0 = data[0, :, :]
            data1 = data[1, :, :]
            data2 = data[2, :, :]
            frame = cv2.merge([data0, data1, data2])

            img_h = frame.shape[0]
            img_w = frame.shape[1]

            # object detection結果を重畳する
            for detection in detections:
                pt1 = int(detection.x_min * img_w), int(detection.y_min * img_h)
                pt2 = int(detection.x_max * img_w), int(detection.y_max * img_h)

                cv2.rectangle(frame, pt1, pt2, (0, 0, 255), 2)

            cv2.imshow('previewout', frame)

    if cv2.waitKey(1) == ord('q'):
        break

# 終了処理
del p
del device

冒頭でApriltag検出ができるという話が出てきましたが、現時点のhttps://docs.luxonis.com/en/latest/pages/api/#api-referenceには見当たりません。DepthAIのissueを眺めているとそれらしいものが見つかりました。
https://github.com/luxonis/depthai/issues/133

どうも本記事を執筆した時点では未対応のようです。これらの進展が気になる人は以下のページをウォッチするとよいかもしれません。
https://github.com/orgs/luxonis/projects

OpenVINO対応

OpenCV AI KitではOpenVINOの学習済モデルを使用できるという記載があります。
https://luxonis.com/depthai#awesomeにある図を以下に引用します。

OpenCV AI Kit上だとMobileNet SSDが約25fpsで動作するようです。RasPi3上でこの速度で動いてくれると色々活用ができそうですね。このあたりは実機が来たら検証してみたいところです。

また、https://docs.luxonis.com/en/latest/pages/tutorials/local_convert_openvino/にOpenVINO IR modelをOpenCV AI Kitで使用するためのチュートリアルがあります。

ROS対応

DiscourseでROS対応についてディスカッションがなされています。
https://discourse.ros.org/t/opencv-ai-kit-oak/15406

また、ROS2のラッパーも実装されているようです。
https://github.com/luxonis/depthai_ros2

Micropython対応

https://www.kickstarter.com/projects/opencv/opencv-ai-kit/faqs

Micropython code directly on the Myriad X as a block in the pipeline.

という記載があり、2021年に対応予定があるようです。

フォーラム

2021年1月からOpenCV AI Kitの公式フォーラムができるというアナウンスがありました。楽しみに待ちましょう!
https://store.opencv.ai/blogs/learn-oak/oak-forum

その他

Luxonisとは?

これまでの説明でLuxonisという単語が何度も出てきましたがOpenCV AI Kitとどう関連しているのか気になってきます。https://www.kickstarter.com/projects/opencv/opencv-ai-kit/faqsに以下の回答があります。

Q. Who is Luxonis? What is their relationship with OpenCV?

A. Luxonis is behind writing the core capabilities and developing the hardware of the OpenCV AI Kit. Dr. Mallick approached Luxonis with the great idea to make this the OpenCV AI Kit and Luxonis loved the idea. So together Luxonis and OpenCV have been working towards that since (now for quite a long time).

Luxonis is also responsible for production of all of the OpenCV AI Kit and fulfillment of this KickStarter.

おわりに

https://www.kickstarter.com/projects/opencv/opencv-ai-kit/posts/3054589を読むと配送周りで若干トラブルが起きていそうなので届くのは年明けになりそうかなという感じですが、事前準備としてOpenCV AI Kit関連の情報収集をしてこのページにまとめてみました。軽く調べた感じでは簡単に使えそうなので届くのが本当に楽しみです!

明日はtetsu5902さんの記事です、楽しみにしましょう!

参考URL

62
47
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
62
47