Automatic Face Recognition Technologies Using Raspberri Pi

People learn to recognize faces from birth and nearly at the age of four months can identify one person from another. This feature is unique to the human brain because other species identify by smells and touch. The human brain takes only an instant to assess the features on those faces and fits them to the matching individual. But it is a complex program for a computer.

Here are a few basic steps.

Step 1: An image of the face is captured from a photo or video.
Step 2: Facial recognition algorithm identifies facial features -such as the shape and width of the nose and the distance between the eyes- that are key to distinguishing a face. The result: a unique facial print.
Step 3: The facial print is compared to a database of known faces.
Step 4: Matching is made with an image in the facial recognition system database with a variation in accuracy.

Automatic Face Recognition system has seen tremendous improvements in performance over the past couple of years. It has gone from being a key feature of highly advanced security system in bond movies to existing all around us. Remember Apple released the Face ID –the face recognition feature- on the i-phone in 2017 and Facebook is working on Facial recognition system for identification for its users.

The distinct advantage of using face recognition over other biometrics systems using fingerprint/ palmprint, iris is its non-contact process. Facial images can be captured from a distance without any direct interaction with the person.

One of our client in Africa is a leading coffee processor with multiple factories across Ethiopia and other African countries. Majority of their labour force consisted of uneducated coffee pickers and other labourers. Hence they required low cost and efficient automatic face recognition system for the attendance recording of employees in the factory environment without any employee intervention.

Automatic Face Recognition Using Raspberry Pi

Verbat Innovation Labs developed an Automatic Face Recognition systems for the African client using Raspberry Pi. Raspberry Pi is a minicomputer the size of a credit card and is of a very low price with better resolution and low power consumption feature. It is also a portable stand-alone device.

The system is programmed using Python programming language and the operating system used here is Raspbian OS. The system is programmed using Python and Open CV, an Open-source computer vision and machine learning software library. Open CV Computer Vision with Python Learn to capture videos, manipulate images, and track objects.

The Work Flow for the System

1. Image Acquisition & Database Creation

The facial features of the employees are stored in a database corresponding to the employee ID. The Raspberry Pi Camera Module (which is connected to the Raspberry Pi) takes numerous images of each person with varied facial expressions and stores this in the database. These images are then feature extracted and a trainer YML file is created which contains the numerical/vectored values of the features unique to each person.

2. Face Detection

OpenCV already contains many pre-trained classifiers for face, eyes, smile etc. Those XML files are stored in opencv/data/haarcascades folder. The following Haarcascade.xml files are used haarcascade_frontalface_alt.xml, haarcascade_eye.xml, haarcascade_mcs_nose.xml, haarcascade_mcs_mouth.xml. As their names suggest, these cascades are for tracking faces, eyes, noses, and mouths.

v2.CascadeClassifier.detectMultiScale () function is used to detect the faces. It takes 3 arguments – the input image, scaleFactor and minNeighbours.
Image: This is an image to be analyzed. It must have 8 bits per channel.
scaleFactor specifies how much the image size is reduced with each scale.
minNeighbours specifies how many neighbours each candidate rectangle should have to retain it.

The detectMultiScale () function returns a list of coordinates to the haarcascade_frontalface_alt.xml for the rectangular regions where faces were found.

We use these coordinates to draw the rectangles on the image. OpenCV provides a rectangle () function for drawing. However, its arguments represent a rectangle differently than Face does. Colour should normally be either a BGR triplet (of values ranging from 0 to 255) or a grayscale value (ranging from 0 to 255), depending on the image’s format.

3. Feature Extraction

When the faces are detected, the background is completely ignored and a rectangle box is enclosed over the face, and only the image portion within it is used for comparison with the database. If the size of the captured images is greater than those of the database images, proper size reduction is done for seamless comparison. The images in the database are then fed into a training algorithm, which generates the .YML file containing the values of extracted features.

4. Recognition & Attendance

The recognition algorithm used in this project is Local Binary Patterns Histogram algorithm (LBPH). LBPH facial recognition compares the input facial image with all facial images from a database to find the employee that matches that face. It is provided by the OpenCV library.

This algorithm is used because it is simpler to be implemented within the processing capacity of the Raspberry Pi. This algorithm analyzes each image in the database independently and the images are recognized locally. Inbuilt functions in the Open-CV (Computer Vision) library is used to implement the LBPH algorithm for face recognition.

The image is divided into many square regions, and each square region is converted into the LBPH matrix, which is a binary matrix created as a result of the LBPH operator. This matrix has in its binary values that form the histogram representation of the image stored in the .YML file. This histogram is then compared to the histograms of face images in the database, and the name associated with the recognized image is displayed.

Project Advantages

  • Authentication
  • People Flow management
  • User Involvement
  • Accuracy
  • Productivity
  • High Identification Speed
  • Ease of Use
  • Low IT Infrastructure cost, future proof
  • Flexibility on Deployment
  • Security Elimination of impersonation