LoginSignup
63
39

More than 5 years have passed since last update.

Intelさんがまた褒めてくれたヽ(゚∀゚)ノ イエァ RaspberryPi3でMobileNet-SSD(MobileNetSSD)物体検出とRealSense測距(640x480) 再生フレームレート25FPS以上 + 予測レート12FPSを達成したよ

Last updated at Posted at 2018-07-21

MobileNet-SSD-RealSense GitHub stars
I wrote an English translation at the end of the article
画像サイズが大きいため、Wi-Fi環境下での閲覧を推奨

◆ 前回記事

デプスカメラRealSenseD435で "紫色のイカ" や "オレンジ色の玉ねぎ" を切り取ったり "金髪の人" を追っかけて距離を測る(1) with Ubuntu16.04

デプスカメラRealSenseD435で "紫色のイカ" や "オレンジ色の玉ねぎ" を切り取ったり "金髪の人" を追っかけて距離を測る(2) with RaspberryPi3 (Raspbian Stretch)

RaspberryPi3 (Raspbian Stretch) + Intel Movidius Neural Compute Stick(NCS) + RealSenseD435 + MobileNet-SSD で高速に物体検出しつつ悟空やモニタまでの距離を測る

の続き

◆ はじめに

つまんない? そうですね。 しつこくてすみません。
きっと驚くと思うので、まぁそう言わずに軽く寄り道していってください。

エモい記事 を書かないと 「いいね」 は、ほとんどもらえない傾向が強いが、体力が無いので適当に書き流す。
世間は厳しい、いや、日本人は変に厳しい。。。
情け深い方は、どうか ポチッ てあげてくださいw

これなら使えるレベルじゃね? という程度に更にゴリゴリにパフォーマンスアップした。
ARM Quad Core と Pythonナメんなよ。
RealSense D435利用前提のプログラムだが、一般的なUSBカメラのロジックに変更するのは難しいことではない。
2018/07/23 USBカメラモードを追加

入力解像度を4倍にしたうえで、下記記事の2倍以上のパフォーマンスが出る。
当然ながら、プレディクションレートはスティックの限界性能以上には上がらない。
プレディクションレートを欲張るなら、TX2 や UP Board2 を素直に購入しよう。
あるいは、距離を測る必要がなければ、普通の安物USBカメラで 320x240 の低解像度でトライしよう。
YoloV2 より超速 MobileNetSSD+Neural Compute Stick(NCS)+Raspberry Piによる爆速・高精度の複数動体検知

カメラ映像の再生レート: 25FPS 〜 30FPS (カメラ本体のRealSenseは30FPSで撮像)
プレディクションレート: 8FPS 〜 12FPS
入力解像度: 640x480 (前回の4倍の解像度←ココ重要、RealSenseだとこれ以上解像度を落とせない)

25FPS 達成報告をした公式フォーラムへの投稿 【Intel Movidius Neural Network Community】
RealSense D435 + Neural Compute Stick + MobileNet-SSD + RaspberryPi3

では、まわりくどいことは置いておいて、実際にモノを見ていただこうと思う。
ARMクアッドコアをフル稼働させるとこうなる。
非同期なのでカメラを素早く動かし過ぎると枠がズレる。
今度はカメラ撮影レートが早すぎてプレディクションが追いつかず、前回よりズレが大きくなった。
速さ至上主義ではなく小綺麗に見せたいなら、前回程度のバランスが良いかもしれない。
【Youtube動画 生の再生スピード】 https://youtu.be/tAf1u9DKkh4
【GIF画像 10FPSまで劣化させてある、TV Monitorの検出と測距スピードがエグい】
ezgif.com-gif-maker (1).gif
※右上に表示されているフレームレートは15フレーム分の平均をとって表示している。

【USBカメラモード 640x480 MultiStick x4 (日本ではコレを4倍界王拳と呼ぶ、気持ち悪い、何故か犬判定が混じる)】
【Youtube動画 生の再生スピード】 https://youtu.be/GedDpAc0JyQ
ezgif.com-optimize (25).gif

