The Face Access Control application is one of a series of IoT reference implementations aimed at instructing users on how to develop a working solution for a particular problem. The solution uses facial recognition as the basis of a control system for granting physical access. The application detects and registers the image of a person’s face into a database, recognizes known users entering a designated area and grants access if a person’s face matches an image in the database.
From this reference implementation, developers will learn to build and run an application that:
- Detects and registers the image of a person’s face into a database
- Recognizes known users entering a designated area
- Grants access if a person’s face matches an image in the database
How it Works
The Face Access Control system consists of two main subsystems:
- cvservice is a C++ application that uses the Intel® Computer Vision SDK (Intel® CV SDK). It connects to a USB camera (for detecting faces) and then performs facial recognition based on a training data file of authorized users to determine if a detected person is a known user or previously unknown. Messages are published to a MQTT* broker when users are recognized and the processed output frames are written to stdout in raw format (to be piped to ffmpeg for compression and streaming). Here, the Photography Vision Library is used for facial detection and recognition.
- webservice uses the MQTT broker to interact with cvservice. It's an application based on Node.js* for providing visual feedback at the user access station. Users are greeted when recognized as authorized users or given the option to register as a new user. It displays a high-quality, low-latency motion jpeg stream along with the user interface and data analytics.
In the UI, there are three tabs:
- live streaming video
- user registration
- analytics of access history.
This is what the live streaming video tab looks like:
This is what the user registration tab looks like:
This is an example of the analytics tab:
- 5th Generation Intel® Core™ processor or newer or Intel® Xeon® v4, or Intel® Xeon® v5 Processors with Intel® Graphics Technology (if enabled by OEM in BIOS and motherboard) [tested on NUC6i7KYK]
- USB Webcam [tested with Logitech* C922x Pro Stream]
How to set up
Intel® CV SDK
Download and install OpenCL*
The Intel® CV SDK requires OpenCL*, which is available as a separate download. We provide a script that helps with the installation process here. Unpack the archive using:
tar xf install_OCL_driver2_sh.tgz
Then prepare a temporary workspace and run the script:
./install_OCL_driver2.sh install --workspace opencl-temp
For this application you do not need to recompile the Linux* kernel thus answer no when asked during the installation process. Additional details and instructions are provided in this article. The System Analyzer Utility mentioned in the article can be use to confirm proper installation.
Download and Install the Intel® CV SDK
The guide for installing the Intel® CV SDK is offered here. After completing the registration, download the archive for Ubuntu*, unpack it, and run the GUI installer:
tar xaf intel_cv_sdk_ubuntu_<version>.tgz
When prompted, install as the root user or as a user with root permissions. The rest of the guide assumes you will install the Intel® CV SDK under the default location.
After installation, don't forget to source the CV SDK environment variables:
This will be required for building and running cvservice. To automate this process, you can source the script from .profile or .bashrc. Alternatively, you can add the variables to /etc/environment.
This reference implementation uses ffmpeg to compress and stream video output from cvservice to the webservice clients. ffmpeg is installed separately from the Ubuntu repositories:
sudo apt update
sudo apt install ffmpeg
Install Paho* MQTT* C client libraries dependencies
This reference implementation uses MQTT to send data between services. To install the dependencies:
sudo apt update
sudo apt install libssl-dev
Building the executable (from cvservice directory):
Instructions on how to setup the Node.js services are provided in the webservice folder.
Running the application
Start the webservice, both server and front-end components.
Start ffserver with:
sudo ffserver -f ./ffmpeg/server.conf
Export the needed ENV vars:
From the cvservice/build directory start cvservice and pipe to ffmpeg:
./cvservice 0 2>/dev/null | ffmpeg -f rawvideo -pixel_format bgr24 -video_size vga -i - http://localhost:8090/fac.ffm