├── Images
├── IE graphic.png
├── OV Overview.png
├── face_detection.png
└── face_detection_overlay.png
├── README.md
├── Videos
└── head-pose-face-detection-female-and-male.mp4
└── dx_face_detection
├── CMakeLists.txt
├── cmake
└── CMakeLists_common.cmake
├── face_detection.hpp
├── main.cpp
└── run_fd.sh
/Images/IE graphic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fritzboyle/openvino-with-fpga-hello-world-face-detection/bc5268f8f4722a95cca2ae6f5e130ec39623d43c/Images/IE graphic.png
--------------------------------------------------------------------------------
/Images/OV Overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fritzboyle/openvino-with-fpga-hello-world-face-detection/bc5268f8f4722a95cca2ae6f5e130ec39623d43c/Images/OV Overview.png
--------------------------------------------------------------------------------
/Images/face_detection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fritzboyle/openvino-with-fpga-hello-world-face-detection/bc5268f8f4722a95cca2ae6f5e130ec39623d43c/Images/face_detection.png
--------------------------------------------------------------------------------
/Images/face_detection_overlay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fritzboyle/openvino-with-fpga-hello-world-face-detection/bc5268f8f4722a95cca2ae6f5e130ec39623d43c/Images/face_detection_overlay.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OpenVINO with FPGA Hello World Face Detection Exercise
2 |
3 | **Note:** This tutorial has been written using OpenVINO™ Toolkit for Linux with FPGA Support version 2018 R4 and is for use with this version only. Using this tutorial with any other version may not be correct.
4 |
5 | # Table of Contents
6 |
7 |
21 |
22 | ## Introduction
23 |
24 | The OpenVINO™ toolkit runs inference models using the CPU to process images. As an option, OpenVINO can use GPU and VPU devices, if available. You can use the inference models to process video from an optional USB camera, an existing video file, or still image files.
25 |
26 | This tutorial examines a sample application that was created with the OpenVINO™ toolkit. The tutorial steps will guide you through downloading the latest Face Detection Tutorial from GitHub, walk you through the sample code and then compile and run the code on the the available hardware. During the process, you will become familiar with key OpenVINO™ concepts.
27 |
28 | This tutorial starts with a base application that reads image data and outputs the image to a window. The steps build on each other by adding deep learning models that process image data and make inferences. In the final step, you will use the completed application to detect faces, report the age and gender of the detected face, and draw a 3D axis representing the head pose for each face.
29 |
30 | ## Getting Started
31 |
32 | ### Prerequisites
33 |
34 | To download all the files for this tutorial, you will need to access GitHub on the Internet.
35 |
36 | To run the application in this tutorial, the OpenVINO™ toolkit for Linux with FPGA and its dependencies must already be installed and verified using the included demos. Installation instructions can be found here: https://software.intel.com/en-us/articles/OpenVINO-Install-Linux-FPGA
37 | If any optional hardware is to be used, it must be installed and verified including:
38 | * Intel® Arria® 10 GX FPGA Development Kit or the Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA.
39 | * GPU - normally embedded with supported Intel® CPUs; requires drivers and updated Linux kernel to run.
40 | * VPU - USB Intel® Movidius™ Neural Compute Stick with Myriad. The **GitHub** download or clone will include the dx_face_detection zip file.
41 |
42 | ### Summary of what is needed:
43 | ### Hardware
44 | Target and development platforms meeting the requirements described in the "System Requirements" section of the OpenVINO™ toolkit documentation which can be found here: https://software.intel.com/openvino-toolkit
45 |
46 | **Note:** For this tutorial, an Intel® i7-7700 (CPU with GPU & Intel® Arria® 10 GX FPGA Development Kit) was used as both the development and target platform.
47 |
48 | **Optional:**
49 | * Intel® Movidius™ Neural Compute Stick
50 | * GPU support
51 | ### Software
52 | * OpenVINO™ toolkit supported Linux operating system. This tutorial was run on 64-bit Ubuntu 16.04.3 LTS updated to kernel 4.14.20 following the OpenVINO™ toolkit installation instructions.
53 | * The latest OpenVINO™ toolkit with FPGA support installed and verified. This tutorial was written using version 2018 R4.
54 | * At least one utility for downloading from the GitHub repository: Subversion (svn), Git (git), or both.
55 |
56 | By now you should have completed the Linux installation guide for the OpenVINO™ toolkit with FPGA support (link). Before continuing, please ensure:
57 | * That you have run the supplied demo samples.
58 | * If you have and intend to use an FPGA: You have installed and tested the Quartus® Programmer (link?) and are able to program bitstreams.
59 | * If you have and intend to use a GPU: You have installed and tested the GPU drivers.
60 | * If you have and intend to use a Myriad: You have connected and tested the USB Intel® Movidius™ Neural Compute Stick.
61 |
62 | ### Required Connectivity
63 | * Your development platform is connected to a network and has Internet access.
64 | * You have Github access.
65 |
66 | ## Download the Tutorial from the Git Repository
67 | In these steps you create a directory for the files you download from the “OpenVINO FPGA Hello World Face Detection” GitHub repository.
68 | ### Use Git Clone to Clone the Entire Repository
69 | 1. Open a command shell prompt (such as xterm).
70 | 2. If you have not installed Git, install it now:
71 | ```
72 | sudo apt-get update
73 | sudo apt-get install git
74 | ```
75 | 3. Create a directory named "tutorials":
76 | ```
77 | mkdir tutorials
78 | ```
79 | 4. Go to the tutorials directory:
80 | ```
81 | cd tutorials
82 | ```
83 | 5. Clone the repository:
84 | ```
85 | git clone https://github.com/fritzboyle/openvino-with-fpga-hello-world-face-detection
86 | ```
87 |
88 | 6. Change to the face detection tutorial folder:
89 | ```
90 | cd openvino-with-fpga-hello-world-face-detection
91 | ```
92 |
93 | You now have the Face Detection Tutorial files. The next section shows the directory structure of the files you extracted.
94 |
95 | # Tutorial Files
96 | The "tutorial" directory contains:
97 | * Images\ - directory of images
98 | * Videos\ - directory of videos
99 | * cmake\ - directory of common CMake files
100 | * dx_face_detection\ - directory of code to help run the scripts
101 | * Readme.md - This document
102 |
103 | # OpenVINO™ Toolkit Overview and Terminology
104 | The OpenVINO™ toolkit enables the quick deployment of Convolutional Neural Networks (CNN) for heterogeneous execution on Intel® hardware while maximizing performance. Deployment is accomplished through the the Intel® Deep Learning Deployment Toolkit (Intel® DL Deployment Toolkit) included within the OpenVINO™ toolkit.
105 | 
106 |
107 | The CNN workflow is:
108 | 1. Create and train the CNN inference model in a framework, such as Caffe*.
109 | 2. Use the Model Optimizer on the trained model to produce an optimized Intermediate Representation (IR), stored .bin and .xml files for use with the Inference Engine.
110 | 3. Use the Inference Engine with your application to load and run the model on your devices.
111 |
112 | This tutorial focuses on the last step in the workflow; using the user application the Inference Engine to run models on a CPU, GPU, FPGA, and Movidius™ Neural Compute Stick.
113 | ## The Inference Engine
114 | Below is a more detailed view of the User Application and Inference Engine:
115 | 
116 |
117 | The Inference Engine includes a plugin library for each supported device that has been optimized for the Intel® hardware device CPU, GPU, FPGA and Myriad. We will use the terms "device" and “plugin” with the assumption that one infers the other (e.g. CPU device infers the CPU plugin and vice versa). As part of loading the model, the User Application tells the Inference Engine which device to target which in turn loads the associated plugin library to later run on the associated device. The Inference Engine uses “blobs” for all data exchanges which are arrays in memory arranged according to the input and output data of the model.
118 | 
119 |
120 | ## Face Detection Sample
121 | In this Face Detection sample, the model estimates the head pose based on the face image it is given. The face detection model estimates the age, gender and head pose. After the head pose model has processed the face, the application will draw a set of axes over the face, indicating the Yaw, Pitch, and Roll orientation of the head. A sample output showing the results with the three axes appears below. The metrics reported also include the time to run the head pose model.
122 |
123 | 
124 |
125 | In the image above, the three axes intersect in the center of the head. The blue line represents Roll, and it extends from the center of the head to the front and the back of the head. The red line represents Pitch, and is drawn from the center of the head to the left ear. The green line represents Yaw, and is drawn from the center of the head to the top of the head.
126 |
127 | For details about the models see the Full Tutorial: https://github.com/intel-iot-devkit/inference-tutorials-generic/blob/openvino_toolkit_r3_0/face_detection_tutorial/step_4/Readme.md#introduction
128 |
129 | In the next section, you build and run the application and see how it runs the three analysis models.
130 |
131 | # Build
132 | 1. Use a terminal window to access a command shell prompt.
133 |
134 | 2. Go the directory containing the Hello World files:
135 | ```
136 | cd dx_face_detection
137 | ```
138 | 3. Source the variables:
139 | ```
140 | source /home//Downloads/fpga_support_files/setup_env.sh
141 | ```
142 | 4. Create a directory to build the tutorial:
143 | ```
144 | mkdir build
145 | ```
146 | 5. Go to the build directory:
147 | ```
148 | cd build
149 | ```
150 | 6. Run CMake to set the build target and file locations:
151 |
152 | ```
153 | cmake -DCMAKE_BUILD_TYPE=Release ..
154 | ```
155 | 7. Build the executable:
156 | ```
157 | make
158 | ```
159 | **Alternative make command:** Run make across multiple pieces of hardware to speed the process
160 | ```
161 | make -j $(nproc)
162 | ```
163 | 8. Load a bitstream that works well for object detection. The OpenVINO toolkit with support for FPGA includes bitstreams for Both Arria 10 FPGA cards.
164 |
165 | * For the Arria 10 GX Development Kit, use this command:
166 | ```
167 | aocl program acl0 /opt/intel/computer_vision_sdk_fpga_2018.3.343/a10_devkit_bitstreams/2-0-1_A10DK_FP11_ResNet50-101.aocx
168 | ```
169 | * For the Intel® Vision Accelerator Design with Intel® Arria® 10 FPGA (IEI Mustang-F100-A10), use this command:
170 | ```
171 | aocl program acl0 /opt/intel/computer_vision_sdk_2018.4.420/bitstreams/a10_vision_design_bitstreams/4-0_PL1_FP11_MobileNet_ResNet_VGG_Clamp.aocx
172 | ```
173 |
174 |
175 | # Run the Application
176 | 1. Go to the main level directory:
177 | ```
178 | cd ..
179 | ```
180 | 2. Turn the script into an executable file:
181 | ```
182 | chmod +x run_fd.sh
183 | ```
184 | ## Script Description
185 | This tutorial includes a script to select the media file, models and hardware. The script commands are provided under each step to provide the opportunity to explore other possibilities.
186 | `run_fd.sh` requires at least one hardware target, and supports up to 3.
187 |
188 | ### How To Use:
189 | ```
190 | ./run_fd.sh (face detection hardware) (age/gender hardware) (head pose hardware)
191 | ```
192 | EXAMPLE: `./run_fd.sh fpga fpga gpu`
193 |
194 | **Choose a hardware component for each argument you use**
195 | 1. cpu
196 | 2. gpu
197 | 3. fpga
198 |
199 | **Targets (in order on command line):**
200 | 1. 1st argument is required, for face detection
201 | 2. 2nd argument, optional, for age & gender recognition
202 | 3. 3rd argument, optional, requires face detection + age/gender recognition, for head pose
203 |
204 | You will see rectangles and the head pose axes that follow the faces around the image (if the faces move), accompanied by age and gender results for the faces, and the timing statistics for processing each frame of the video.
205 |
206 | When the video finishes, press any key to close the window and see statistics of the trial.
207 |
208 |
209 | ## Example 1 - Run face detection on targeted hardware (CPU):
210 | ```
211 | ./run_fd.sh cpu
212 | ```
213 |
214 | **Full command**
215 | ```
216 | build/intel64/Release/face_detection_tutorial -i ../Videos/head-pose-face-detection-female-and-male.mp4 -m /opt/intel/computer_vision_sdk/deployment_tools/intel_models/face-detection-retail-0004/FP32/face-detection-retail-0004.xml -d CPU
217 | ```
218 |
219 |
220 | ## Example 2 - Run face detection on targeted hardware (FPGA):
221 | ```
222 | ./run_fd.sh fpga
223 | ```
224 |
225 | **Full command**
226 | ```
227 | build/intel64/Release/face_detection_tutorial -i ../Videos/head-pose-face-detection-female-and-male.mp4 -m /opt/intel/computer_vision_sdk/deployment_tools/intel_models/face-detection-retail-0004/FP16/face-detection-retail-0004.xml -d HETERO:FPGA,CPU
228 | ```
229 |
230 | ## Example 3 - Run face detection on FPGA with age/gender recognition on GPU
231 | ```
232 | ./run_fd.sh fpga gpu
233 | ```
234 |
235 | **Full command**
236 | ```
237 | build/intel64/Release/face_detection_tutorial -i ../Videos/head-pose-face-detection-female-and-male.mp4 -m /opt/intel/computer_vision_sdk/deployment_tools/intel_models/face-detection-retail-0004/FP16/face-detection-retail-0004.xml -m_ag /opt/intel/computer_vision_sdk/deployment_tools/intel_models/age-gender-recognition-retail-0013/FP16/age-gender-recognition-retail-0013.xml -d HETERO:FPGA,CPU -d_ag GPU
238 | ```
239 |
240 | ## Example 4 - Run face detection on FPGA, age/gender recognition on a GPU, and head pose estimation on a CPU
241 | ```
242 | ./run_fd.sh fpga gpu cpu
243 | ```
244 |
245 | **Full command**
246 | ```
247 | build/intel64/Release/face_detection_tutorial -i ../Videos/head-pose-face-detection-female-and-male.mp4 -m /opt/intel/computer_vision_sdk/deployment_tools/intel_models/face-detection-retail-0004/FP16/face-detection-retail-0004.xml -m_ag /opt/intel/computer_vision_sdk/deployment_tools/intel_models/age-gender-recognition-retail-0013/FP16/age-gender-recognition-retail-0013.xml -m_hp /opt/intel/computer_vision_sdk/deployment_tools/intel_models/head-pose-estimation-adas-0001/FP32/head-pose-estimation-adas-0001.xml -d HETERO:FPGA,CPU -d_ag GPU -d_hp CPU
248 | ```
249 |
250 |
251 | ## Example 5 - Run everything on cpu
252 | ```
253 | ./run_fd.sh cpu cpu cpu
254 | ```
255 |
256 | **Full command**
257 | ```
258 | build/intel64/Release/face_detection_tutorial -i ../Videos/head-pose-face-detection-female-and-male.mp4 -m /opt/intel/computer_vision_sdk/deployment_tools/intel_models/face-detection-retail-0004/FP32/face-detection-retail-0004.xml -m_ag /opt/intel/computer_vision_sdk/deployment_tools/intel_models/age-gender-recognition-retail-0013/FP32/age-gender-recognition-retail-0013.xml -m_hp /opt/intel/computer_vision_sdk/deployment_tools/intel_models/head-pose-estimation-adas-0001/FP32/head-pose-estimation-adas-0001.xml -d CPU -d_ag CPU -d_hp CPU
259 | ```
260 |
261 | **NOTE:** The FPGA plugin does NOT support the head pose model. If specified, it will be replaced with CPU.
262 |
263 | This completes the application tutorial. For more information on using the OpenVINO™ toolkit in your environment, see the documentation here: https://software.intel.com/openvino-toolkit
264 |
--------------------------------------------------------------------------------
/Videos/head-pose-face-detection-female-and-male.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fritzboyle/openvino-with-fpga-hello-world-face-detection/bc5268f8f4722a95cca2ae6f5e130ec39623d43c/Videos/head-pose-face-detection-female-and-male.mp4
--------------------------------------------------------------------------------
/dx_face_detection/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018 Intel Corporation
2 |
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 |
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | cmake_minimum_required(VERSION 2.8)
15 |
16 | # Common to all tutorial sections
17 | include(cmake/CMakeLists_common.cmake)
18 |
19 | set(TARGET_NAME "face_detection_tutorial")
20 |
21 | find_package(OpenCV)
22 | if(OpenCV_FOUND)
23 | message(STATUS "OPENCV is enabled")
24 | message(STATUS "OpenCV_INCLUDE_DIRS=${OpenCV_INCLUDE_DIRS}")
25 | message(STATUS "OpenCV_LIBS=${OpenCV_LIBS}")
26 | else()
27 | message(STATUS "OPENCV is disabled or not found, " ${TARGET_NAME} " skiped")
28 | return()
29 | endif()
30 |
31 | if( BUILD_SAMPLE_NAME AND NOT ${BUILD_SAMPLE_NAME} STREQUAL ${TARGET_NAME} )
32 | message(STATUS "SAMPLE ${TARGET_NAME} SKIPPED")
33 | return()
34 | endif()
35 |
36 | file (GLOB MAIN_SRC
37 | ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
38 | )
39 |
40 | file (GLOB MAIN_HEADERS
41 | ${CMAKE_CURRENT_SOURCE_DIR}/*.h
42 | )
43 |
44 | # Create named folders for the sources within the .vcproj
45 | # Empty name lists them directly under the .vcproj
46 | source_group("src" FILES ${MAIN_SRC})
47 | source_group("include" FILES ${MAIN_HEADERS})
48 |
49 | include_directories (
50 | ${OpenCV_INCLUDE_DIRS}
51 | #/opt/intel/computer_vision_sdk/inference_engine/src/extension
52 | /opt/intel/computer_vision_sdk/deployment_tools/inference_engine/src/extension
53 | /opt/intel/computer_vision_sdk/deployment_tools/inference_engine/include/cpp/
54 | )
55 | link_directories(
56 | ${LIB_FOLDER}
57 | /opt/intel/computer_vision_sdk_2018.4.420/deployment_tools/inference_engine/lib/ubuntu_16.04/intel64
58 | )
59 |
60 | # Create library file from sources.
61 | add_executable(${TARGET_NAME} ${MAIN_SRC} ${MAIN_HEADERS})
62 |
63 | add_dependencies(${TARGET_NAME} gflags)
64 |
65 | set_target_properties(${TARGET_NAME} PROPERTIES "CMAKE_CXX_FLAGS" "${CMAKE_CXX_FLAGS} -fPIE"
66 | COMPILE_PDB_NAME ${TARGET_NAME})
67 |
68 |
69 | target_link_libraries(${TARGET_NAME} format_reader ${IE_LIBRARIES} gflags)
70 |
71 | if(UNIX)
72 | target_link_libraries( ${TARGET_NAME} inference_engine cpu_extension_avx2 ${LIB_DL} pthread ${OpenCV_LIBRARIES})
73 | endif()
74 |
--------------------------------------------------------------------------------
/dx_face_detection/cmake/CMakeLists_common.cmake:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2018 Intel Corporation
2 |
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 |
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | cmake_minimum_required (VERSION 2.8)
16 |
17 | project(face_detection_tutorial)
18 |
19 | # environment variable InferenceEngine_DIR is used to find CMake files in installation
20 | # point to common pieces in Inference Engine's samples directory
21 | if("$ENV{InferenceEngine_DIR}" STREQUAL "")
22 | message(FATAL_ERROR "Environment variable 'InferenceEngine_DIR' is not defined. Before running CMake, please be sure to source the setupvars.sh in the OpenVINO installation directory using the command:\n\tsource /opt/intel/computer_vision_sdk/bin/setupvars.sh\n")
23 | endif()
24 |
25 | message(STATUS "InferenceEngine_DIR=$ENV{InferenceEngine_DIR}")
26 | if(NOT(UNIX))
27 | get_filename_component(InferenceEngine_Samples_DIR "$ENV{InferenceEngine_DIR}/../samples" ABSOLUTE)
28 | else()
29 | set(InferenceEngine_Samples_DIR "$ENV{InferenceEngine_DIR}/../samples" )
30 | endif()
31 |
32 | list (APPEND CMAKE_MODULE_PATH ${InferenceEngine_Samples_DIR}/cmake)
33 | message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
34 |
35 | get_filename_component(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/../share" ABSOLUTE)
36 |
37 | message(STATUS "Looking for inference engine configuration file at: ${CMAKE_PREFIX_PATH}")
38 | find_package(InferenceEngine 1.0)
39 |
40 | if (NOT InferenceEngine_FOUND)
41 | message(FATAL_ERROR "")
42 | endif()
43 |
44 |
45 | if("${CMAKE_BUILD_TYPE}" STREQUAL "")
46 | message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used")
47 | set(CMAKE_BUILD_TYPE "Release")
48 | endif()
49 |
50 | if (NOT(BIN_FOLDER))
51 | if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
52 | set (ARCH intel64)
53 | else()
54 | set (ARCH ia32)
55 | endif()
56 |
57 | set (BIN_FOLDER ${ARCH})
58 | endif()
59 |
60 | if (NOT (IE_MAIN_SOURCE_DIR))
61 | set(NEED_EXTENSIONS TRUE)
62 | # if (WIN32)
63 | # set (IE_MAIN_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../bin/)
64 | # else()
65 | set (IE_MAIN_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
66 | # endif()
67 | endif()
68 |
69 | if(NOT(UNIX))
70 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
71 | set (CMAKE_LIBRARY_PATH ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
72 | set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
73 | set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
74 | set (CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
75 | set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
76 | set (LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER})
77 | set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}) # compatibility issue: linux uses LIBRARY_OUTPUT_PATH, windows uses LIBRARY_OUTPUT_DIRECTORY
78 | else ()
79 | set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
80 | set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
81 | set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
82 | set (CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
83 | set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE})
84 | set (LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${CMAKE_BUILD_TYPE}/lib)
85 | set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}/lib)
86 | endif()
87 |
88 | set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
89 | if (WIN32)
90 | if(NOT "${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
91 | message(FATAL_ERROR "Only 64-bit supported on Windows")
92 | endif()
93 |
94 | set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
95 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS -DNOMINMAX")
96 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") #no asynchronous structured exception handling
97 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
98 | if (ENABLE_OMP)
99 | find_package(OpenMP)
100 | if (OPENMP_FOUND)
101 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
102 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
103 | endif()
104 | endif()
105 | else()
106 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type ")
107 | if (APPLE)
108 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-command-line-argument")
109 | elseif(UNIX)
110 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized -Winit-self -Wmaybe-uninitialized")
111 | endif()
112 | endif()
113 |
114 | include(feature_defs OPTIONAL)
115 |
116 | # Find OpenCV libray if exists
117 | find_package(OpenCV)
118 | include_directories(${OpenCV_INCLUDE_DIRS})
119 | if(OpenCV_FOUND)
120 | add_definitions(-DUSE_OPENCV)
121 | endif()
122 |
123 | ####################################
124 | ## to use C++11
125 | set (CMAKE_CXX_STANDARD 11)
126 | set (CMAKE_CXX_STANDARD_REQUIRED ON)
127 | set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
128 | ####################################
129 |
130 | # Make sure dependencies are present
131 | set(IE_SAMPLES_GFLAGS_DIR "${InferenceEngine_Samples_DIR}/thirdparty/gflags")
132 | set(IE_SAMPLES_FORMAT_READER_DIR "${InferenceEngine_Samples_DIR}/common/format_reader")
133 |
134 | if(NOT EXISTS "${IE_SAMPLES_GFLAGS_DIR}/CMakeLists.txt")
135 | message(FATAL_ERROR "The required 'gflags' library was not found in the Inference Engine's samples at: ${IE_SAMPLES_GFLAGS_DIR}")
136 | endif()
137 | if(NOT EXISTS "${IE_SAMPLES_FORMAT_READER_DIR}/CMakeLists.txt")
138 | message(FATAL_ERROR "The required 'format_reader' library was not found in the Inference Engine's samples at: ${IE_SAMPLES_GFLAGS_DIR}")
139 | endif()
140 |
141 |
142 | set(GFLAGS_IS_SUBPROJECT TRUE)
143 | add_subdirectory(${IE_SAMPLES_GFLAGS_DIR} ${CMAKE_CURRENT_BINARY_DIR}/gflags)
144 | add_subdirectory(${IE_SAMPLES_FORMAT_READER_DIR} ${CMAKE_CURRENT_BINARY_DIR}/format_reader)
145 |
146 | # Properties->C/C++->General->Additional Include Directories
147 | include_directories (
148 | ${InferenceEngine_Samples_DIR}/common/format_reader
149 | ${InferenceEngine_Samples_DIR}
150 | ${InferenceEngine_Samples_DIR}/../include
151 | ${InferenceEngine_Samples_DIR}/thirdparty/gflags/include
152 | ${InferenceEngine_Samples_DIR}/common
153 | )
154 |
155 | if (UNIX)
156 | SET(LIB_DL dl)
157 | endif()
158 |
159 | #add_subdirectory(object_detection_sample)
160 | #add_subdirectory(interactive_face_detection_sample)
161 | #add_subdirectory(security_barrier_camera_sample)
162 | #add_subdirectory(object_detection_demo_ssd_async)
163 | #add_subdirectory(object_detection_sample_ssd)
164 | #add_subdirectory(classification_sample)
165 | #add_subdirectory(classification_sample_async)
166 | #add_subdirectory(hello_classification)
167 | #add_subdirectory(hello_request_classification)
168 | #add_subdirectory(segmentation_sample)
169 | #add_subdirectory(style_transfer_sample)
170 |
171 | if (NEED_EXTENSIONS)
172 | #add_subdirectory(${InferenceEngine_Samples_DIR}/src/extension ${CMAKE_CURRENT_BINARY_DIR}/extension)
173 | #add_subdirectory("/opt/intel/computer_vision_sdk/deployment_tools/inference_engine/src/extension/" ${CMAKE_CURRENT_BINARY_DIR}/extension)
174 | endif()
175 |
176 | #if (OpenCV_FOUND)
177 | # add_subdirectory(validation_app)
178 | #else()
179 | # message(STATUS "Validation app build is switched off")
180 | #endif()
181 |
--------------------------------------------------------------------------------
/dx_face_detection/face_detection.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | // Copyright (c) 2018 Intel Corporation
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | */
16 |
17 | ///////////////////////////////////////////////////////////////////////////////////////////////////
18 | #pragma once
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #ifdef _WIN32
26 | #include
27 | #else
28 | #include
29 | #endif
30 |
31 | /// @brief message for help argument
32 | static const char help_message[] = "Print a usage message.";
33 |
34 | /// @brief message for images argument
35 | static const char video_message[] = "Optional. Path to an video file. Default value is \"cam\" to work with camera.";
36 |
37 | /// @brief message for model argument
38 | static const char face_detection_model_message[] = "Required. Path to an .xml file with a trained face detection model.";
39 | static const char age_gender_model_message[] = "Optional. Path to an .xml file with a trained age gender model.";
40 | static const char head_pose_model_message[] = "Optional. Path to an .xml file with a trained head pose model.";
41 |
42 | /// @brief message for plugin argument
43 | static const char plugin_message[] = "Plugin name. For example MKLDNNPlugin. If this parameter is pointed, " \
44 | "the sample will look for this plugin only.";
45 |
46 | /// @brief message for assigning face detection calculation to device
47 | static const char target_device_message[] = "Specify the target device for Face Detection (CPU, GPU, FPGA, or MYRIAD. " \
48 | "Sample will look for a suitable plugin for device specified.";
49 |
50 | /// @brief message for assigning age gender calculation to device
51 | static const char target_device_message_ag[] = "Specify the target device for Age Gender Detection (CPU, GPU, FPGA, or MYRIAD. " \
52 | "Sample will look for a suitable plugin for device specified.";
53 |
54 | /// @brief message for number of simultaneously age gender detections using dynamic batch
55 | static const char num_batch_ag_message[] = "Specify number of maximum simultaneously processed faces for Age Gender Detection ( default is 1).";
56 |
57 | /// @brief message for assigning age gender calculation to device
58 | static const char target_device_message_hp[] = "Specify the target device for Head Pose Detection (CPU, GPU, FPGA, or MYRIAD. " \
59 | "Sample will look for a suitable plugin for device specified.";
60 |
61 | /// @brief message for number of simultaneously age gender detections using dynamic batch
62 | static const char num_batch_hp_message[] = "Specify number of maximum simultaneously processed faces for Head Pose Detection ( default is 1).";
63 |
64 | /// @brief message for performance counters
65 | static const char performance_counter_message[] = "Enables per-layer performance report.";
66 |
67 | /// @brief message for clDNN custom kernels desc
68 | static const char custom_cldnn_message[] = "Required for clDNN (GPU)-targeted custom kernels."\
69 | "Absolute path to the xml file with the kernels desc.";
70 |
71 | /// @brief message for user library argument
72 | static const char custom_cpu_library_message[] = "Required for MKLDNN (CPU)-targeted custom layers." \
73 | "Absolute path to a shared library with the kernels impl.";
74 |
75 | /// @brief message for probability threshold argument
76 | static const char thresh_output_message[] = "Probability threshold for detections.";
77 |
78 | /// @brief message raw output flag
79 | static const char raw_output_message[] = "Inference results as raw values.";
80 |
81 | /// @brief message no wait for keypress after input stream completed
82 | static const char no_wait_for_keypress_message[] = "No wait for key press in the end.";
83 |
84 | /// @brief message no show processed video
85 | static const char no_show_processed_video[] = "No show processed video.";
86 |
87 |
88 | /// \brief Define flag for showing help message
89 | DEFINE_bool(h, false, help_message);
90 |
91 | /// \brief Define parameter for set image file
92 | /// It is a required parameter
93 | DEFINE_string(i, "cam", video_message);
94 |
95 | /// \brief Define parameter for face detection model file
96 | /// It is a required parameter
97 | DEFINE_string(m, "", face_detection_model_message);
98 |
99 | /// \brief Define parameter for face detection model file
100 | /// It is a required parameter
101 | DEFINE_string(m_ag, "", age_gender_model_message);
102 |
103 | /// \brief Define parameter for face detection model file
104 | /// It is a required parameter
105 | DEFINE_string(m_hp, "", head_pose_model_message);
106 |
107 | /// \brief device the target device for face detection infer on
108 | DEFINE_string(d, "CPU", target_device_message);
109 |
110 | /// \brief device the target device for age gender detection on
111 | DEFINE_string(d_ag, "CPU", target_device_message_ag);
112 |
113 | /// \brief device the target device for age gender detection on
114 | DEFINE_uint32(n_ag, 1, num_batch_ag_message);
115 |
116 | /// \brief device the target device for head pose detection on
117 | DEFINE_string(d_hp, "CPU", target_device_message_hp);
118 |
119 | /// \brief device the target device for head pose detection on
120 | DEFINE_uint32(n_hp, 1, num_batch_hp_message);
121 |
122 | /// \brief Enable per-layer performance report
123 | DEFINE_bool(pc, false, performance_counter_message);
124 |
125 | /// @brief clDNN custom kernels path
126 | /// Default is ./lib
127 | DEFINE_string(c, "", custom_cldnn_message);
128 |
129 | /// @brief Absolute path to CPU library with user layers
130 | /// It is a optional parameter
131 | DEFINE_string(l, "", custom_cpu_library_message);
132 |
133 | /// \brief Flag to output raw scoring results
134 | /// It is an optional parameter
135 | DEFINE_bool(r, false, raw_output_message);
136 |
137 | /// \brief Flag to output raw scoring results
138 | /// It is an optional parameter
139 | DEFINE_double(t, 0.5, thresh_output_message);
140 |
141 | /// \brief Flag to disable keypress exit
142 | /// It is an optional parameter
143 | DEFINE_bool(no_wait, false, no_wait_for_keypress_message);
144 |
145 | /// \brief Flag to disable processed video showing
146 | /// It is an optional parameter
147 | DEFINE_bool(no_show, false, no_show_processed_video);
148 |
149 | /**
150 | * \brief This function show a help message
151 | */
152 | static void showUsage() {
153 | std::cout << std::endl;
154 | std::cout << "face_detection_tutorial [OPTION]" << std::endl;
155 | std::cout << "Options:" << std::endl;
156 | std::cout << std::endl;
157 | std::cout << " -h " << help_message << std::endl;
158 | std::cout << " -i \"\" " << video_message << std::endl;
159 | std::cout << " -m \"\" " << face_detection_model_message<< std::endl;
160 | std::cout << " -m_ag \"\" " << age_gender_model_message << std::endl;
161 | std::cout << " -m_hp \"\" " << head_pose_model_message << std::endl;
162 | std::cout << " -l \"\" " << custom_cpu_library_message << std::endl;
163 | std::cout << " Or" << std::endl;
164 | std::cout << " -c \"\" " << custom_cldnn_message << std::endl;
165 | std::cout << " -d \"\" " << target_device_message << std::endl;
166 | std::cout << " -d_ag \"\" " << target_device_message_ag << std::endl;
167 | std::cout << " -d_hp \"\" " << target_device_message_hp << std::endl;
168 | std::cout << " -n_ag \"\" " << num_batch_ag_message << std::endl;
169 | std::cout << " -n_hp \"\" " << num_batch_hp_message << std::endl;
170 | std::cout << " -no_wait " << no_wait_for_keypress_message << std::endl;
171 | std::cout << " -no_show " << no_show_processed_video << std::endl;
172 | std::cout << " -pc " << performance_counter_message << std::endl;
173 | std::cout << " -r " << raw_output_message << std::endl;
174 | std::cout << " -t " << thresh_output_message << std::endl;
175 | }
176 |
--------------------------------------------------------------------------------
/dx_face_detection/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | // Copyright (c) 2018 Intel Corporation
3 | //
4 | // Licensed under the Apache License, Version 2.0 (the "License");
5 | // you may not use this file except in compliance with the License.
6 | // You may obtain a copy of the License at
7 | //
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // Unless required by applicable law or agreed to in writing, software
11 | // distributed under the License is distributed on an "AS IS" BASIS,
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | // See the License for the specific language governing permissions and
14 | // limitations under the License.
15 | */
16 |
17 | /**
18 | * \brief The entry point for the Inference Engine interactive_face_detection sample application
19 | * \file object_detection_sample_ssd/main.cpp
20 | * \example object_detection_sample_ssd/main.cpp
21 | */
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include