【2018/08/03 複数物体を一斉に背景透過するモードを追加 (スピードを犠牲にしてMobileNetSSDで検出した複数の物体の背景を一気に透過する、検出対象物の距離はマチマチで良い、SSDの精度が低いためかなりズレる、ラズパイで処理していることを考えれば上出来か)】
RealSense必須
【Youtube動画】 https://youtu.be/ApyX-mN_dYA
12.gif
 
 
Githubに公開したプログラムソースはこちら
PINTO0309/MobileNet-SSD-RealSense

◆ 環境

1.RaspberryPi3 + Raspbian Stretch (USB2.0 Port)
2.Intel RealSense D435 (640x480) or USBカメラ
3.Intel Movidius Neural Compute Stick 1本 ← 【注意】マルチスティック(MultiStick)もOKだけどレンダリングが引きずられて逆に遅くなる
4.OpenCV3.4.2
5.VFPV3
6.Numpy
7.Python3.5 + MultiProcessing
8.NCSDK v2.05.00.02
9.Intel TBB ← 今回は無効にした
10.OpenGL Driver ← 今回は無効にした
11.HDMIディスプレイ

◆ 参考にさせていただいた記事、謝辞

【くろのてさん】 [Python] multiprocessing 備忘録
http://note.crohaco.net/2017/python-multiprocessing/

【Python公式チュートリアル】
https://docs.python.jp/3/library/multiprocessing.html

◆ 作業に着手する前の前提条件

下記記事を参考に、NCSDK v2.xx や RealSenseSDK や OpenCV3.4、そのほか諸々が導入済みであること。

(1) デプスカメラRealSenseD435で "紫色のイカ" や "オレンジ色の玉ねぎ" を切り取ったり "金髪の人" を追っかけて距離を測る(2) with RaspberryPi3 (Raspbian Stretch)

(2) RaspberryPi3 (Raspbian Stretch) + Intel Movidius Neural Compute Stick NCSDK v2.05 のインストール

◆ レシピ

1.Git Clone する。

リソース一式のクローン
$ cd ~
$ git clone https://github.com/PINTO0309/MobileNet-SSD-RealSense.git

2.Neural Compute Stick 1本 と RealSense をUSBポートにぶっ刺す。

3.実行する。いじょ。

プレディクションの実行
$ sudo raspi-config
"7.Advanced Options" - "A7 GL Driver" - "G3 Legacy"

$ cd ~/MobileNet-SSD-RealSense
$ python3 MultiStickSSDwithRealSense.py

◆ まとめ

  • RaspberryPi3 Model B (プラス無し) をナメちゃダメ
  • ARM 4Core ナメちゃダメ
  • Python ナメちゃダメ
  • Python の MultiThread はゴミ "Global Interpreter Lock" (通称:GIL)
  • 消費電力を気にしないなら multiprocessing
  • OpenVINOの推論エンジンが NCSDK と同じ という情報を得たため、テンションが上がり気味
  • あらためて OpenVINO の調査を再開する見込み
  • OpenVINOについては こちら の一番下のところを参照
  • 暇な人、320x240のカメラ解像度で試してみてください ← Git Clone で試せます。RealSenseより何故か検出が速くてキモいです。
  • RaspberryPi3 Model B+ 欲しいなぁ。。。
  • TX2 欲しいなぁ。。。
  • 無言でCaffe超軽量モデルを量産してくださる、そんな神が降臨することを願って止まない
  • "ディープラーニングおじさん" ではないので、流行りモノに手を出して勝てるとも思わないし、勝とうとも思わない、安価・実用・実装に特化したコトにしか興味が沸かない悪いクセ
  • 【2018/08/04追記】 OpenVINOがどうしてもエッジで使いたくて予約購入してしまった。。。
    9月出荷予定らしい。
    LattePanda Alpha 864 – Tiny Ultimate Windows/Linux Device
    https://www.dfrobot.com/product-1728.html

    DFR0544-450x300.jpg
  • 【2018/08/04追記】 TX2のキャリアボードのコイツも気になる。が、TX2を所有していない。
    RaspberryPi3より縦横2cmほど大きいが、TX2の開発ボードの巨大さからするとだいぶマシ。
    Pico-ITX Carrier Board for NVIDIA Jetson TX1 and Jetson TX2
    https://www.avermedia.com/professional/product/ex731_aa/overview
    EX731-AA_3.png

◆ 次回記事

