OAK-D UVCカメラ化

知りたい点:
・4K RGBカメラはチャット用カメラとして使えないんだろうか。

→ UVC化について公式FAQに書かれていた。
FAQs & How-To — DepthAI documentation | Luxonis

How to run OAK-D as video device

Luxonis devices do not appear as standard cameras. To run them as a video device,
consider running them as UVC (USB Video Class). To run UVC directly (still needing
the depthai library, but just for initialization), inside a clone of dephtai-python repo, run:

git fetch --all
git checkout origin/gen2_uvc
python3 examples/install_requirements.py
python3 examples/19_uvc_video.py

Keep the script open. It’s needed to periodically feed the device watchdog (would reset the device on close). And then open some UVC viewer. It should work
all good on Linux. On macOS, it needs a workaround (having some app looking for devices and opening the stream quickly after the depthai pipeline is started),
while on Windows, it doesn’t work yet.

 

 最後一文でガッカリ。とは言うものの、とりあえずやってみたら、下記。


PS C:\***> python .\19_uvc_video.py
Traceback (most recent call last):
File "C:\***\19_uvc_video.py", line 28, in <module>
with dai.Device(pipeline) as device:
RuntimeError: Failed to connect to device, error message: X_LINK_COMMUNICATION_NOT_OPEN

まぁダメかな。

Windows11にアップデートして、WSLをUSBデバイス対応した後、もう一度試そう。

OAK-D

OAK-D OpenCV DepthAIカメラ - スイッチサイエンス (switch-science.com)

スイッチサイエンスで発売日(2021/7/5)に発注、翌日納品。
購入時は在庫多数だったのに、初日か2日目に売り切れになった模様。

f:id:snflwr59:20210708225933j:plain

OAK-D

Luxonis Holding Corporation (github.com) 以下の
depthai
depthai-experiments
depthai-python
などを一通り試してみた。
requirements.txtがサンプルによってまちまちな上に==指定ばかり。
とりあえず試したかったのでpip install -r

あとは人の姿勢推定を見たかったので、blazeposeの以下のリポジトリを試す。
geaxgx/depthai_blazepose (github.com)

open3dはpython 3.9だと入らない。winpython3.8を入れて無事動作。

f:id:snflwr59:20210708233614p:plain

Blazepose (skeleton in 3D)

サンプルコードがたくさんあって、動かすだけで満足してしまいそう。

バイス側にMyriadXが入っているので、それなりに高フレームレートで動作する。

 

知りたい点:
・MyriadXに処理させるにはどういうように記載すればよいのか不明。次はこの辺を調べる?
・4K RGBカメラはチャット用カメラとして使えないんだろうか。

チュートリアルのメモ

機械学習
DL4US(https://weblab.t.u-tokyo.ac.jp/dl4us/)
 東大 松尾研が公開。エンジニア向けDeep Learning講座。Jupyter notebook形式。
 ライブラリはKerasと、Numpy, Scipy, Scikit-learn等の標準的なものに限られている。

 
Chainer(https://tutorials.chainer.org/ja/)
 Preferred Networksが公開。
 Python, 数学, Pythonライブラリの説明の後、DeepLearning入門としてChainerについて解説。


Raspberry Pi関連:
 Raspberry PiGPGPU : https://qiita.com/9_ties/items/2e85318989170f967e4b
  PyVideoCore(Pythonライブラリ) : https://github.com/nineties/py-videocore
 Raspberry PiGPUで行列乗算(その1) : https://qiita.com/9_ties/items/15ab7fa198991a61a3a9
 Raspberry PiGPUで行列乗算(その2) : https://qiita.com/9_ties/items/e0fdd165c1c7df6bb8ee
 Raspberry PiGPU数値計算: (1)QPUと数値計算 : http://qiita.com/Terminus-IMRC/items/7406fa835d6510790406
 Raspberry PiGPU数値計算: (2)QPUの特徴 : https://qiita.com/Terminus-IMRC/items/c2b3ef492fe9c018d6ff
 Raspberry Pi QPU における逆数計算と精度補正 : https://qiita.com/ysugi/items/e3118ada915d2a6485eb
 Actcast : https://actcast.io/docs/ja/GettingStarted/
  Idein社の社員が公開。
  RaspberryPiのGPU VideoCoreIVを使ってGPGPUをする際のTipsでgemmが実装済
  既存の機械学習の計算をPyVideoCoreに置き換えると、RaspberryPiでも高速化が望めるはず。
  これを適応したものがActcastであるが、確かにRaspberry Piにしては早い。
  機械学習の理解とハードウェア/ミドルウェアの使いこなし理解で丁度よさそうな題材。


Jetson nano関連:
 Jetson Nano関係のTIPSまとめ(https://qiita.com/karaage0703/items/b14c249aa33112669ee4)
 karaageさんが公開。
 セットアップから物体検出まで書かれている通りにやれば動く。
 が、これだけやり終えると満足できてしまい、思考停止になる。
 Kerasと学習済データの使い方をきちんとマスターするといろいろ広がる。

Raspberry Pi Zero W

1.Raspberry Pi Zero Wを購入

www.switch-science.com在庫切れだったけど、メール登録→ほどなく連絡。

 

2.セットアップ 

Raspberry Pi初心者のためのOS別セットアップガイド | ライフハッカー[日本版]
Win32DiskImagerでSDカードに書き込み

Windows10でRaspberry Pi Zero (W) をOTGを使ってセットアップする - Qiita
SSH有効化・Teratermでアクセス、VNCセットアップ・ログインまではこちら 

Raspberry Pi ZeroとZero Wセットアップ 完全ガイド – Blue-black.ink
第7, 8, 10, 11回を参照

 

3.なにか動かす

ラズパイ + Bottleでお手軽にIoT環境を作る - Qiita
とりあえず、Webサーバーとして動くことは確認。