Interactive Face Detection Demo - Microsoft® Windows®

By Andrew Herrold, Published: 08/09/2019, Last Updated: 08/09/2019

The Intel® Distribution of OpenVINO™ toolkit includes many different demo vision applications intended to teach developers about how to design and integrate their own applications with the toolkit. The demos span from simple image classification to human emotion detection – whatever your use-case, you can find valuable information and development insights from these demos.

Note: The Inference Engine demos are covered under the Apache 2.0 license, giving you the freedom to modify for your purposes. Do be aware that other parts of the Toolkit have different licenses. More information can be found in C:\Program Files (x86)\IntelSWTools\openvino/licensing/readme.txt.

One of the demos included is the Interactive Face Detection Demo, a multi-network object detection application that recognizes faces, approximate age, approximate gender, current head pose, estimated emotion, and facial landmarks. This demo shows the ability of the Intel® Distribution of OpenVINO™ toolkit to work with multiple neural networks to bring together data to accomplish a unified goal – in this case, reading multiple aspects of a face for a prototype-ready human response detection system.

Note: More information about the demo can be found here, or at the README distributed with the demo in the demo folder.

This demo uses 5 different networks. Pre-trained networks that satisfy the requirements are publicly available in the Open Model Zoo, and are used in this article. The networks are described simply below:

  • face-detection-adas-0001, a facial detection network based on MobileNet*
  • age-gender-recognition-retail-0013, a recognition network that acts on the results from the face-detection network and reports estimated age and gender
  • head-pose-estimation-adas-0001, a network that estimates the current face’s direction based on the results from the face-detection network
  • emotions-recognition-retail-0003, a network that recognizes and reports one of five emotions – neutral, happy, sad, surprise, anger
  • facial-landmarks-35-adas-0002, a network that reports facial landmarks of a detected face

This article will walk through setting up and running the demo on Windows*, using both your already available Intel® Core™  Processor and the Intel® Neural Compute Stick 2 (Intel® NCS 2). Before we begin, make sure that you meet the prerequisites.


Make sure you have completed the following steps. Many of these components may have been completed during the installation of the Intel® Distribution of OpenVINO™ toolkit, but make sure everything is installed.

  • Microsoft Visual Studio* 2015/2017/2019 with C++, MSBuild, and the Build Tools for Visual Studio
    • For Visual Studio Installer 2017 and 2019, select the “Desktop development with C++” workflow
  • CMake 3.4 or higher
  • At least Python 3.6.5 64-bit with the Python libraries
    • The most recent Python3 installer from contains all needed components
  • Intel® Distribution of OpenVINO™ Toolkit 2019 R2
    •  Make sure that the Inference Engine Runtime for Intel® CPU and the Inference Engine Runtime for Intel® Movidius™ VPU are installed if a custom installation is desired. Otherwise, install the full package.
    • The default installation directory is C:\Program Files(x86)\IntelSWTools\openvino.
  • Computer with Microsoft* Windows 10* OS (64-bit) and an Intel® Core™ processor and Integrated Webcam
    • Note that the inference engine works with AMD processors in x86_64 environments, but do not have the processor-specific optimizations available with Intel® processors. An Intel® Core™ processor is recommended for use with the Intel® Distribution of OpenVINO™ toolkit.
  • Intel® Neural Compute Stick 2 (Intel® NCS 2) 
    • If you’re running a current version of Windows 10, Intel® NCS 2 works just by plugging in. If you’re using an earlier version of Windows, or the Intel® NCS 2 is not detected when running demos, then install the Movidius USB driver located in C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\inference-engine\external\MovidiusDriver\. Right-click on Movidius_VSC_Device.inf and select install. You may need to restart your machine for changes to take effect.

Building the Demos

As long as all of the prerequisites are met, then you should continue to build the demos. The demos ship as source code, giving you the power to learn and modify for your uses. To build the demos and their Visual Studio solutions, a script has been provided in C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\omz_model_zoo\demos\ named build_demos_msvc.bat. Run this in an elevated command prompt to build the demos using the command-line Build Tools for Visual Studio. If you’ve already built the demos, you can skip this step.

Note: This article assumes you’ve installed the Intel® Distribution of OpenVINO™ toolkit into the default install directory, located at C:\Program Files (x86)\IntelSWTools\openvino\. If you’ve changed the installation directory, make sure to change your paths when using the commands below.

After completing, the built demos and their solutions are placed in %USERPROFILE%\Documents\Intel\OpenVINO\omz_demos_build\. The master Visual Studio solution (.sln) is located in this folder, and the individual project files are located in their respective folders. The application binaries are in omz_demos_build\intel64\Release\.

Setting Up the Environment

To begin, open an elevated command prompt and scope to the OpenVINO installation directory. Run the setupvars.bat script in the \bin\ folder to set the environment variables for your current session.

cd "C:\Program Files (x86)\IntelSWTools\openvino\bin"

Note: You need to run this script every time you’re working in a shell. Alternatively, you can add the environment variables to your system to have them set every time a new command prompt is opened.

Fetching Models

We will need to fetch 5 different models for this demo:

  • face-detection-adas-0001
  • age-gender-recognition-retail-0013
  • head-pose-estimation-adas-0001
  • emotions-recognition-retail-0003
  • facial-landmarks-35-adas-0002