[検出レート約30FPS] RaspberryPi3 Model B(プラスなし) で TX2 "より少し遅い" MobilenetSSDの物体検出レートを獲得しつつ MultiModel (VOC+WIDER FACE) に対応する へ続く
 
 

◆ English Article

Intel also praised me again ヽ(゚∀゚)ノ Yeah
MobileNet-SSD(MobileNetSSD) object detection and RealSense distance measurement (640x480) with RaspberryPi3 At least 25FPS playback frame rate + 12FPS prediction rate

◆ Previous article

Cut away "purple squid" or "orange colored onion" with the depth camera RealSense D435 and measure the distance by following "blonde person" (1) with Ubuntu16.04

With depth camera RealSense D 435 cut away "purple squid" or "orange colored onion" and measure "distance" by following "blonde person" (2) with RaspberryPi3 (Raspbian Stretch)

RaspberryPi3 (Raspbian Stretch) + Intel Movidius Neural Compute Stick(NCS) + RealSense D435 + Measure the distance to Goku and the monitor while detecting objects at high speed with MobileNet-SSD

◆ Introduction

Camera image playback rate: 25FPS to 30FPS (RealSense of the camera body is captured at 30FPS)
Prediction rate: 8FPS to 12FPS
Input resolution: 640x480 (4 times the previous resolution ← important here, RealSense can not lower the resolution any more)

When ARM quad core is fully operated, it becomes like this.
Since it is asynchronous, if the camera is moved too quickly, the frame shifts.
The camera shooting rate was so fast that the prediction could not catch up and the gap became bigger than last time.
If you want to show it beautifully rather than speed supremacy, the balance of the previous survey may be good.

Posting to the official forum which reported achievement of 25FPS 【Intel Movidius Neural Network Community】
RealSense D435 + Neural Compute Stick + MobileNet-SSD + RaspberryPi3

【Youtube video raw playback speed】 https://youtu.be/tAf1u9DKkh4
※The frame rate displayed in the upper right is displayed taking an average of 15 frames.

【USB camera mode 640x480 MultiStick x4 (In Japan, call this as the "4-bai-kai-o-ken", somehow mixed with dog judgment)】
【Youtube video raw playback speed】 https://youtu.be/GedDpAc0JyQ

【2018/08/03 Add mode for transparently transmitting multiple objects at the same time (passing the background of multiple objects detected by MobileNetSSD at the expense of speed at once, the distance of the object to be detected is good, the accuracy of SSD is Because it is low, it shifts pretty much, considering what it is processing with laspai is good】

RealSense required
【Youtube video raw playback speed】 https://youtu.be/ApyX-mN_dYA

Here is the program source released to Github
PINTO0309/MobileNet-SSD-RealSense

◆ Environment

  1. RaspberryPi 3 + Raspbian Stretch (USB2.0 Port)
  2. Intel RealSense D435 (640x480) or USB camera
  3. Intel Movidius Neural Compute Stick x1
  4. OpenCV 3.4.2
  5. VFPV 3
  6. Numpy
  7. Python 3.5 + MultiProcessing
  8. NCSDK v2.05.00.02
  9. HDMI display

◆ Prerequisites before starting work

Based on the following article, NCSDK v2.xx, RealSense SDK, OpenCV3.4, various others have been installed.

(1) With depth camera RealSense D435 cut away "purple squid" or "orange colored onion" and measure "distance" by following "blonde person" (2) with RaspberryPi 3 (Raspbian Stretch)

(2) Installation of RaspberryPi3 (Raspbian Stretch) + Intel Movidius Neural Compute Stick NCSDK v2.05

◆ Recipes

1.Git Clone.

Clone_of_a_set_of_resources
$ cd ~
$ git clone https://github.com/PINTO0309/MobileNet-SSD-RealSense.git

2.Stick one Neural Compute Stick and RealSense into the USB port.

3.Execute.

Execution_of_prediction
$ sudo raspi-config
"7.Advanced Options" - "A7 GL Driver" - "G3 Legacy"

$ cd ~/MobileNet-SSD-RealSense
$ python3 MultiStickSSDwithRealSense.py

◆ Next article

[Detection rate approx. 30FPS] RaspberryPi3 Model B(plus none) is slightly later than TX2 acquires object detection rate of MobilenetSSD and corresponds to MultiModel (VOC+WIDER FACE)

63
39
4

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
63
39