security barrier cameraで動作を学ぶ
Openvino toolkitをインストールした際にデモ実行するsecurity_barrier_camera_demoで詳しく見てみます
実行環境
CPU: Intel(R) Core(TM) i7-6770HQ CPU @ 2.60GHz
MemTotal: 16318440 kB
OS: Ubuntu 16.04LTS
スクリプトを見る
通常は/opt/intel/openvino/deployment_tools/demo 内に格納されている、demo_security_barrier_camera.shの動作を確認します
スクリプトは4つのパートに分かれています
# Step 1. Downloading Intel models
一つ目のパートは、モデルダウンロードです
このパートはdownloaderを使用して、自動的にsecurity_burrier_camera_demoで使用されるモデルをダウンロードします
# Step 2. Build samples
ホームディレクトリにinference_engine_demos_buildというフォルダを作成して、実行ファイルを作成します
# Step 3. Run samples
実際にプログラムを実行する部分です
print_and_run ./security_barrier_camera_demo -d "$target" -d_va "$target" -d_lpr "$target" -i "$target_image_path" "${model_args[@]}" ${sampleoptions}
上記のコマンドが実行部分の本体となります
シェルスクリプトで、毎回モデルをダウンロードしたり、ビルドしているのは大変なので、実行部分だけを抜き出すと便利です
プログラムの実行
実行部分だけを抜き出したプログラムで実行してみましょう
inference_engine_demos_build/intel64/Release/security_barrier_camera_demo -h interactive_vehicle_detection [OPTION] Options: -h Print a usage message. -i "<path1>" "<path2>" Required for video or image files input. Path to video or image files. -m "<path>" Required. Path to the Vehicle and License Plate Detection model .xml file. -m_va "<path>" Optional. Path to the Vehicle Attributes model .xml file. -m_lpr "<path>" Optional. Path to the License Plate Recognition model .xml file. -l "<absolute_path>" Required for CPU custom layers. Absolute path to a shared library with the kernels implementation. Or -c "<absolute_path>" Required for GPU custom kernels. Absolute path to an .xml file with the kernels description. -d "<device>" Optional. Specify the target device for Vehicle Detection (the list of available devices is shown below). Default value is CPU. Use "-d HETERO:<comma-separated_devices_list>" format to specify HETERO plugin. The application looks for a suitable plugin for the specified device. -d_va "<device>" Optional. Specify the target device for Vehicle Attributes (the list of available devices is shown below). Default value is CPU. Use "-d HETERO:<comma-separated_devices_list>" format to specify HETERO plugin. The application looks for a suitable plugin for the specified device. -d_lpr "<device>" Optional. Specify the target device for License Plate Recognition (the list of available devices is shown below). Default value is CPU. Use "-d HETERO:<comma-separated_devices_list>" format to specify HETERO plugin. The application looks for a suitable plugin for the specified device. -pc Optional. Enables per-layer performance statistics. -r Optional. Output inference results as raw values. -t Optional. Probability threshold for vehicle and license plate detections. -no_show Optional. Do not show processed video. -auto_resize Optional. Enable resizable input with support of ROI crop and auto resize. -nireq Optional. Number of infer requests. 0 sets the number of infer requests equal to the number of inputs. -nc Required for web camera input. Maximum number of processed camera inputs (web cameras). -fpga_device_ids Optional. Specify FPGA device IDs (0,1,n). -loop_video Optional. Enable playing video on a loop. -n_iqs Optional. Number of allocated frames. It is a multiplier of the number of inputs. -ni Optional. Specify the number of channels generated from provided inputs (with -i and -nc keys). For example, if only one camera is provided, but -ni is set to 2, the demo will process frames as if they are captured from two cameras. 0 sets the number of input channels equal to the number of provided inputs. -fps Optional. Set the playback speed not faster than the specified FPS. 0 removes the upper bound. -n_wt Optional. Set the number of threads including the main thread a Worker class will use. -display_resolution Optional. Specify the maximum output window resolution. -tag Required for HDDL plugin only. If not set, the performance on Intel(R) Movidius(TM) X VPUs will not be optimal. Running each network on a set of Intel(R) Movidius(TM) X VPUs with a specific tag. You must specify the number of VPUs for each network in the hddl_service.config file. Refer to the corresponding README file for more information. -nstreams "<integer>" Optional. Number of streams to use for inference on the CPU or/and GPU in throughput mode (for HETERO and MULTI device cases use format <device1>:<nstreams1>,<device2>:<nstreams2> or just <nstreams>) -nthreads "<integer>" Optional. Number of threads to use for inference on the CPU (including HETERO and MULTI cases). -u Optional. List of monitors to show initially. Available target devices: CPU GPU MYRIAD
ターゲットデバイスはCPU、GPU、MYRIAD(NCS2)が使用可能です
Vehicle Detection用のデバイスを指定する場合には、-dオプション
Vehicle Attributes用のデバイスを指定する場合には、-d_vaオプション
License Plate Recognition用のデバイスを指定する場合には、-d_lprオプション を使用します
それぞれの推論にはモデルの指定が必要となります
こちらの指定には、-m, -m_va, -m_lprオプションを使用します
それらをふまえて、下記のコマンドをXwindowが実行されている端末で実行します
プログラムの実行
inference_engine_demos_build/intel64/Release/security_barrier_camera_demo -d CPU -d_va CPU -d_lpr CPU -i /opt/intel/openvino/deployment_tools/demo/car_1.bmp -m /home/skullcanyon/openvino_models/ir/intel/vehicle-license-plate-detection-barrier-0106/FP16/vehicle-license-plate-detection-barrier-0106.xml -m_lpr /home/skullcanyon/openvino_models/ir/intel/license-plate-recognition-barrier-0001/FP16/license-plate-recognition-barrier-0001.xml -m_va /home/skullcanyon/openvino_models/ir/intel/vehicle-attributes-recognition-barrier-0039/FP16/vehicle-attributes-recognition-barrier-0039.xml
少し長いコマンドですが、実行するとウィンドウが表示され、ナンバープレートが認識されているのがわかります

