Facial Recognition Access Control
Tags: azure, iot, dotnet, ai
Published: 2020-01-28 11:24:28



# About 

The Experiment #103 researches about the possibilities of applying Cognitive Services to create an access control system only managed by an Artificial Intelligence by giving it the capabilities of speaking human languages and recognizing human faces.

# Idea

The project tries to simulate an automatic access control system with facial recognition. The application will tell the visitor if he/she is or is not in a white list in order to open and welcome him/her or to keep the door closed to strangers. The idea is based on an old project from [huckster.io](https://www.hackster.io/windows-iot/windows-iot-facial-recognition-door-e087ce) created by [Ethan Kusters](https://www.hackster.io/ethankusters) and [Masato Sudo](https://www.hackster.io/mazudo) and published in 2016.

# Utility

For this simulation we will build a smart box. This box will contain an item hidden behind a little door. The door will be locked until the application recognizes a face included in the white list. If the Artificial Intelligence recognizes the visitor the door will automatically open, showing up the item. This way, the owners of this system only have to take care of who take part of the white list by enrolling the different visitors.

# Process

First, we are going to create a Windows Universal Platform application with C Sharp and .Net Core. This application will be our user interface. After that, we will connect a Webcam to interact with the [Cognitive Service Vision Face API](https://azure.microsoft.com/en-us/services/cognitive-services/face/). Then, we will to ensemble all the electronic parts, a LED light, a button and a servo motor. We will install [Windows 10 IoT Core](https://docs.microsoft.com/en-us/windows/iot-core/) on a [Raspberry Pi 2 model B GPIO](https://www.raspberrypi.org/products/raspberry-pi-2-model-b/) device to run the application on it. Also, we will build our 3D printed smart box to contain the entire project and the electronics. Finally, we will plug in a speaker to hear the machine speaking thanks to the [Cognitive Service Text to Speech API](https://azure.microsoft.com/en-us/services/cognitive-services/text-to-speech/).

# Advantages

The principal advantage of using Cognitive Services in this simulation is the possibility of identifying people quickly and accurately. The Artificial Intelligence can work for us 24 hours a day, 7 days a week without any interruption. This way a company will save money and resources and will be very much efficient controlling the accesses to a building for example. In addition, with the capability to speak we can give the machine a more human appearance.

# Architecture

![PoC facial recognition architecture diagram](https://www.idiwork.com/wp-content/uploads/PoC_Facial_Recognition_Architecture_Diagram_A.png)

First, we created a Windows Universal Application to run the project on desktop and mobile. This app allows us to register the faces of our whitelisted users (01). These people will be the ones with access permissions.

The app connects to Azure (02) and its [Cognitive Services](https://azure.microsoft.com/en-us/services/cognitive-services/) (03) to use the [Text to Speech](https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/text-to-speech) (04) service and the [Face](https://docs.microsoft.com/en-us/azure/cognitive-services/face/) (05) service we have previously deployed.

With the [Face](https://docs.microsoft.com/en-us/azure/cognitive-services/face/) cognitive service, we can store all users by adding their photos to a Person Group List (06) in the cloud.

There are reverse arrows in the diagram because the process works also for consulting the Person Group list and tell us if the visitor is registered on it.

If you want to read more go to [this post](https://www.idiwork.com/experiment-103-architectural-diagram/).
 
# Step by Step

## 1. How to work with Face Cognitive Service

First, we are going to create the [Face Resource](https://docs.microsoft.com/en-us/azure/cognitive-services/face/) from our Azure portal under [Cognitive Services](https://azure.microsoft.com/en-us/services/cognitive-services/) group:

![Face service GIF](https://www.idiwork.com/wp-content/uploads/Face_Service.gif)

If you want to see the whole process just go to [this post](https://www.idiwork.com/experiment-103-how-to-modify-the-project-to-work-with-face-cognitive-service-and-servo-motor/).


## 2. How to set up the IoT device hardware

We will use a [Raspberry Pi 2 Model B](https://www.raspberrypi.org/products/raspberry-pi-2-model-b/) to run our IoT project. Also, we need to attach to it some peripherals like: Nano USB Wi-Fi Adapter, USB Compact Speaker Set and Microsoft LifeCam HD-3000.

{% youtube BEEPtL6jqNA %}

If you want to see the whole process visit [this post](https://www.idiwork.com/experiment-103-how-to-set-up-the-iot-device-hardware-peripherals-and-electronics/).

## 3. How to pack and launch the IoT project

The 3D model of the project box was created in [SketchUp](https://www.sketchup.com/). Inside the six faces, there are individual spaces for each component.

Then, we used a [Slicer Software](https://www.prusa3d.com/prusaslicer/) to convert the STL 3D files into G-Code that our 3D Printer can understand and print.

Finally, we printed the 3D parts in a [Prusa i3 MK2S](https://www.prusa3d.com/prusaslicer/) printer with black, red and white filaments from [Smart Materials](https://www.smartmaterials3d.com/).

{% youtube 2hq4-DKWP5M %}

If you want to see the whole process just go to [this post](https://www.idiwork.com/experiment-103-how-to-build-a-3d-printed-box-to-pack-and-run-the-iot-project/).

### Links

- [Azure Cognitive Services](https://azure.microsoft.com/en-us/services/cognitive-services/)
- [Cognitive Services – Face API](https://azure.microsoft.com/en-us/services/cognitive-services/face/)
- [Cognitive Services – Text to Speech](https://azure.microsoft.com/en-us/services/cognitive-services/text-to-speech/)
- [Raspberry Pi 2 Model B](https://www.raspberrypi.org/products/raspberry-pi-2-model-b/)
- [Windows IoT Core](https://developer.microsoft.com/en-us/windows/iot)
- [Windows IoT Dashboard](https://docs.microsoft.com/en-us/windows/iot-core/connect-your-device/iotdashboard)
- [Thingiverse 3D Model](https://www.thingiverse.com/thing:4020615)
- [SketchUp 3D Software](https://www.sketchup.com/)
- [Prusa i3 MK2 3D Printer](https://www.prusa3d.com/)
- [PrusaSlicer Software](https://www.prusa3d.com/prusaslicer/)
- [3D Printing Filament](https://www.smartmaterials3d.com/)

Check the code in the [GitHub repo](https://github.com/idiWork/Experiment_103)!