You are on page 1of 19

ANALYSIS OF FACIAL RECOGNITION SYSTEM USING LBPH

ALGORITHM

compiled as one of the requirements for completing the Undergraduate Study Program in
the Electrical Engineering Department, Faculty of Engineering

by:

M HAIDAR REZA
D400184040

ELECTRICAL ENGINEERING STUDY PROGRAM


FACULTY OF ENGINEERING
UNIVERSITAS MUHAMMADIYAH SURAKARTA
2022
i
a

ii
iii
ANALYSIS OF FACIAL RECOGNITION SYSTEM USING LBPH
ALGORITHM

Abstract

Biometric authentication is a way to identify and verify individuals by analyzing


biological characteristics that are unique. One of the biometric authentications that are
often used is facial recognition. Facial recognition is a technology used for matching a
human face from an image or video. For making a facial recognition there are four steps:
they are face detection, face alignment, feature extraction, and face recognition. Several
factors also must be considered when making facial recognition factors like
environmental factors, quality of image, shifting, and scaling of images can affect the
facial recognition accuracy greatly. In this study writer designed a facial recognition
system using LBPH (Local Binary Pattern Histogram) algorithm in the Raspberry Pi 3
Model B+ with Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz as processor and 1GB ram.
This system was designed by connecting 5mp Picamera into CSI camera port in
Raspberry Pi. To make this facial recognition system several algorithms were used such
as haar cascade classifier and LBPH algorithm with the help of OpenCV library. In this
facial recognition system, several test were conducted to know the accuracy of the
system in various conditions such as distance, lighting, and face position. This study
resulted that LBPH algorithm with 5mp camera can detect a face at a maximum of
100cm from the camera and able to detect a face when the lighting is enough.

Keywords: Raspberry Pi, LBPH, Haar Cascade, OpenCV, Python.

Abstrak

Otentikasi biometrik adalah cara untuk mengidentifikasi dan memverifikasi individu


dengan menganalisis karakteristik biologis yang unik. Salah satu otentikasi biometrik
yang sering digunakan adalah pengenalan wajah. Pengenalan wajah adalah teknologi
yang digunakan untuk mencocokkan wajah manusia dari sebuah gambar atau video.
Untuk membuat pengenalan wajah ada empat langkah yaitu deteksi wajah, penyelarasan
wajah, ekstraksi fitur, dan pengenalan wajah. Beberapa faktor juga harus
dipertimbangkan saat membuat pengenalan wajah, faktor seperti faktor lingkungan,
kualitas gambar, pergeseran, dan penskalaan gambar dapat sangat mempengaruhi akurasi
pengenalan wajah. Pada penelitian ini penulis merancang sistem pengenalan wajah
menggunakan algoritma LBPH (Local Binary Pattern Histogram) pada Raspberry Pi 3
Model B+ dengan Cortex-A53 (ARMv8) SoC 64-bit @ 1.4GHz sebagai prosesor dan
ram 1GB. Sistem ini dirancang dengan menghubungkan Picamera 5mp ke port kamera
CSI di Raspberry Pi. Untuk membuat sistem pengenalan wajah ini digunakan beberapa
algoritma seperti haar cascade classifier dan algoritma LBPH dengan bantuan library
OpenCV. Pada sistem pengenalan wajah ini dilakukan beberapa pengujian untuk
mengetahui keakuratan sistem pada berbagai kondisi seperti jarak, pencahayaan, dan
posisi wajah. Penelitian ini menghasilkan algoritma LBPH dengan kamera 5mp dapat
mendeteksi wajah maksimal 100cm dari kamera dan mampu mendeteksi wajah saat
pencahayaan cukup.

Kata Kunci: Raspberry Pi, LBPH, Haar Cascade, OpenCV, Python

