---
# System prepended metadata

title: Openvino with NCS2 ON Raspi-4

---

# Openvino with NCS2 ON Raspi-4
ref. The PDF made by 梁藝鐘
ref. https://community.intel.com/t5/Intel-Distribution-of-OpenVINO/Can-t-get-through-OpenVINO-installation-on-RBPi-NCS2/m-p/1327705
ref. https://www.intel.com/content/www/us/en/support/articles/000057005/boards-and-kits.html

All the commands below should be run at the Command Line

If the command has "jl" in it, change to the user you're currently using.
e.g.. you're using "pi" as user, then change "jl" to "pi"
# Setting up
### Check the user at the same groups as the "pi" user
ref. [2) Add the new user to the same groups as the "pi" user. This command will do that.](https://forums.raspberrypi.com/viewtopic.php?t=169079)
or just use **pi** to login
### Software up to date
```
sudo apt update && sudo apt upgrade -y
```
### (opt) Using wired network
the network will be more stable while downloading, but wifi is also acceptable
# Install CMack 3.14.4
Back to root
```
cd ~/
```
Download CMack
```
wget https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4.tar.gz
```
Unzip CMack file
```
tar xvzf cmake-3.14.4.tar.gz
```
Go to CMack file
```
cd ~/cmake-3.14.4
```
Run ./bootstrap, will take a while
```
./bootstrap
```
Success:
![](https://hackmd.io/_uploads/BJjLe4GM6.png)

Then run make, also take a long long time
```
make -j4
```
Success:
![](https://hackmd.io/_uploads/rJY77NGz6.png)

this one Should be quick
```
sudo make install
```
Success:
![](https://hackmd.io/_uploads/HJ4HXEfzT.png)
# Install OpenCV
back to root
```
cd ~/
```
install packages
```
sudo apt install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libatlas-base-dev python3-scipy
```
download opencv
```
git clone --depth 1 --branch 4.5.2-openvino https://github.com/opencv/opencv.git
```
go to opencv && create new file && go to new file
```
cd opencv && mkdir build && cd build
```
```
cmake –DCMAKE_BUILD_TYPE=Release –DCMAKE_INSTALL_PREFIX=/usr/local ..
```
Take a really long time
```
make -j4
```
Success:
![](https://hackmd.io/_uploads/BJluqWHGMT.png)
```
sudo make install
```
Success:
![](https://hackmd.io/_uploads/B1LnWHzMp.png)
# Install OpenVINO
```
cd ~/
```
```
git clone --depth 1 --branch releases/2021/4 https://github.com/openvinotoolkit/openvino.git
```
```
cd ~/openvino
```
(optional) under openvino file, this command can check the version of openvino, and it should be 2021/4
```
git branch
```
take a while
```
git submodule update --init --recursive
```
```
sh ./install_build_dependencies.sh
```
setup path
```
export OpenCV_DIR=/usr/local/lib/cmake/opencv4
```
Success:
![](https://hackmd.io/_uploads/SkHcQrfGp.png)
```
cd ~/openvino/inference-engine/ie_bridges/python/
```
```
pip3 install -r requirements.txt
```
if using unstable network, it may fail with incorrect hash value, like the img below
![](https://hackmd.io/_uploads/B1AJ4Hzfa.png)
run the command below solve my problem, which reinstall without cache the previous file (which is already wrong hash value)
ref: https://stackoverflow.com/questions/71435874/pip-these-packages-do-mot-match-the-hashes-from-the-requirements-file
```
pip install --no-cache-dir -r requirements.txt
```
Success:
![](https://hackmd.io/_uploads/Hk74SBGf6.png)
```
sudo apt install libusb-1.0-0-dev
```
```
sudo apt-get install cython3
```
# Build OpenVINO
```
cd ~/openvino && mkdir build && cd build
```
```
git config --global user.name "abc" && git config --global user.email "abc@example.com"
```
## Important, this command can be vary due to the user
### Change "/home/{user}/openvino_dist" to the user you're using.
### e.g.. i'm using "jl" user so change to /home/jl/openvino_dist, like the img and code below
### so if you'r using "pi" as user, change to /home/pi/openvino_dist
![](https://hackmd.io/_uploads/SyxIDBMGp.png)
```
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/home/jl/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="-Wno-psabi -latomic" ..
```
```
make -j4
```
![](https://hackmd.io/_uploads/HkIFp5Xf6.jpg)
Success:
![](https://hackmd.io/_uploads/rJzGjIzz6.png)
```
sudo make install
```
Success:
![](https://hackmd.io/_uploads/ry_4jUGza.png)
# Testing, Now need to plug NCS2 in usb3 port (the blue one)
```
cd ~/openvino/bin/armv7l/Release
```
this command check whether u plug the NCS2 to Raspi and whether the system can read the NCS2
```
./object_detection_sample_ssd -h
```
Success: if the "Available target devices:" is not showing MYRIAD, then the system doesn't read the NCS2
![](https://hackmd.io/_uploads/SkgsjIzzT.png)
```
cd ~/Downloads
```
Now, that's download the demo
```
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
```
this command download the img which is for model to detect the person at the "Download" file
```
wget https://cdn.pixabay.com/photo/2018/07/06/00/33/person-3519503_960_720.jpg -O walk.jpg
```
![](https://hackmd.io/_uploads/HyianLfzT.png)

This may be unnecessary if you have already added the user to the 'users' group, but it's harmless to execute again
```
sudo usermod -a -G users "$(whoami)"
```
Setup the enrivment and install NCS rule
## Important, the two commands below can be vary due to the user
### you should change "jl" to the user you're using. e.g.. u'r using pi as user then the command should be like:
"source /home/**pi**/openvino_dist/bin/setupvars.sh"
and
"sh /home/**pi**/openvino_dist/install_dependencies/install_NCS_udev_rules.sh"
```
source /home/jl/openvino_dist/bin/setupvars.sh
```
```
sh /home/jl/openvino_dist/install_dependencies/install_NCS_udev_rules.sh
```
![](https://hackmd.io/_uploads/SJhArwMzp.png)

Go to the file where model exist
```
cd ~/openvino/bin/armv7l/Release
```
Execute the model to detect the person from wald.jpg
```
./object_detection_sample_ssd -i ~/Downloads/walk.jpg -m ~/Downloads/person-vehicle-bike-detection-crossroad-0078.xml -d MYRIAD
```
The 'out_0.bmp' is the result. Open it, and you can see the image below, which means this time the victory is on your side. Congratulation
![](https://hackmd.io/_uploads/Hyg-TUGMT.png)
![](https://hackmd.io/_uploads/ryHhh8zfp.png)

---
## Additional
The command above "source /home/jl/openvino_dist/bin/setupvars.sh" should be execute everytime u open command line, if u want to use NCS2
The command below can automaticaly execute "source /home/jl/openvino_dist/bin/setupvars.sh" eyerytime u open command line
```
echo "source /home/jl/openvino_dist/bin/setupvars.sh" >> ~/.bashrc
```
Therefore, u can directly execute the model after open the command line, like the img below

![](https://hackmd.io/_uploads/S17UaLGM6.png)