Raspberry pi 4 + openvion + ncs2

Raspberry Pi 4 的 Raspbian OS 安裝 OpenVINO

使用 ncs2 加速棒 執行 deeplabv3

更新

sudo apt update && sudo apt upgrade -y && \
sudo apt install -y build-essential && \
sudo apt install -y git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libatlas-base-dev python3-scipy

CMake(make -j4 可用 grep -c ^processor /proc/cpuinfo 查詢核心數量)

cd ~/ && \
wget https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4.tar.gz && \
tar xvzf cmake-3.14.4.tar.gz && \
cd ~/cmake-3.14.4 && \
./bootstrap && \
make -j2 && \
sudo make install

opencv

cd ~/ && \
git clone --depth 1 --branch 4.5.2 https://github.com/opencv/opencv.git && \
cd opencv && mkdir build && cd build && \
sudo cmake –DCMAKE_BUILD_TYPE=Release –DCMAKE_INSTALL_PREFIX=/usr/local .. && \
sudo make -j2 && \
sudo make install

下載範例程式

cd ~/ && \
git clone --depth 1 --branch 2021.3 https://github.com/openvinotoolkit/openvino.git && \
cd ~/openvino && \
git submodule update --init --recursive && \
sh ./install_build_dependencies.sh

編譯範例程式

export OpenCV_DIR=/usr/local/lib/cmake/opencv4 && \
cd ~/openvino/inference-engine/ie_bridges/python/ && \
pip install -r requirements.txt && \
cd ~/openvino && \
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release && \
-DCMAKE_INSTALL_PREFIX=/home/pi/openvino_dist && \
-DENABLE_MKL_DNN=OFF && \
-DENABLE_CLDNN=OFF && \
-DENABLE_GNA=OFF && \
-DENABLE_SSE42=OFF && \
-DTHREADING=SEQ && \
-DENABLE_OPENCV=OFF && \
-DNGRAPH_PYTHON_BUILD_ENABLE=ON && \
-DNGRAPH_ONNX_IMPORT_ENABLE=ON && \
-DENABLE_PYTHON=ON && \
-DPYTHON_EXECUTABLE=$(which python3.7) && \
-DPYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.7m.so && \
-DPYTHON_INCLUDE_DIR=/usr/include/python3.7 && \
-DCMAKE_CXX_FLAGS=-latomic .. && \
make -j2 && \
sudo make install

測試1

cd ~/openvino/bin/armv7l/Release && \
./object_detection_sample_ssd -h

下載 ncs2 測試檔案

cd ~/Downloads && \
wget https://download.01.org/opencv/2021/openvinotoolkit/2021.2/open_model_zoo/models_bin/3/person-vehicle-bike-detection-crossroad-0078/FP16/person-vehicle-bike-detection-crossroad-0078.bin && \
wget https://download.01.org/opencv/2021/openvinotoolkit/2021.2/open_model_zoo/models_bin/3/person-vehicle-bike-detection-crossroad-0078/FP16/person-vehicle-bike-detection-crossroad-0078.xml && \
cd ~/Downloads && \
wget https://cdn.pixabay.com/photo/2018/07/06/00/33/person-3519503_960_720.jpg -O walk.jpg

安裝 ncs2

sudo usermod -a -G users "$(whoami)" && \
source /home/pi/openvino_dist/bin/setupvars.sh && \
sh /home/pi/openvino_dist/install_dependencies/install_NCS_udev_rules.sh

執行 ncs2 測試

cd ~/openvino/bin/armv7l/Release && \
./object_detection_sample_ssd -i ~/Downloads/walk.jpg -m ~/Downloads/person-vehicle-bike-detection-crossroad-0078.xml -d MYRIAD

nc2 測試 2

source /home/pi/openvino_dist/bin/setupvars.sh && \
cd /home/pi/openvino_dist/deployment_tools/inference_engine/samples/python/object_detection_sample_ssd && \
python3 object_detection_sample_ssd.py -i ~/Downloads/walk.jpg -m ~/Downloads/person-vehicle-bike-detection-crossroad-0078.xml -d MYRIAD

在〈“Raspberry pi 4 + openvion + ncs2”〉中有 2 則留言