1
1. INTRODUCTION
Biometric is body measurements and calculations related to human characteristics.
Biometric authentication is used in computer science as a form of identification. The
working principle of biometric authentication is by measuring the intrinsic physical or
behavioral trait. There are two main types of biometric identifiers that are physiological
characteristics and behavioral characteristics. The Physiological identifiers relate to the
composition of the user being authenticated. While Behavioral identifiers include the unique
ways in which individuals act.
One of the physiological identifiers of biometric identification is facial recognition. facial
recognition is a technology capable of matching a human face from a digital image or a video
frame against a database of faces by mapping an individual's facial features mathematically.
Facial recognition is used to authenticate users through ID verification services. With the help of
artificial intelligent system, the facial structure of humans can be analyzed..
There are several methods for recognizing a person’s face. Each method has different
characteristics and accuracy. Recognition accuracy is the most important factor in facial
recognition algorithms. There are many factors that affect recognition accuracy. Environmental
factors, quality of image, shifting, and scaling of images are the common factors that affect the
recognition accuracy(Paul & Acharya, n.d.).
For recognizing the face, software goes through several processes the first step is face
detection. One of the popular algorithms used in face detection is Viola-Jones Detection
Technique known as Haar Cascades. The following process is analyzing the face that is captured.
By analyzing the data software can convert the image to data. This data then compared to the face
in the database by matching geometric features of the face with the general specification defined
by a vector showing the position and size of the main facial features, for example, the eyebrows,
nose, mouth, and facial contours(Deeba et al., 2019). In this study, python is used as a
programming language for facial recognition. Python is a powerful high-level, interpreted,
interactive, and object-oriented scripting language created by Guido Van Rossum in late 1980s
(A.L.Sayeth Saabith 1 et al., n.d.). One of the libraries used in this program is OpenCV. OpenCV
is one of the libraries that is often used in computer vision image processing that utilizes an
Application Programming Interface (API) where OpenCV allows the computer to see like humans
with camera. The most useful part of OpenCV may well be its architecture and memory
management. It provides a framework within which it is possible to work with images and videos

2
in any number of ways (“Motion Detection and Face Recognition Using Raspberry Pi, as a part
of, the Internet of Things,” 2019). With Opencv several algorithms can use easily for facial
recognition. One of the algorithms used in this study is LBPH (Local Binary Pattern Histogram)
algorithm. Based on Suma SL LBPH algorithm achieved 85%-95% accuracy(Suma Sl & Sarika
Raga, 2018).
In this study, author develop facial recognition software to find out the accuracy of the
algorithm used in the process with test it to several conditions and faces. This test was carried out
using 5mp Picamera that connected into the CSI camera port in Raspberry 3 model B+. This
facial recognition system used LBPH algorithm method to recognize humans faces. LBP is an
efficient feature for texture classification and combined with histogram it will improve the
detection performance making it powerful and efficient algorithm that can run in Raspberry Pi 3
model B+.

2. METHOD

2.1 Research flowchart


In this research, there are four steps for building facial recognizing system that step is:
face detection, creating dataset, data training, and face recognition. Based on figure 1
the face will be detected by face detection. If the face is detected the next process is to
create a dataset of the face with this dataset, the face can be trained and converted to
the data by training it. Face recognition will match the data that is converted with the
face captured in the video if the face is recognized the program will call the label
name.

3
Figure 1. Facial Recogniton Flowchart

2.2 Tools Preparation

2.2.1 Raspberry Pi

Raspberry Pi is single board circuit(SCB) with the sizes like a credit card.
Although the size is quite mini, the capabilities of this computer are not inferior
to computers in general. Raspberry Pi is able to run office programs, play
music, and videos with high resolution. Raspberry pi is developed in the United
Kingdom by Raspberry Pi Foundation. This research itself is using Raspberry pi
3 model B+ as a CPU with the specification shown below:
 Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz
 1GB LPDDR2 SDRAM
 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac wireless LAN, Bluetooth 4.2,
BLE
 5V/2.5A DC power input

4
Figure 2. Raspberry Pi 3 Model B+

2.2.2 Picamera

Pi Camera module is a camera that can be used to take pictures and high-
definition videos. The Pi Camera module can attach to the Raspberry Pi’s CSI
port using 15-pin ribbon cable. In this project, the camera has 5mp resolution
with up to 1080p video recording.

Figure 3. Picamera

2.3 Work Steps

When the tool is ready in the raspberry pi installed Opencv as a library for facial
recognition. this library is often used in computer vision where Opencv allows the
computer to see like humans with a camera. This library work by acquiring,