You can fetch these models using the Model Downloader, a script distributed with the Intel® Distribution of OpenVINO™ toolkit. The Model Downloader is a Python script located at C:\Program Files (x86)\deployment_tools\tools\model_downloader\
Use the following commands to fetch the models. They will be placed in the same folder as the Model Downloader:

python --name face-detection-adas-0001
python --name age-gender-recognition-retail-0013
python --name head-pose-estimation-adas-0001
python --name emotions-recognition-retail-0003
python --name facial-landmarks-adas-0002

These commands will download all of the models needed for the demo. It will place them into a subfolder located in the same folder as the Model Downloader. 

Running the Demo

With your model, you’re ready to run the demo. The demos are command-line programs that use flags as options for running. The full list of options for the demo can be seen by running a demo with the –h flag. Scope to the folder containing the demo (%USERPROFILE%\Documents\Intel\OpenVINO\omz_demos_build\intel64\Release\) to run the demo.

cd %USERPROFILE%\Documents\Intel\OpenVINO\omz_models_build\intel64\Release\
interactive_face_detection_demo.exe –h

The following example runs the demo using the models downloaded previously and the integrated webcam in your computer. Note that you must assign a model for each part of the demo or the demo will return an error. This demo will run every network on a connected Intel® NCS 2:

interactive_face_detection_demo.exe –i cam –m "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Transportation\object-detection\face\pruned_mobilenet_reduced_ssd_shared_weights\FP16\face-detection-adas-0001.xml" –m_ag "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Retail\object_attributes\age_gender\dldt\FP16\age-gender-recognition-retail-0013.xml" –m_hp "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Transportation\object_attributes\headpose\vanilla_cnn\dldt\FP16\head-pose-estimation-adas-0001.xml" –m_em "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Retail\object_attributes\emotion_recognition\0003\dldt\FP16\emotions-recognition-retail-0003.xml" -m_lm "C:\Program Files (x86)\IntelSWTools\\openvino\deployment_tools\tools\model_downloader\Transportation\object_attributes\facial_landmarks\custom-35-facial-landmarks\dldt\FP16\facial-landmarks-35-adas-0002.xml" –d MYRIAD –d_ag MYRIAD –d_hp MYRIAD –d_em MYRIAD –d_lm MYRIAD

The sample will take the input video feed from the camera and display different statistics over it using OpenCV. Running multiple networks on a single Intel® NCS 2 can reduce the speed of inferencing. For best results, have at least a single Intel® NCS 2 for every network that you run. The MYRIAD plugin will automatically balance and manage the networks across different devices.

The sample only needs a single network to run – the face-detection-adas-0001 network specifically. Your command may be as short as this:

interactive_face_detection_demo.exe –i cam –m "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Transportation\object-detection\face\pruned_mobilenet_reduced_ssd_shared_weights\dldt\FP16\face-detection-adas-0001.xml"-d MYRIAD

This reduces the functionality of the sample by removing the other detectors, but is less computationally complex. Additionally, adding additional networks without specifying a device to load them to defaults the sample to the CPU plugin. 

Using an Intel® CPU

You can also use the Intel® Core™ processor inside of your computer to run inference with Intel® Distribution of OpenVINO™ toolkit, provided it is at least 6th Generation or newer. 

The command uses the exact same inputs as the previous command, but changes the device flags to use CPU. It uses a camera attached to the device (the only one available) and the same 5 networks, running inference for all 5 networks on the CPU:

interactive_face_detection_demo.exe –i cam –m "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Transportation\object-detection\face\pruned_mobilenet_reduced_ssd_shared_weights\FP16\face-detection-adas-0001.xml" –m_ag "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Retail\object_attributes\age_gender\dldt\FP16\age-gender-recognition-retail-0013.xml" –m_hp "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Transportation\object_attributes\headpose\vanilla_cnn\dldt\FP16\head-pose-estimation-adas-0001.xml" –m_em "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Retail\object_attributes\emotion_recognition\0003\dldt\FP16\emotions-recognition-retail-0003.xml" -m_lm "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Transportation\object_attributes\facial_landmarks\custom-35-facial-landmarks\dldt\FP16\facial-landmarks-35-adas-0002.xml" –d CPU –d_ag CPU –d_hp CPU –d_em CPU –d_lm CPU

As alluded to above, you can also mix different inferencing devices, such as running the main face-detection-adas-0001 network on the CPU and running the additional networks on attached Intel® NCS 2 units, as shown below:

interactive_face_detection_demo.exe –i cam –m "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Transportation\object-detection\face\pruned_mobilenet_reduced_ssd_shared_weights\FP16\face-detection-adas-0001.xml" –m_ag "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Retail\object_attributes\age_gender\dldt\FP16\age-gender-recognition-retail-0013.xml" –m_hp "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Transportation\object_attributes\headpose\vanilla_cnn\dldt\FP16\head-pose-estimation-adas-0001.xml" –m_em "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Retail\object_attributes\emotion_recognition\0003\dldt\FP16\emotions-recognition-retail-0003.xml" -m_lm "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\tools\model_downloader\Transportation\object_attributes\facial_landmarks\custom-35-facial-landmarks\dldt\FP16\facial-landmarks-35-adas-0002.xml" –d CPU –d_ag MYRIAD –d_hp MYRAID –d_em MYRIAD –d_lm MYRAID

We encourage you to explore the interactive_face_detection_demo project to see how the code interacts with the network and the Inference Engine.

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804