Inference Engine Samples

The Inference Engine sample applications are simple console applications that demonstrate how you can use the Inference Engine in your applications. The sample applications are available in the <INSTALL_DIR>/deployment_tools/inference_engine/samples directory.

The OpenVINO™ toolkit includes the following samples:

Several C++ samples referenced above have simplified implementation in Python (<INSTALL_DIR>/deployment_tools/inference_engine/samples/python_samples)*.

Media Files Available for Samples

To run the sample applications, you can use images and videos from the media files collection available at https://github.com/intel-iot-devkit/sample-videos.

Samples that Support Pre-Trained Models

You can download the pre-trained models using the OpenVINO Model Downloader or from https://download.01.org/opencv/.

Build the Sample Applications

Build the Sample Applications on Linux*

The officially supported Linux* build environment is the following:

To build the sample applications for Linux, go to the directory with the build_samples.sh script and run it:

build_samples.sh

You can also build the sample applications manually:

NOTE: If you have installed the product as a root user, switch to root mode before you continue: sudo -i

  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

    NOTE: If you ran the Image Classification verification script during the installation, the samples build directory was already created in your home directory: /home/<user>/inference_engine_samples_build/

  2. Go to the created directory:
    cd build
  3. Run CMake to generate the Make files for release or debug configuration:
    • For release configuration:
      cmake -DCMAKE_BUILD_TYPE=Release <INSTALL_DIR>/deployment_tools/inference_engine/samples
    • For debug configuration:
      cmake -DCMAKE_BUILD_TYPE=Debug <INSTALL_DIR>/deployment_tools/inference_engine/samples
  4. Run make to build the samples:
    make

For the release configuration, the sample application binaries are in <path_to_build_directory>/intel64/Release/; for the debug configuration — in <path_to_build_directory>/intel64/Debug/.

Build the Sample Applications on Microsoft Windows* OS

The recommended Windows* build environment is the following:

NOTE: If you want to use Microsoft Visual Studio 2019, you are required to install CMake 3.14.

To build the sample applications for Windows, run the build_samples_msvc.bat batch file:

<INSTALL_DIR>\inference_engine\samples\build_samples_msvc.bat

By default, the script automatically detects the highest Microsoft Visual Studio version installed on the machine and uses it to create and build a solution for a sample code. Optionally, you can also specify the preferred Microsoft Visual Studio version to be used by the script. Supported versions are VS2015, VS2017, and VS2019. For example, to build the samples using the Microsoft Visual Studio 2017, use the following command:

<INSTALL_DIR>\inference_engine\samples\build_samples_msvc.bat VS2017

The sample applications binaries are in the C:\Users\<username>\Documents\Intel\OpenVINO\inference_engine_samples_build\intel64\Release directory.

You can also build a generated solution manually, for example, if you want to build binaries in Debug configuration. Run the appropriate version of the Microsoft Visual Studio and open the generated solution file from the C:\Users\<username>\Documents\Intel\OpenVINO\inference_engine_samples_build\Samples.sln directory.

Get Ready for Running the Sample Applications

Get Ready for Running the Sample Applications on Linux*

Before running compiled binary files, make sure your application can find the Inference Engine and OpenCV libraries. Run the setupvars script to set all necessary environment variables:

source <INSTALL_DIR>/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:

  1. Open the .bashrc file in <user_home_directory>:
    vi <user_home_directory>/.bashrc
  2. Add this line to the end of the file:
    source /opt/intel/openvino/bin/setupvars.sh
  3. Save and close the file: press the Esc key, type :wq and press the Enter key.
  4. To test your change, open a new terminal. You will see [setupvars.sh] OpenVINO environment initialized.

You are ready to run sample applications. To learn about how to run a particular sample, read the sample documentation by clicking the sample name in the samples list above.

Get Ready for Running the Sample Applications on Windows*

Before running compiled binary files, make sure your application can find the Inference Engine and OpenCV libraries. Use the setupvars script, which sets all necessary environment variables:

<INSTALL_DIR>\bin\setupvars.bat

To debug or run the samples on Windows in Microsoft Visual Studio, make sure you have properly configured Debugging environment settings for the Debug and Release configurations. Set correct paths to the OpenCV libraries, and debug and release versions of the Inference Engine libraries. For example, for the Debug configuration, go to the project's Configuration Properties to the Debugging category and set the PATH variable in the Environment field to the following:

PATH=<INSTALL_DIR>\deployment_tools\inference_engine\bin\intel64\Debug;<INSTALL_DIR>\opencv\bin;%PATH%

where <INSTALL_DIR> is the directory in which the OpenVINO toolkit is installed.

You are ready to run sample applications. To learn about how to run a particular sample, read the sample documentation by clicking the sample name in the samples list above.

See Also