5
processing, and analyzing the data so the camera can recognize human's face. After
installing the OpenCV The camera and CV2 library were tested on Raspberry pi by
running the script.

For the next step is implementing face detection with haar cascade classifier
algorithm. Haar cascade classifier is an algorithm that is often used in face detection.
In the OpenCV, the Haar Cascade script is already included in OpenCV data. By
calling haarcascade.xml file to the program the camera will automatically
programmed to detect objects using Haar Cascade algorithm. Haar Cascade can detect
the face in real-time so it can be used in video streaming. Haar-Features are good at
detecting edges and lines. This makes it especially effective in face detection.
However, because Haar Features have to be determined manually, there is a certain
limit to the types of things it can detect. If you give a classifier (a network, or any
algorithm that detects faces) edge and line features, then it will only be able to detect
objects with clear edges and lines. Even as a face detector, if we manipulate the face a
bit like tilting head to the side a Haar-based classifier may not be able to recognize the
face. In this haar cascade it using scalefactor 1.05 and minNeighbors 6 as the
parameters.

When the face is already detected it’s time to create the dataset. To create the
dataset new folder is needed for the data place. By gathering the data from photos of a
test subject in the folder the more data it gets the more accurate facial recognition is. If
the data gathering is complete. Data that already gathered will trained. This process is
important for facial recognition because of camera will try to match our face in camera
with the data. This data is then converted to yml file. When the camera failed to
recognize the face on the camera. This means the data need to be trained again by
scaling the picture, cropping the picture, and converting the picture to grayscale. Train
the data again and again to improve the accuracy and time needed to recognize the
face. In this research the data converted to gray with the command in the trainer. This
is done to make raspberry pi easier to process so it can fasten the process time. In
RGB image it consist 3 dimensional pixel value while on the grayscale a pixel value

6
will be one dimension. To convert the RGB image to grayscale I’m using this
formula :

L = R * 299/1000 + G * 587/1000 + B * 114/1000

L= Gray
R= Red
G= Green
B= Blue

The dataset that is already trained will produce yml file. That yml will be
called in facial recognition script and help the camera to recognize face. For the facial
recognition itself author used Local Binary Patterns Histograms (LBPH) algorithm.
Local Binary Patterns Histograms is simple but efficient algorithm used for
recognizing face. This algorithm work by labeling the pixel of an image by
thresholding the neighborhood of each pixel and considers the result as a binary
number. This pixel then matched with the face on the video that captured with predict
function it enable us to know the labels of the data value based on trained model. In
this study author using default parameters for LBPH algorihm.

Figure 4. LBPHParameters

7
Figure 5. LBPH algorithm flowchart

2.4 Testing and Data Collection


Several datasets are created in order to test several data. This data retrieval is used to
know the ability of LBPH as facial recognition algorithm. This test used the distance
of the data from camera, face position, and lighting in the room.

2.5 Data Analysis


This step is to analyze the data that has been taken at the time of tool testing and data
collection. Data that already collected then analyzed by seeing the result of each test.
This data then made into table to determine the conclusion.

8
3. RESULTS AND DISCUSSION

3.1 System Design


In this system it using Raspberry Pi 3 Model B+ as a cpu. This raspberry pi
connected to Picamera in CSI camera input and displayed in monitor by HDMI cable

3.2 Face Detection


This face detection using haar cascade method as the algorithm for detecting face.
The program writed in pthon with opencv library

Figure 6. Face Detected


Figure 3.1 showing the result of the face detection using haar cascade as algorithm.
When the camera detected face it will show the blue square. In this program I used
sclaefactor 1.5 to reduce at each image scale and minneighbors 5 for specify how
many neighbors each candidate rectangle should have to retain.

3.3 Create and Train Dataset


Created dataset by taking a picture of myself. This data set contains grayscale and
colored photo. Dataset can be seen in figure below

Figure 7. Example of Dataset

9
This dataset then trained with LBPH algorithm with parameter shown in figure 4.
for recognize the face with numpy array.With numpy array the image in dataset will
change to the number inside array. This number contain height width and channel
format. In this study author change the pixel size of the image to gain higher
accuracy.

3.4 Face Recognition

