Install OpenVINO™ toolkit for Raspbian* OS

NOTE:

  • The OpenVINO™ toolkit was formerly known as the Intel® Computer Vision SDK.
  • These steps apply to 32-bit Raspbian* 9 OS (Stretch), which is an official OS for Raspberry Pi* boards.
  • These steps have been validated with Raspberry Pi 3*.
  • All steps in this guide are required unless otherwise stated.
  • An internet connection is required to follow the steps in this guide.

Introduction

The OpenVINO™ toolkit quickly deploys applications and solutions that emulate human vision. Based on Convolutional Neural Networks (CNN), the toolkit extends computer vision (CV) workloads across Intel® hardware, maximizing performance. The OpenVINO toolkit includes the Intel® Deep Learning Deployment Toolkit (Intel® DLDT).

The OpenVINO™ toolkit for Raspbian* OS includes the Inference Engine and the MYRIAD plugin only. You can use it with the Intel® Movidius™ Neural Compute Stick (Intel® NCS) or the Intel® Neural Compute Stick 2 plugged in one of USB ports.

Included in the Installation Package

The OpenVINO toolkit for Raspbian OS is an archive with pre-installed header files and libraries. The following components are installed by default:

Component Description
Inference Engine This is the engine that runs the deep learning model. It includes a set of libraries for an easy inference integration into your applications.
OpenCV* version 4.0.0 OpenCV* community version compiled for Intel® hardware.
Sample Applications A set of simple console applications demonstrating how to use Intel's Deep Learning Inference Engine in your applications.

NOTE: The package does not include the Model Optimizer. To convert models to Intermediate Representation (IR), you need to install it separately to your host machine.

Development and Target Platforms

Hardware

Operating Systems

Software

Overview

This guide provides step-by-step instructions on how to install the OpenVINO™ toolkit for Raspbian* OS. Links are provided for each type of compatible hardware including downloads, initialization and configuration steps. The following steps will be covered:

  1. Install the OpenVINO™ toolkit
  2. Install External Software Dependencies
  3. Set the environment variables
  4. Add USB rules
  5. Run the Object Detection Sample to validate Inference Engine installation
  6. Run Inference of Face Detection Model (for OpenCV*) to validate OpenCV installation
  7. Learn About Workflow for Raspberry Pi

Install the OpenVINO™ Toolkit for Raspbian* OS Package

The guide assumes you downloaded the OpenVINO toolkit for Raspbian* OS. If you do not have a copy of the toolkit package file l_openvino_toolkit_raspbi_p_<version>.tgz, download the latest version from the Intel® Open Source Technology Center and then return to this guide to proceed with the installation.

NOTE: The OpenVINO toolkit for Raspbian OS is distributed without installer, so you need to perform extra steps comparing to the Intel® Distribution of OpenVINO™ toolkit for Linux* OS.

  1. Open the Terminal* or your preferred console application.
  2. Go to the directory in which you downloaded the OpenVINO toolkit. This document assumes this is your ~/Downloads directory. If not, replace ~/Downloads with the directory where the file is located.
    cd ~/Downloads/
    By default, the package file is saved as l_openvino_toolkit_raspbi_p_<version>.tgz.
  3. Create an installation folder.
    sudo mkdir -p /opt/intel/openvino
  4. Unpack the archive:
    sudo tar -xf l_openvino_toolkit_raspbi_p_<version>.tgz --strip 1 -C /opt/intel/openvino
  5. Modify the setupvars.sh script by replacing <INSTALLDIR> with the absolute path to the installation folder:
    sudo sed -i "s|<INSTALLDIR>|/opt/intel/openvino|" /opt/intel/openvino/bin/setupvars.sh

Now the OpenVINO toolkit components are installed. Additional configuration steps are still required. Continue to the next sections to install External Software Dependencies, configure the environment and set up USB rules.

Install External Software Dependencies

CMake* version 3.7.2 or higher is required for building the Inference Engine sample application. To install, open a Terminal* window and run the following command:

sudo apt install cmake

CMake is installed. Continue to the next section to set the environment variables.

Set the Environment Variables

You must update several environment variables before you can compile and run OpenVINO toolkit applications. Run the following script to temporarily set the environment variables:

source /opt/intel/openvino/bin/setupvars.sh

(Optional) The OpenVINO environment variables are removed when you close the shell. As an option, you can permanently set the environment variables as follows:

echo "source /opt/intel/openvino/bin/setupvars.sh" >> ~/.bashrc

