Learn how to:
- Build the DLDT Inference Engine on your host Windows* machine.
- Use the engine to build the Security Camera Demo App from Open Model Zoo, also on your host Windows* machine.
- Run the Security Camera Demo App from inside a Windows* Docker container.
Step 1: Install Dependencies
To build the Security Barrier Camera Demo, you need to have these programs installed on your system. The versions for Visual Studio Community and the Intel® C++ Compiler are important!
NOTE: You must install Visual Studio Community before you install the Intel® C++ Compiler!
|Visual Studio Community Visual C++|
|building DLDT and security camera demos|
|Intel® C++ Compiler||19.0 (important)||building DLDT (absolutely necessary for certain builds to complete)|
|Docker||18.09.2||building and running the Docker container|
|CMake||3.14.5||generating VS 2017 solutions|
|Git||2.22.0.windows.1||pulling from various repos|
|Python 3 (not Python 2)||3.6.8||downloading open_model_zoo models|
|GNU Wget||1.11.4||downloading various packages for CMake|
Visual Studio Community 2017
- Download the Visual Studio Installer.
- Only download the Desktop development with C++ workload.
Intel® C++ Compiler
- Download the Intel® Parallel Studio XE package installer. You will need to get a license for it (use the free trial or a student account). Make sure to select the customizable installer from the download page.
- Intel® C++ Compiler 19.0 Update 4
- Intel® Threading Building Blocks 2019 Update 6
- NOTE: The Intel® Debugger Extension 8.2 may be automatically checked. You may leave it checked or uncheck it.
- On the top right corner, you may choose to uncheck the box next to IA-32 (it is not needed)
- If you follow these, your installation size (shown in the GUI) should be about 1.8GB.
- Select whether to consent to your information being collected.
- Next to IDE Integration, select Customize. Choose Visual Studio 2017 as your integration target.
- Proceed to install the packages you selected!
NOTE: The installation might take a while (~30 minutes to over 1 hour) with no progress update. Make sure to be patient and let the Finish button show up or else it will not install properly!
- Download Docker Desktop.
- After the installation completes, you will be prompted to log out.
- Log back in. On startup, Docker will ask you if you want to enable Hyper-V. Click Yes and you will be prompted to restart your computer. If you are never prompted to enable Hyper-V, see how to do so manually here.
- Right click Docker icon in the taskbar menu and select Switch to Windows* containers...
- Right click Docker icon, go to Settings
- In General, check "Expose daemon on..."
- If you are working behind a proxy, in Proxies, check Manual proxy configuration and add your configurations.
- Make sure to click "Apply" to properly apply these settings! You will have to restart Docker.
- You are now ready to use Docker!
- Cmake Installer Page
- in the installer, make sure to check the option to add CMake to PATH
- Python 3.6.8
- in the installer, make sure to check the option to add Python to PATH
- GNU Wget Installer
Step 2: Configure Proxies (only if needed)
If you are operating behind a proxy, make sure to set your HTTP_PROXY and HTTPS_PROXY environment variables to your corresponding proxy server addresses.
Step 3: Build the DLDT Inference Engine
NOTE: The steps to build the DLDT Inference Engine can also be found here.
First, clone dldt and its submodules:
git clone https://github.com/opencv/dldt.git cd dldt\inference-engine git submodule init git submodule update --recursive
NOTE: On rare occasion, git submodule init and git submodule update --recursive will fail to pull from the ade repository. Pay attention to possible error logs! You many need to check dldt\inference-engine\thirdparty\ade to see if it is empty. If it is empty, you will need to manually clone ade from this repo.
Next, build the Visual Studio solution files. Pay attention to the parameters you pass into CMake! Note that specifying the Intel® C++ Compiler via the -T flag (as opposed to MSVC, etc.) is mandatory, or else many essential libraries (i.e. MKLDNNPlugin.dll) will fail to build!
- Make sure to change the Intel® C++ Compiler version in your command syntax to match whichever version you have installed (if you are not using version 19.0)
- Make sure to specify the Win64 Visual Studio generator, or else the process will silently fail.
cd ...\dldt\inference-engine mkdir build cd build cmake .. -G "Visual Studio 15 2017 Win64" -T "Intel C++ Compiler 19.0" ^ -DCMAKE_BUILD_TYPE=Release -DICCLIB="C:\Program Files ^ (x86)\IntelSWTools\compilers_and_libraries_2019\windows\compiler\lib"
NOTE: If this fails, try running this command on the "Intel Compiler 19.0 Update 4 Intel(R) 64 Visual Studio 2017" shell environment. It should be located at C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Intel Parallel Studio XE 2019\Compiler and Performance Libraries\Command Prompt with Intel® Compiler 19.0 Update 4.
Finally, build the executables:
cmake --build . --config Release
NOTE: You MUST build in "Release" mode! Failing to build in "Release" mode will cause the Security Barrier Camera Demo to fail to build later on (it will not recognize the Directory name or the names of several .dll's)
Step 3: Build OpenCV
First, clone opencv.
git clone https://github.com/opencv/opencv.git
Next, build the OpenCV solution files, and then OpenCV!
cd ...\opencv mkdir build cd build cmake -G "Visual Studio 15 2017 Win64" .. cmake --build . --config Release
NOTE: The DLDT repository actually contains all the necessary OpenCV libraries for building the camera demo. However, building the app using the original repository solves some problems with decoding .mp4 videos inside the Windows* Docker container.
Step 4: Build Security Camera Barrier Demo from Open Model Zoo
NOTE: The steps to build the demo can also be found here.
First, clone the Open Model Zoo repository and switch to the 2019 branch.
git clone https://github.com/opencv/open_model_zoo.git cd open_model_zoo git checkout 2019
We want to build the demos manually using the Inference Engine libraries from dldt, so we set the InferenceEngine_DIR environment variable to the dldt build directory (your path depends on where your dldt folder is located):
$env:InferenceEngine_DIR = "...dldt\inference-engine\build"
We want to use the OpenCV libraries from our own installation of OpenCV, not the libraries included in the dldt repo), so we will set the OpenCV_DIR environment variable to the directory containing the OpenCVConfig.cmake file.
$env:OpenCV_DIR = "...\opencv\build"
NOTE: (See note in Step 3) Alternatively, you may link the OpenCV directory inside the dldt repo:
$env:OpenCV_DIR = "...\dldt\inference-engine\temp\opencv_4.1.0\cmake"
The benefit of this is that you don't actually need to install OpenCV from its own repo (you can skip step 3). However, if you do this, the demo application will not be able to read .mp4 files.
Next, we simply run
to build the demos. The demos, including security_barrier_camera_demo.exe, are found in C:\Users\<username>\Documents\Intel\OpenVINO\omz_demos_build_build\intel64\Release , where <username> is your account username.
In order to download the appropriate models for the security barrier camera demo, we run these commands:
pip install requests pip install pyyaml cd ...\open_model_zoo\model_downloader python .\downloader.py --name 'vehicle-license-plate-detection-barrier-0106,vehicle-attributes-recognition-barrier-0039,license-plate-recognition-barrier-0001'
The downloader.py script downloads these three models, all of which will be used by security_barrier_camera_demo.exe:
A full list of models can be found here. However, these are the only models you should download for the security barrier camera app demo.
At this point, everything we need is built, and all we need to do is transfer necessary files to the Docker container.
Step 5: Aggregating Dynamic Libraries
In order for security_camera_barrier_demo.exe to run, it must have access to the .dll's below.
NOTE: The IntelSWTools libraries come with installing the Intel® C++ Compiler.
|File Directory||Library Files|
|C:\Program Files (x86)\IntelSWTools\...*||libmmd.dll|
We also need some .dll's that come with the Visual C++ runtime, which are found in System32 on your host. You do not need to copy these files into the Docker container, however, as we can install the Visual C++ runtime via Dockerfile.
|File Directory||Library Files|
Make these .dll's accessible by either placing them in the same folder as the executable, or adding the directories containing them to your PATH.
Step 6: Building the Docker Image
Before we run docker build, we need to arrange all the necessary files in a special format so that we can copy them into the Docker container.
Here is a file structure guide and a list of files that must be put inside the Docker container.
security-barrier-camera-app ├── Dockerfile ├── security_barrier_camera_demo.exe ├── vc_redist.x64.exe ├── models | ├── license-plate-recognition-barrier-0001.bin | ├── license-plate-recognition-barrier-0001.xml | └── ... (6 files total) └── bin └── (all necessary .dll files)
List of Files
- Found in ...\Documents\Intel\OpenVINO\omz_demos_build\intel64\Release
- This is the security camera demo app
- You may download it from here.
- This executable will be used to install the Visual C++ runtime.
- All of the .dll files listed above (in the table)
- Comprehensive list:
- Comprehensive list:
- Compressed machine learning models from Open Model Zoo (both the .bin and .xml files for each)
- License Plate Recognition Barrier Model
- Found in open_model_zoo\model_downloader\Security\object_attributes\vehicle\resnet10_update_1\dldt
- Vehicle Attributes Recognition Barrier Model
- Found in open_model_zoo\model_downloader\Security\object_detection\barrier\0106\dldt
- Vehicle License Plate Detection Barrier Model
- Found in open_model_zoo\model_downloader\Security\optical_character_recognition\license_plate\dldt
- License Plate Recognition Barrier Model
Go to the directory containing your Dockerfile and build the image.
cd <directory with Dockerfile in it> docker build -t security-app .
NOTE: Pulling the Windows* amd-64 image may take a LONG time, and at times you may see full progress bars with no progress update (during "Extracting" phase) for over 20 minutes. Be patient! Check your task manager, and if Docker is still running, it means that the build is probably working, even if it may not seem so.
NOTE: If you see errors on build such as "a Windows version XXX-based image is incompatible with XXX host," check your Windows* version. TheThe provided Dockerfile uses the Windows* 10 1903 base image, but an older Windows* host cannot run a newer Windows* container. For example, if your Windows* Version is Windows* 10 1809, you will need to edit the base image to mcr.microsoft.com/windows:1809-amd64
# escape=` # Use full Windows image (Server Core and Nano Server lack some library files) FROM mcr.microsoft.com/windows:1903-amd64 # Copy files over COPY ["bin", "C:/demo/bin"] COPY ["models", "C:/demo/models"] COPY ["security_barrier_camera_demo.exe", "C:/demo/security_barrier_camera_demo.exe"] # Install Visual C++ runtime COPY ["vc_redist.x64.exe", "C:/temp/vc_redist.x64.exe"] RUN C:\temp\vc_redist.x64.exe /install /quiet /norestart # Default to Powershell when running SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass"] # Add bin to PATH RUN $newpath = $env:path + "';C:\demo\bin;C:\demo'" ; ` Set-ItemProperty -Path ` 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' ` -Name PATH -Value $newpath
Step 7: Running in Docker Container
Use the command below to run the camera demo in the Docker container.
- [$path] should be the absolute path to the folder containing the images / videos you want to run the app on.
- i.e. you may download this image of a car, and if the image's full path is "/home/folder/car_1.bmp", replace [$path] with "/home/folder".
- The -no_show and -r flags are used to make sure that the application output is printed as text (as we cannot view image or video output from the Docker container).
docker run -v [$path]:C:\media -it security-app security_barrier_camera_demo -i C:/media/car_1.bmp -d CPU -d_va CPU -d_lpr CPU -m C:/demo/models/vehicle-license-plate-detection-barrier-0106.xml -m_va C:/demo/models/vehicle-attributes-recognition-barrier-0039.xml -m_lpr C:/demo/models/license-plate-recognition-barrier-0001.xml -no_show -r
If everything works properly, the output should print some inference results describing the car and its license plate.