In the test I set the confidence level of the facial recognition is 50%. If the face
recognize and the accuracy above 50% program will print the name of the face above
the square with the help of pickle. By predict the value of image in [y:y+h, x:x+w]
confidence level is shown

Figure 8. Program Testing

Facial recognition test are carried out repeatedly to see the level of accuracy and
the ability to detect face in several distance and lighting. In this table below it show
the result of experiment.

Table 1. Expeiment of Data A in Bright lighting

Face
Distanc Face
Lighting Accuracy Result
e Detection Recognition

Bright
(580 40cm Detected Recognized 70%
lumen)

10
70cm Detected Recognized 77%

Not
100cm Detected
recognized -

Table 2. Experiment of Data A In Dim Lighting

Face
Lightin Distanc
Detectio Face Accuracy Result
g e
n Recognition

Not
40cm Detected 69%
Recognized

Dim
(420 70cm Detected Recognized 68%
lumen)

Not
100cm Detected -
recognized

11
Table 3 Experiment of Data A In Dark Lighting

Face
Distanc
Lighting Detectio Face Accuracy Result
e
n Recognition

Not Not
40cm -
Detected Recognized

Not Not
Dark 70cm -
Detected Recognized

Not Not
100cm -
Detected recognized

In this experiment several other face and position also tested in this figure
below will show the result of the testing:

Figure 9. Several Faces Recognized

12
Figure 10. Recognized More Than One face With Photo

Figure 11. Several Head Position


In figure above face can not be detected. So the facial recognition system
can’t recognize it this happen because haar cascade only detect face with clear edge
and line

4. CLOSING
From the results of the study, it can be concluded that the facial recognition system is
affected by several variables. In this experiment, the greater distance of the face will make
the camera won't recognize the face. On the other hand if the face is too close from the
camera it also reduces the accuracy. In this experiment when the face is around 40cm and

13
70cm the camera can recognize the face but when it's above 100cm the camera already can
not recognize the face of the person. Not only that the lighting of the room also affected the
result if the lighting in the room is too low it will disturb face detection and facial
recognition process. Based on the research even the camera won't detect anything at all in
dark lighting while in dim light camera still recognize but the accuracy is lower. Training
data also affected the accuracy of the facial recognition program. In this study training the
data by resizing the pixel image can improve the accuracy of the camera. Several head
positions also affected the process of face detection when the face is tilted a little haar
cascade can not detect the face because the face line and edge are not clear.
Suggestion for further research, it is better to use more powerful board for the processing unit
so it can detect faster and can run better algorithms. A more powerful board can help improve the
accuracy of the facial recognition system by making a complex program and a lot of dataset..

ACKNOWLEDGEMENT
All praise is to Allah for all His blessings and with that, I was able to accomplish my tasks
in this final project. But the whole process also involved different individuals who advised
me and guided me to reach my goal and these include;
1. Mr. Dedi Ary Prasetya,S.T., M.Eng as my supervisor who provided me with various
suggestions and inputs during the period of making my final project.
2. My friends at The Department of Electrical Engineering at Muhammadiyah University of
Surakarta.
3. My family that helped me to accomplish this study

REFERENCE
A.L.Sayeth Saabith 1, , MMM.Fareez 2, & , T.Vinothraj3. (n.d.). PYTHON CURRENT TREND

APPLICATIONS- AN OVERVIEW. International Journal of Advance Engineering and

Research Development.

Deeba, F., Memon, H., Ali, F., Ahmed, A., & Ghaffar, A. (2019). LBPH-based Enhanced Real-

Time Face Recognition. International Journal of Advanced Computer Science and

Applications, 10(5). https://doi.org/10.14569/IJACSA.2019.0100535

14
Motion Detection and Face Recognition using Raspberry Pi, as a Part of, the Internet of Things.

(2019). Acta Polytechnica Hungarica, 16(3). https://doi.org/10.12700/APH.16.3.2019.3.9

Paul, S., & Acharya, S. (n.d.). A Comparative Study on Facial Recognition Algorithms. 14.

Suma Sl & Sarika Raga. (2018). Real Time Face Recognition of Human Faces by using LBPH and

Viola Jones Algorithm. International Journal of Scientific Research in Computer Science

and Engineering, Vol 6(5).

15

You might also like