This is a getting started guide for beginners to Intel Compute Stick and OpenVINO. I will be using pre-trained model from model zoo. I am going to build a vehicle alert system should. When a vehicle is approaching, Raspberry Pi will speak out the alert. This could be a very good use-case for visually impaired persons or for bikers who often don't see what's coming from behind.
Things you need
Hardwares- Raspberry Pi 3 ( or 4 ) with 16GB SD card
- Intel Neural Compute Strick 2
- 3.5mm Speaker
- USB Power bank to power Raspberry Pi
- USB Keyboard and Mouse during setup
- HDMI Monitor during setup
BalenaEtcher or Pi Imager to burn SD card with Raspbian OS.
OpenVINO Toolkit
Let's get started
Prepare SD CardIf you are familiar with Raspberry Pi, then you know first thing is to prepare your SD card with Raspbian OS. You can either use Balena Etcher (download from https://www.balena.io/etcher) or use Pi Imager. I would prefer Pi Imager as it's one less step to follow.
Choose the operating system ( Raspberry pi 3 32 bit ) and choose your SD card to flush. This may take few minutes. Once finished, unplug the SD card from your computer and insert into Raspberry Pi.
Configure Raspberry Pi 3Connect USB keyboard, mouse and a HDMI monitor to raspberry pi. Connect the power which will turn boot up your Pi desktop. Follow the setup wizard and configure WiFi for your Pi. After reboot, open Raspberry Pi Configuration wizard and enable Camera and SSH. Optionally you can enable VNC viewer if you want to remote access your desktop.
You may follow the official documentation here or follow steps below.
Open Terminal window on your Pi and go to Downloads folder
cd ~/Downloads
and download OpenVINO sdk.
wget --no-check-certificate https://download.01.org/opencv/2020/openvinotoolkit/2020.4/l_openvino_toolkit_runtime_raspbian_p_2020.4.287.tgz
You should see the zip file as below
Then create a folder where OpenVINO will be installed
sudo mkdir -p /opt/intel/openvino
sudo tar -xf l_openvino_toolkit_runtime_raspbian_p_<version>.tgz --strip 1 -C /opt/intel/openvino
sudo apt install cmake
echo "source /opt/intel/openvino/bin/setupvars.sh" >> ~/.bashrc
Close the terminal and open a new one. You should see below message which means your environment variables are setup
Now, it's time to add some USB rule for your NCS 2
sudo usermod -a -G users "$(whoami)"
sh /opt/intel/openvino/install_dependencies/install_NCS_udev_rules.sh
You are almost done ! Plug your NCS 2 stick to one of the USB port of your Pi and move to build process.
cd /home/pi
mkdir OpenVINO && OpenVINO
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=armv7-a" /opt/intel/openvino/deployment_tools/inference_engine/samples/c
make -j2 object_detection_sample_ssd
Now go one level up to OpenVINO folder
cd ..
And download my github repo which contains the python code and pre-trained vehicle detection models from model zoo
git clone https://github.com/just4give/openvio-vehicle-detection.git
cd openvio-vehicle-detection
Then install python dependencies via pip3
pip3 install -r requirements.txt
You all set to run your vehicle detection program. Before you do, there are few other things.
Install Camera ModuleConnect your Pi Camera module to Pi and test it to make sure it's working by issuing below command from terminal
raspistill -v -o test.jpg
If all is well, you should see the image preview. If not, please read this document for full configuration.
Configure AudioFollow this official document to configure audio output for you Pi. Once done run below command from terminal
aplay /home/pi/OpenVINO/openvio-vehicle-detection/alert.wav
All right, if you had success so far, you are ready to run your program for the first time :)
cd /home/pi/OpenVINO/openvio-vehicle-detection
and issue below command
python3 main.py -d MYRIAD -m vehicle-detection-adas-0002.xml -pt 0.9
My threshold is very high and the model was producing some falls vehicles. You may adjust the value based on your ambience light etc.
Congratulations !!! You have setup OpenVINO and ran your first program successfully. There are plenty of interesting and useful pre-trained models to explore -> https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/intel
What's next ? Your imagination has no limit. Learn to train your own models and explore the computer vision world.
This project is also published on PCBWay
Comments