RaspberryPi と Movidius ではじめる OpenVINO 深層学習入門２

# RaspberryPi と Movidius ではじめる OpenVINO 深層学習２
OpenVINO をはじめて利用する方向けの、基礎的な説明やインストールについては、以下の記事をご参照下さい。
[RaspberryPi と Movidius ではじめる OpenVINO 深層学習入門](https://qiita.com/tagucchan/items/4ba77c754d41582f412f "RaspberryPi と Movidius ではじめる OpenVINO 深層学習入門")

この記事では、[https://download.01.org/opencv/2019/open_model_zoo/R3/のサンプル](https://download.01.org/opencv/2019/open_model_zoo/R3/20190905_163000_models_bin/ "https://download.01.org/opencv/2019/open_model_zoo/R3/のサンプル")が色々とありますので、RaspberryPi と Movidiusの環境で動作させる方法の例を解説します。

今回試したもの以外にも色々と用意されていますので、試しに動かしてみてください。

各サンプルの解説ページはこちら(2020/01/08時点)：
https://docs.openvinotoolkit.org/latest/usergroup1.html

各サンプルのモデルダウンロード先はこちら(2020/01/08時点)：
https://download.01.org/opencv/2019/open_model_zoo/R3/20190905_163000_models_bin/
## person-vehicle-bike-detection-crossroad-0078を試す
交差点で、人、車、バイク（自転車）を認識するサンプルです。
[person-vehicle-bike-detection-crossroad-0078](https://docs.openvinotoolkit.org/latest/_models_intel_person_vehicle_bike_detection_crossroad_0078_description_person_vehicle_bike_detection_crossroad_0078.html"person-vehicle-bike-detection-crossroad-0078")

### OpenVINO用の作業ディレクトリ"~/OpenVINO"配下にディレクトリ"person-vehicle-bike-detection-crossroad-0078"を作成

~~~
pi@raspberrypi:~ $ cd ~/OpenVINO
pi@raspberrypi:~/OpenVINO $ mkdir person-vehicle-bike-detection-crossroad-0078 && cd person-vehicle-bike-detection-crossroad-0078
~~~

### Object Detection(物体検出) サンプルをビルドします

~~~
pi@raspberrypi:~/OpenVINO/face-detection $ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=armv7-a" /opt/intel/openvino/deployment_tools/inference_engine/samples
~~~

最後に以下が表示され、ビルドファイルが作成できたことを確認します。

~~~
-- Build files have been written to: /home/pi/OpenVINO/person-vehicle-bike-detection-crossroad-0078
~~~

make します。
少し時間がかかります。

~~~
pi@raspberrypi:~/OpenVINO/person-vehicle-bike-detection-crossroad-0078 $ make -j2 object_detection_sample_ssd
~~~

### トレーニング済のモデルをダウンロードします

~~~
pi@raspberrypi:~/OpenVINO/person-vehicle-bike-detection-crossroad-0078 $ wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R3/20190905_163000_models_bin/person-vehicle-bike-detection-crossroad-0078/FP16/person-vehicle-bike-detection-crossroad-0078.bin
~~~

~~~
pi@raspberrypi:~/OpenVINO/person-vehicle-bike-detection-crossroad-0078 $ wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R3/20190905_163000_models_bin/person-vehicle-bike-detection-crossroad-0078/FP16/person-vehicle-bike-detection-crossroad-0078.xml
~~~

### テストします
テストのために、交差点の画像ファイル　kudanshita_sample.bmp　を用意しました
置き場所は~/OpenVINO/person-vehicle-bike-detection-crossroad-0078ディレクトリ内

~~~
pi@raspberrypi:~/OpenVINO/person-vehicle-bike-detection-crossroad-0078 $ ./armv7l/Release/object_detection_sample_ssd -m person-vehicle-bike-detection-crossroad-0078.xml -d MYRIAD -i /home/pi/OpenVINO/person-vehicle-bike-detection-crossroad-0078/kudanshita_sample.bmp
~~~

実行例：

~~~
pi@raspberrypi:~/OpenVINO/person-vehicle-bike-detection-crossroad-0078 $ ./armv7l/Release/object_detection_sample_ssd -m person-vehicle-bike-detection-crossroad-0078.xml -d MYRIAD -i /home/pi/OpenVINO/person-vehicle-bike-detection-crossroad-0078/kudanshita_sample.bmp
[ INFO ] InferenceEngine: 
	API version ............ 2.1
	Build .................. custom_releases/2019/R3_cb6cad9663aea3d282e0e8b3e0bf359df665d5d0
	Description ....... API
Parsing input parameters
[ INFO ] Files were added: 1
[ INFO ]     /home/pi/OpenVINO/person-vehicle-bike-detection-crossroad-0078/kudanshita_sample.bmp
[ INFO ] Loading Inference Engine
[ INFO ] Device info: 
	MYRIAD
	myriadPlugin version ......... 2.1
	Build ........... 30677
[ INFO ] Loading network files:
	person-vehicle-bike-detection-crossroad-0078.xml
	person-vehicle-bike-detection-crossroad-0078.bin
[ INFO ] Preparing input blobs
[ INFO ] Batch size is 1
[ INFO ] Preparing output blobs
[ INFO ] Loading model to the device
[ INFO ] Create infer request
[ WARNING ] Image is resized from (640, 480) to (1024, 1024)
[ INFO ] Batch size is 1
[ INFO ] Start inference
[ INFO ] Processing output blobs
[0,1] element, prob = 0.998047    (9,304)-(38,386) batch id : 0 WILL BE PRINTED!
[1,1] element, prob = 0.97998    (395,304)-(439,392) batch id : 0 WILL BE PRINTED!
[2,1] element, prob = 0.974121    (44,306)-(73,386) batch id : 0 WILL BE PRINTED!
[3,1] element, prob = 0.96875    (478,306)-(530,406) batch id : 0 WILL BE PRINTED!
[4,1] element, prob = 0.602051    (0,306)-(24,380) batch id : 0 WILL BE PRINTED!
[5,1] element, prob = 0.384521    (170,306)-(181,336) batch id : 0
[6,1] element, prob = 0.283936    (572,308)-(580,332) batch id : 0
[7,1] element, prob = 0.224854    (593,311)-(599,330) batch id : 0
[8,1] element, prob = 0.185547    (602,310)-(608,329) batch id : 0
[9,1] element, prob = 0.183594    (370,309)-(380,328) batch id : 0
[10,1] element, prob = 0.169434    (99,351)-(116,393) batch id : 0
[11,1] element, prob = 0.159546    (550,315)-(557,330) batch id : 0
[12,1] element, prob = 0.148193    (128,300)-(159,339) batch id : 0
[13,1] element, prob = 0.141724    (543,316)-(549,330) batch id : 0
[14,1] element, prob = 0.140137    (533,316)-(540,330) batch id : 0
[15,1] element, prob = 0.135376    (581,311)-(586,327) batch id : 0
[16,1] element, prob = 0.130005    (222,312)-(244,336) batch id : 0
[17,1] element, prob = 0.122803    (160,309)-(167,326) batch id : 0
[18,1] element, prob = 0.121155    (409,262)-(420,298) batch id : 0
[19,1] element, prob = 0.119385    (508,317)-(518,334) batch id : 0
[20,1] element, prob = 0.115723    (202,304)-(210,330) batch id : 0
[21,1] element, prob = 0.115112    (54,308)-(86,389) batch id : 0
[22,1] element, prob = 0.11377    (399,303)-(430,356) batch id : 0
[23,1] element, prob = 0.113464    (192,308)-(197,325) batch id : 0
[24,1] element, prob = 0.110657    (182,309)-(187,326) batch id : 0
[25,1] element, prob = 0.108093    (163,307)-(173,330) batch id : 0
[26,1] element, prob = 0.104553    (217,309)-(234,333) batch id : 0
[27,1] element, prob = 0.1026    (244,311)-(266,337) batch id : 0
[28,1] element, prob = 0.102173    (153,309)-(161,327) batch id : 0
[29,1] element, prob = 0.102173    (210,303)-(220,333) batch id : 0
[30,1] element, prob = 0.100403    (235,312)-(255,337) batch id : 0
[31,1] element, prob = 0.100159    (368,300)-(385,326) batch id : 0
[32,1] element, prob = 0.0998535    (248,299)-(263,331) batch id : 0
[33,1] element, prob = 0.0993042    (543,309)-(554,330) batch id : 0
[34,1] element, prob = 0.098938    (430,304)-(459,344) batch id : 0
[35,1] element, prob = 0.0982666    (146,305)-(162,331) batch id : 0
[36,1] element, prob = 0.0973511    (-1,304)-(13,368) batch id : 0
[37,1] element, prob = 0.0964355    (523,313)-(529,328) batch id : 0
[38,1] element, prob = 0.0963135    (205,306)-(215,332) batch id : 0
[39,1] element, prob = 0.0942993    (240,287)-(249,310) batch id : 0
[40,1] element, prob = 0.0934448    (433,302)-(482,352) batch id : 0
[41,1] element, prob = 0.0922241    (303,311)-(327,337) batch id : 0
[42,1] element, prob = 0.0916138    (389,294)-(405,317) batch id : 0
[43,1] element, prob = 0.0914917    (596,309)-(604,330) batch id : 0
[44,1] element, prob = 0.0913086    (126,280)-(142,330) batch id : 0
[45,1] element, prob = 0.0912476    (391,296)-(399,312) batch id : 0
[46,1] element, prob = 0.0909424    (219,310)-(228,327) batch id : 0
[47,1] element, prob = 0.0905762    (295,312)-(318,338) batch id : 0
[48,1] element, prob = 0.090332    (271,282)-(279,308) batch id : 0
[49,1] element, prob = 0.0889282    (422,305)-(447,345) batch id : 0
[50,1] element, prob = 0.0883179    (400,304)-(407,319) batch id : 0
[51,1] element, prob = 0.0881958    (496,313)-(516,340) batch id : 0
[52,1] element, prob = 0.0870972    (620,311)-(627,328) batch id : 0
[53,1] element, prob = 0.0866699    (487,301)-(503,343) batch id : 0
[54,1] element, prob = 0.0862427    (413,288)-(419,302) batch id : 0
[55,1] element, prob = 0.0861816    (409,253)-(418,281) batch id : 0
[56,1] element, prob = 0.0861206    (38,294)-(54,333) batch id : 0
[57,1] element, prob = 0.0859375    (250,285)-(265,307) batch id : 0
[58,1] element, prob = 0.0858154    (511,314)-(518,328) batch id : 0
[59,1] element, prob = 0.0847778    (284,252)-(305,308) batch id : 0
[60,1] element, prob = 0.0844727    (67,318)-(97,391) batch id : 0
[61,1] element, prob = 0.0844116    (373,291)-(379,301) batch id : 0
[62,1] element, prob = 0.0841064    (476,304)-(493,343) batch id : 0
[63,1] element, prob = 0.0839233    (410,272)-(418,291) batch id : 0
[64,1] element, prob = 0.0838013    (292,295)-(297,309) batch id : 0
[65,1] element, prob = 0.0837402    (411,278)-(418,297) batch id : 0
[66,1] element, prob = 0.0836182    (202,305)-(207,322) batch id : 0
[67,1] element, prob = 0.0835571    (250,302)-(260,322) batch id : 0
[68,1] element, prob = 0.083313    (213,308)-(220,327) batch id : 0
[69,1] element, prob = 0.0825806    (86,336)-(103,382) batch id : 0
[70,1] element, prob = 0.0822144    (391,291)-(398,302) batch id : 0
[71,1] element, prob = 0.0819702    (239,290)-(250,322) batch id : 0
[72,1] element, prob = 0.0819092    (290,284)-(298,308) batch id : 0
[73,1] element, prob = 0.0817871    (259,282)-(269,308) batch id : 0
[74,1] element, prob = 0.0817871    (460,304)-(468,318) batch id : 0
[75,1] element, prob = 0.0817871    (483,308)-(513,350) batch id : 0
[76,1] element, prob = 0.081665    (565,310)-(574,330) batch id : 0
[77,1] element, prob = 0.0811157    (382,291)-(388,301) batch id : 0
[78,1] element, prob = 0.0809937    (530,302)-(541,331) batch id : 0
[79,2] element, prob = 0.0658569    (314,448)-(377,478) batch id : 0
[80,2] element, prob = 0.0534668    (240,237)-(311,272) batch id : 0
[81,2] element, prob = 0.051239    (128,301)-(159,339) batch id : 0
[ INFO ] Image out_0.bmp created!
[ INFO ] Execution successful

[ INFO ] This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool
~~~

## 処理前のビットマップ画像（kudanshita_sample.bmp）：
Qiitaで表示するために、Jpeg形式に変換しています
![kudanshita_sample.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/273559/a96f0221-0d4c-3a32-9d84-fb1a46ffd152.jpeg)

## 処理後のビットマップ画像（out_0.bmp）：
Qiitaで表示するために、Jpeg形式に変換しています
（遠くの方は認識できていませんが、手前の歩行者は認識できています）
![out_0.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/273559/a65daf10-1175-2e0e-bf73-e27595e91de2.jpeg)