車両位置認識を行っているのが、Vehicle Detection、
色検出を行っているのが、Vehicle Attribute、
ナンバープレートは、License Plate Recognitionとなります
ウィンドウなしでの実行
オプションに-no_showを与えると、cli上の結果表示となります
klf@skullcanyon:~$ inference_engine_demos_build/intel64/Release/security_barrier_camera_demo -d CPU -d_va CPU -d_lpr CPU -i /opt/intel/openvino/deployment_tools/demo/car_1.bmp -m /home/klf/openvino_models/ir/intel/vehicle-license-plate-detection-barrier-0106/FP16/vehicle-license-plate-detection-barrier-0106.xml -m_lpr /home/klf/openvino_models/ir/intel/license-plate-recognition-barrier-0001/FP16/license-plate-recognition-barrier-0001.xml -m_va /home/klf/openvino_models/ir/intel/vehicle-attributes-recognition-barrier-0039/FP16/vehicle-attributes-recognition-barrier-0039.xml -no_show [ INFO ] InferenceEngine: 0x7f571ad8b040 [ INFO ] Files were added: 1 [ INFO ] /opt/intel/openvino/deployment_tools/demo/car_1.bmp [ INFO ] Loading device CPU CPU MKLDNNPlugin version ......... 2.1 Build ........... 37988 [ INFO ] Loading detection model to the CPU plugin [ INFO ] Loading Vehicle Attribs model to the CPU plugin [ INFO ] Loading Licence Plate Recognition (LPR) model to the CPU plugin [ INFO ] Number of InferRequests: 1 (detection), 3 (classification), 3 (recognition) [ INFO ] 4 streams for CPU [ INFO ] Display resolution: 1920x1080 [ INFO ] Number of allocated frames: 3 [ INFO ] Resizable input with support of ROI crop and auto resize is disabled 59.7FPS for (1 / 1) frames Detection InferRequests usage: 100.0% [ INFO ] Execution successful
CPUだけで実行すると、59.7FPSの結果となりました
様々なデバイスでの実行
今回使用した環境では3つのデバイスが選択できましたので、それぞれの推論エンジンにそれぞれデバイス設定を行いました
下記の表がそれぞれの処理結果となります
(下記の結果はそれぞれ10回実行後の平均値となります)
-d | -d_va | -d_lpr | FPS |
CPU | CPU | CPU | 52.2 |
|
| GPU | 87.7 |
|
| MYRIAD | 65.3 |
| GPU | CPU | 53.3 |
|
| GPU | 74.8 |
|
| MYRIAD | 51.0 |
| MYRIAD | CPU | 52.5 |
|
| GPU | 77.71 |
|
| MYRIAD | 61.6 |
GPU | CPU | CPU | 51.3 |
|
| GPU | 89.3 |
|
| MYRIAD | 50.4 |
| GPU | CPU | 52.5 |
|
| GPU | 73.7 |
|
| MYRIAD | 56.2 |
| MYRIAD | CPU | 53.1 |
|
| GPU | 88.1 |
|
| MYRIAD | 57.1 |
MYRIAD | CPU | CPU | 26.46 |
|
| GPU | 30.2 |
|
| MYRIAD | 28.09 |
| GPU | CPU | 26.6 |
|
| GPU | 28.5 |
|
| MYRIAD | 28.0 |
| MYRIAD | CPU | 28.04 |
|
| GPU | 29.3 |
|
| MYRIAD | 25.8 |
続く

産業用画像処理装置開発、
ゲームコンソール開発、半導体エンジニアなどを経て、
Webエンジニア&マーケティングをやっています
好きな分野はハードウェアとソフトウェアの境界くらい