To test your change, open a new terminal. You will see the following:

[setupvars.sh] OpenVINO environment initialized

Continue to the next section to add USB rules for Intel® Movidius™ Neural Compute Stick and Intel® Neural Compute Stick 2 devices.

Add USB Rules

  1. Add the current Linux user to the users group:
    sudo usermod -a -G users "$(whoami)"
    Log out and log in for it to take effect.
  2. To perform inference on the Intel® Movidius™ Neural Compute Stick or Intel® Neural Compute Stick 2, install the USB rules running the install_NCS_udev_rules.sh script:
    sh /opt/intel/openvino/install_dependencies/install_NCS_udev_rules.sh

You are ready to compile and run the Object Detection sample to verify the Inference Engine installation.

Build and Run Object Detection Sample

Follow the next steps to run pre-trained Face Detection network using Inference Engine samples from the OpenVINO toolkit.

  1. Navigate to a directory that you have write access to and create a samples build directory. This example uses a directory named build:
    mkdir build && cd build
  2. Build the Object Detection Sample:
    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=armv7-a" /opt/intel/openvino/deployment_tools/inference_engine/samples
    make -j2 object_detection_sample_ssd
  3. Download the pre-trained Face Detection model or copy it from the host machine:
    • To download the .bin file with weights:
      wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R1/models_bin/face-detection-adas-0001/FP16/face-detection-adas-0001.bin
    • To download the .xml file with the network topology:
      wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R1/models_bin/face-detection-adas-0001/FP16/face-detection-adas-0001.xml
  4. Run the sample with specifying the model and a path to the input image:
    ./armv7l/Release/object_detection_sample_ssd -m face-detection-adas-0001.xml -d MYRIAD -i <path_to_image>
    The application outputs an image (out_0.bmp) with detected faced enclosed in rectangles.

Continue to the next section to verify the OpenCV installation.

Run Inference of Face Detection Model Using OpenCV* API

To validate OpenCV* installation, run the OpenCV deep learning module with the Inference Engine backend. Here is a Python* sample, which works with the pre-trained Face Detection model:

  1. Download the pre-trained Face Detection model or copy it from a host machine:
    • To download the .bin file with weights:
      wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R1/models_bin/face-detection-adas-0001/FP16/face-detection-adas-0001.bin
    • To download the .xml file with the network topology:
      wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R1/models_bin/face-detection-adas-0001/FP16/face-detection-adas-0001.xml
  2. Create a new Python* file named as openvino_fd_myriad.py and copy the following script there:
    import cv2 as cv
    # Load the model.
    net = cv.dnn.readNet('face-detection-adas-0001.xml',
    'face-detection-adas-0001.bin')
    # Specify target device.
    net.setPreferableTarget(cv.dnn.DNN_TARGET_MYRIAD)
    # Read an image.
    frame = cv.imread('/path/to/image')
    # Prepare input blob and perform an inference.
    blob = cv.dnn.blobFromImage(frame, size=(672, 384), ddepth=cv.CV_8U)
    net.setInput(blob)
    out = net.forward()
    # Draw detected faces on the frame.
    for detection in out.reshape(-1, 7):
    confidence = float(detection[2])
    xmin = int(detection[3] * frame.shape[1])
    ymin = int(detection[4] * frame.shape[0])
    xmax = int(detection[5] * frame.shape[1])
    ymax = int(detection[6] * frame.shape[0])
    if confidence > 0.5:
    cv.rectangle(frame, (xmin, ymin), (xmax, ymax), color=(0, 255, 0))
    # Save the frame to an image file.
    cv.imwrite('out.png', frame)
  3. Run the script:
    python3 openvino_fd_myriad.py

In this script OpenCV* loads the Face Detection model from the Intermediate Representation (IR) format and an image. Then it runs the inference and saves the image with detected faces.

Congratulations, you have finished the OpenVINO™ toolkit for Raspbian* OS installation. You have completed all required installation, configuration and build steps in this guide.

Read the next topic if you want to learn more about OpenVINO workflow for Raspberry Pi.

Workflow for Raspberry Pi*

If you want to use your model for inference, the model must be converted to the .bin and .xml Intermediate Representation (IR) files that are used as input by Inference Engine. OpenVINO™ toolkit support on Raspberry Pi only includes the Inference Engine module of the Intel® Distribution of OpenVINO™ toolkit. The Model Optimizer is not supported on this platform. To get the optimized models you can use one of the following options: