Professional Documents
Culture Documents
HOCHIMINH CITY
INTERNATIONAL UNIVERSITY
SCHOOL OF ELECTRICAL ENGINEERING
BY
GROUP 1 – KLÚTA
ii
Developing AI Based Automatic Door to
Detect Mask & Measure Temperature
BY
GROUP 1 – KLÚTA
Under the guidance and approval of the committee, and approved by its members, this
thesis has been accepted in partial fulfillment of the requirements for the degree.
Approved:
________________________________
Chairperson
_______________________________
Committee member
________________________________
Committee member
________________________________
Committee member
________________________________
Committee member
i
HONESTY DECLARATION
My name is ______________ (full name). I would like to declare that, apart from
the acknowledged references, this thesis either does not use language, ideas, or other
original material from anyone; or has not been previously submitted to any other
educational and research programs or institutions. I fully understand that any writings in
this thesis contradicted to the above statement will automatically lead to the rejection
Hochiminh City.
Date:
Student’s Signature
(Full name)
ii
TURNITIN DECLARATION
Name of Student:
Date:
iii
ACKNOWLEGMENT
guidance of Dr. Nguyen Van B. His constant encouragement and support helped me to
achieve my goal.
………………………
iv
TABLE OF CONTENTS
HONESTY DECLARATION.............................................................................................ii
TURNITIN DECLARATION............................................................................................iii
ACKNOWLEGMENT.......................................................................................................iv
TABLE OF CONTENTS....................................................................................................v
LIST OF TABLES............................................................................................................vii
LIST OF FIGURES..........................................................................................................viii
ABSTRACT........................................................................................................................x
CHAPTER I INTRODUCTION.........................................................................................1
CHAPTER II DESIGN SPECIFICATIONS AND STANDARDS...................................4
2.1. Hardware specification............................................................................................4
2.2. Software specification..............................................................................................4
CHAPTER III PROJECT MANAGEMENT......................................................................5
3.1. Budget and Cost Management Plan.........................................................................5
3.2. Project Schedule.......................................................................................................5
3.3. Resource Planning....................................................................................................6
CHAPTER IV LITERATURE REVIEW............................................................................7
4.1. COVID-19: Face Mask Detector with OpenCV, Keraas/TensorFlow, and Deep
Learning..........................................................................................................................7
4.1.1. Creating dataset................................................................................................8
4.1.2. Training Face Mask Classifier with Keras and TensorFlow............................8
4.1.3. Applying Face Mask Classifier to image with OpenCV..................................9
4.1.4. Applying Face Mask Classifier to real time video with OpenCV..................10
4.2. TouchFree: Automated Temperature Checkup and Mask Detection.....................11
4.3. Automatic Door Opener using Arduino and PIR Sensor.......................................14
CHAPTER V METHODOLOGY.....................................................................................16
5.1. Overview................................................................................................................16
5.2. Objectives...............................................................................................................17
5.2.1. Hardware Setup..............................................................................................17
5.2.2. Constructing Mask Detection Program..........................................................21
5.2.3. Constructing Temperature Checkup Program................................................23
5.2.4. Constructing Auto-Operating Door................................................................24
5.2.5. Integration and Test........................................................................................24
v
CHAPTER VI EXPECTED RESULTS............................................................................27
CHAPTER VII CONCLUSION AND FUTURE WORK................................................28
REFERENCES..................................................................................................................29
APPENDICES...................................................................................................................30
vi
LIST OF TABLES
Table 2.1: Component list....................................................................................................4
Table 2.2: Software list........................................................................................................4
Table 3.1: Component Price................................................................................................5
vii
LIST OF FIGURES
Figure 1.1: Thermal checkup using thermometer................................................................1
Figure 1.2: System Illustration............................................................................................2
Figure 3.1: Gantt Chart........................................................................................................6
Figure 4.1: Phases and individual steps for building a COVID-19 face mask detector......7
Figure 4.2: Original/artificial face mask applied image......................................................8
Figure 4.3: Coronavirus face mask......................................................................................8
Figure 4.4: COVID-19 face mask detector training accuracy.............................................9
Figure 4.5: Not wearing mask result..................................................................................10
Figure 4.6: Mask Detection by Deep Neural Network......................................................11
Figure 4.7: Find the best Spot on the Forehead using DLIB Module................................12
Figure 4.8: Temperature Reading using Contactless IR Temperature Sensor...................12
Figure 4.9: High temperature warning test........................................................................13
Figure 4.10: Email Based Alert.........................................................................................14
Figure 4.11: Automatic door system-based Arduino.........................................................15
Figure 4.12: Circuit Diagram for the system.....................................................................15
Figure 5.1: System Overview............................................................................................16
Figure 5.2: Raspberry setup...............................................................................................17
Figure 5.3: Hardware schematic for PID system...............................................................20
Figure 5.4: Localizing face in image.................................................................................21
Figure 5.5: Detecting ROI.................................................................................................21
Figure 5.6: Display result..................................................................................................22
Figure 5.7: PID system result............................................................................................23
Figure 5.8: Measuring temperature process.......................................................................23
Figure 5.9: Door operating condition................................................................................24
Figure 5.10: Test the mask detection program..................................................................25
Figure 5.11: Test the temperature checkup program.........................................................25
Figure 5.12: Expectation results from testing....................................................................26
viii
ABBREVIATIONS AND NOTATIONS
ix
ABSTRACT
Under the threat from unpredictable evolving of COVID-19 variants, the need to improve
the pandemic prevention method is crucial. Currently, social distancing policy has shown
majority of the temperature checking methods used in Vietnam are done manually by
security staffs, which is against the mentioned policy and may indirectly gain the chance
automatic entrance kiosk – a door that automate the temperature checking process as well
as mask detection at crowd places without the interference from human. In this project,
Facial Landmark is used in automatic temperature checkup process and Deep Learning
Neural Network is used in mask detection process. The door will, then, operate based on
data collected from temperature checkup and mask detection process. About application,
our project can be practically installed at public places such as school, hospital, airport,
etc.
x
xi
CHAPTER I
INTRODUCTION
Until now, there is no exact treatment for COVID-19 virus. Thus, outbreak of the pandemic can
result in city or even national lockdown, which causes huge damage to the economics of the
world. So far, to prevent the spread of the pandemic people need to follow social distancing
policy from the governments. Nevertheless, majority of public places in our country use infrared
thermometer to check the temperature of entering people (illustrated in Figure 1.1). This method
requires human to operate, which may indirectly cause spreading of the pandemic. Thus, there
will be needed certain automatic system to improve the efficiency of this process by replacing
the human workforce.
Symptoms of COVID-19 including fever. We believe that implementing AI into our system, we
can easily measure temperature without interference from human. Furthermore, there are a lot of
research on developing mask-wearing detection program using machine learning out there. Thus,
1
we would like to integrate the two mentioned AI programs into our system to construct an
automatic door that can be able to measure temperature and detect temperature of passing
people.
This project proposes an automatic door – based AI, which illustrated by Figure 1.2. This
system aims to set up in social places such as mall, hospital, supermarket, school, etc. People
come and the system will detect mask and temperature. First, when people come to the door, the
system will detect people wearing the mask or not by applying trained AI. The system will have
a screen which will warning people if they do not wear mask. This is described in the number (1)
in Figure 1.2. Next, if people are wearing mask, they have to pull the mask down to show their
full face. The system will use Facial Landmark to detect the forehead on the face, then using a
temperature sensor to measure the temperature (described as (2) in Figure 1.2) and show the data
on the screen (described as (3) in Figure 1.2). The model of the door is a bar connecting to servo
motor. The automatic door will open if both condition in (1) & (2) are met. In general, the goal
of the project is to develop an AI based door to detect mask and measure temperature. To archive
the goal, the following objectives should be completed.
2
2.2. Training AI with created data
3
CHAPTER II
In this chapter, we will discuss about the specifications of our project. There are two sections, we
will mention about hardware specifications in section 2.1 and software specifications in section
2.2.
4
CHAPTER III
PROJECT MANAGEMENT
In this chapter, we will discuss about the price of the components as well as the task assignment
in this project in three sections.
Components Prices
Combo Raspberry Pi 4 Model B 2.065.000
Raspberry Pi Camera Module 650.000
Non-contact Infrared Temperature Sensor Module (MLX90614) 180.000
Pan Tilt Kit 282.000
SG90 Micro-servo motor 35.000
Raspberry Pi Touch Display 1.400.000
Premium Female/ Female Extension jumper wires, 40 x 6” (150) 33.000
Total 4.645.000
5
Figure 3.3: Gantt Chart
6
CHAPTER IV
LITERATURE REVIEW
In this chapter, we discuss about three reference articles (in section 4.1, 4.2, and 4.3) that have
solutions we would like to base on building our project.
4.1. COVID-19: Face Mask Detector with OpenCV, Keraas/TensorFlow, and Deep
Learning
In studying for mask detection program, an article [CITATION Adr20 \l 1033 ] posted by Ardian
Rosebrock clearly demonstrates the process of developing mask detection program. Being
generalized by Figure 4.1, the article discusses two phases in programming mask detector
program. In the first phase or training phase, dataset is reviewed to train custom face mask
detector. Then, the training process begin using Keras and TensorFlow. In the second phase or
Figure 4.4: Phases and individual steps for building a COVID-19 face mask detector
7
deployment phase, the author, first, create a script to detect face in image and resize the image
such that the face is clearly appear in the frame. Then, the program will apply face mask
classifier to the resized frame to analyze the face and show result
In this article, 1376 images of people not wearing mask used to create dataset. The dataset
included two classes with_mask (690 images) and without_mask (680 images). To create
with_mask set, Facial Landmark is used to extract the face and apply a mask image (as shown in
Figure 4.3). This process yields the result as shown in Figure 4.2.
8
Figure 4.5: Coronavirus face mask
9
Figure 4.7: COVID-19 face mask detector training accuracy
Figure 4.4 shows the test set result in the article with accuracy ~99%. Additionally, there are
little signs of overfitting, with the validation loss lower than the training loss. Thus, the classifier
is expected to generalize well to images outside of the training and testing set.
This step can be generalized as following. First, the input image is loaded from disk. Then,
the program will detect faces in the image and eventually, apply the face mask detector to
classify the face as either with_mask or without_mask. Figure 4.5 below shows result to no
mask wearing image after applying the classifier.
10
Figure 4.8: Not wearing mask result
4.1.4. Applying Face Mask Classifier to real time video with OpenCV
With similar approach to the program mentioned in section 4.1.2, the author suggests looping
over frame in the video. In every frame of the video, the program will extract Region of Interest
(ROI) of face and apply face mask classifier to that ROI to get result.
After studying the article, we recognize that the face mask classifier in real time streaming video
mentioned in section 4.1.4 is the solution to our mask detection program. Thus, we will construct
our mask detection program based on the mentioned section. We also follow the reference in
section 4.1.1 and 4.1.2 to create data set and train the face mask classifier.
11
4.2. TouchFree: Automated Temperature Checkup and Mask Detection
Moving on to the last article [CITATION Sak20 \l 1033 ], the kiosk of Saksham Bhutani
operates by first trying to detect mask on the passing person as shown in Figure 4.6. Then, after
recognizing mask on, the system will ask the person to remove mask, so that the temperature
checking program can work properly.
The protocol he used to connect and control the sensor through raspberry pi is the I2C protocol.
The
Once, the System has detected the Mask it asks the user to remove the mask so that it
can perform Facial Landmarking. The System is using DLIB Module for Facial
Landmarking to find the best Spot on the Forehead of the person to take Temperature
from. (Figure 4.7)
12
Figure 4.10: Find the best Spot on the Forehead using DLIB Module
Then by using PID Control System with Servo Motors, the system tries to align the Selected
Spot on the Forehead with the Sensor. Once aligned the system takes Temperature Reading using
Contactless IR Temperature Sensor (Figure 4.8)
13
When the temperature too high, it will alarm and not allow the person with high temperature to
enter (Figure 4.9)
The temperature checking program used Facial Landmark & PID control system to find the
forehead of people. When operating, the kiosk will use constantly finding the preset facial
landmark spots that represent the forehead by PID control system and try to align the infrared
sensor to those spots. Thus, the temperature can be accurately measured. Each time, when there
are people passing through the kiosk, the system will send an alert mail to the administrator as
shown in Figure 4.10.
14
Figure 4.13: Email Based Alert
After analyzing article[ CITATION Sak20 \l 1033 ], we recognize the temperature checkup
program used in the article has similar purposed to ours. Thus, we will construct our mask
detection program based on the solution in section 4.2 to develop the PID system to search for
the forehead and measure the temperature.
15
Figure 4.14: Automatic door system-based Arduino
In this article, PIR Motion Detector Sensor is used to detect motion of people. If the sensor
detected a person, the door will open for a while and automatically close after that. They also use
the L298N Motor Driver Module to control the 5V driving motor of the door.
Referring to Figure 4.12, we can interpret the mechanism of the system as following. First, when
there are people approaching the door, the PIR sensor will send a HIGH signal to pin 8 of the
Arduino. The Arduino will then send a signal via port 2 & 3 to the L298N to control the motion
of the motor to drive the door.
Since our project need to be affordable in testing process, we decide to follow the simple
automatic door system project to minimize the cost. The article mentioned above meets our
desire. Thus, we will construct our automatic door system with a model as mentioned above.
16
CHAPTER V
METHODOLOGY
In this chapter, we will first describe generally our system in section 5.1. Then we will discuss in
detail how each objective gets done to build up the complete system in section 5.2
5.1. Overview
Figure 5.1 shows the system overview of our project. There are three main blocks in the system,
which are the mask detection block, the temperature checkup block, and the automatic door
block. In operation, our system will start with the mask detection block, the mask detection
program will load pre-trained face mask classifier from disk, then it will extract the face in video
stream and apply the classifier to check for mask-wearing. Once mask is detected, the system
17
temperature using contactless IR temperature sensor. Finally, the automatic door, which is
modeled by a DC servo, will open when both conditions are met from the previous programs.
5.2. Objectives
In other to build the properly working system as described in section 5.1, we need to complete
the following objectives
18
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system
needs more memory resources and the RAM is full, inactive pages in memory are moved to the
swap space. While swap space can help machines with a small amount of RAM, it should not be
considered a replacement for more RAM. Swap space is located on hard drives, which have a
slower access time than physical memory.
Command lines from 11 to 18 are for installing important dependencies for the OpenCV
line 19 $ sudo apt-get install python3-opencv
Command line from 20 to 30 are for installing the tensor flow module and libraries.
Installing DLIB module:
line 32 $ pip3 install dlib
19
line 33 $ python3
line 34 >>> import dlib
line 35 >>> exit()
Command line 33 to 34 are for checking the DLIB module has already in the python
environment.
Now we will change Swap Size and Memory back
line 36 $ sudo nano /etc/dphys-swapfile
Command line 36 is for changing back the swap size and memory by navigating to the swap file
and then from CONF_SAWPSIZE=1024 we change to CONF_SWAPSIZE=100
Now, with the system ready, we will create a folder name caps_gr1_proj to store the code of this
project
line 40 $ mkdir caps_gr1_proj
line 41 $ cd caps_gr1_proj
Command line from 40 to 41 are for creating a new folder and storing the programming code of
the systems.
5.2.1.2. Set up the sensor
In this project, we will be using the MLX90614 sensor which is shown in Figure 5.3 (Contact IR
Temperature Sensor) and the protocol to connect this to the Raspberry is I2C protocol.
I2C communication is a feature that allows multiple slaves connect to a single master and you
can have multiple master controlling multiple single, or multiple slaves. I2C only uses two wires
to transmit data between devices: SDA (Serial Data) for transmitting data and SCL (Serial
Clock) for carrying the clock signal. I2C has a way to communicate to the slave device is
addressing them. The master sends the address of the slave it wants to communicate with to
every slave connected to it. Each slave compared the address sent from the master to its own
address. If the address matches, it sends a low voltage ACK bit back to the master. If the address
doesn’t match, the slave does nothing, and the SDA line remains high.
After connecting the sensor to the Raspberry Pi, we set up the protocol
line 42 $ sudo su -c 'echo "Y" > /sys/module/i2c_bcm2708/parameters/combined'
line 43 $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- 5a -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
20
Command line 42 and 43 are for calling out the address of the port that the sensors connect to.
Here, we have the port address connecting to the sensor is 0x5A.
5.2.1.3. Set up the hardware for PID system & the automatic door
We connect the servos X and Y as shown in Figure 5.3. Those servos will take the role to
adjust the angle for the PID system (X moves in horizontal direction while Y moves in
vertical direction). We also connect a third servo Z to model our automatic barrier gate
(see section 5.2.4).
21
5.2.2. Constructing Mask Detection Program
Based on section 4.1, before constructing the mask detection program, we first create the
dataset and trained the mask detection classifier.
Facial landmark is a method allows us to automatically infer the location of facial structures,
including eyes, eyebrow, nose, mouth, and jawline. There are lots of applications of this method
such as: face alignment, head pose estimation, face swapping, blink detection and much more.
Detecting Facial Landmark has two step processes:
Step 2: Detect the key facial structures on the face ROI (Region of Interest).
22
After detecting ROI in each image (as shown in Figure 5.5), we spilt the set into two. 500 images
for with_mask data and 500 images for without_mask data. For without_mask data set, Facial
Landmark is applied again to attach a mask image for human face, just as mentioned in section
4.1.1.
23
5.2.3. Constructing Temperature Checkup Program
Based on section 4.2, we will build the program to achieve the following task:
24
5.2.4. Constructing Auto-Operating Door
In this objective we will construct the door and then develop a program to automatic the door
based on the result form section 5.2.2 & 5.2.3
and temperature checkup program executed, they will return two conditions. If those
condition are met, the door will open.
25
Figure 5.25: Test the mask detection program
Then we will apply the model with a camera to test the real time and continuum face mask
detection of the system.
26
Then, we check the temperature checkup program without the pan and tilt module to see it
could take the temperature from a person by aligning their head to match the forehead spot
with the temperature spot on the display screen.
Finally, we test the completed temperature checkup program with the pan and tilt module to
see it could take the temperature of a person by self-alignment to match the temperature spot
with the forehead spot.
Both expected result of the last 2 tests should be like this figure 5.12:
Secondly, we want to test the door operate well when there is one of the conditions are
met.For instance, the door will not open if the temperature is accepted but there is no mask
detected and vice versa.
Finally, we test the door to see it operate well when two conditions are met, the door must
open when the temperature is accepted, and the mask is detected.
After testing each small program, we will test again the whole system. Finally, we adjust,
fix, and complete the product.
27
CHAPTER VI
EXPECTED RESULTS
28
CHAPTER VII
29
REFERENCES
[1] A. Rosebrock, "covid-19-face-mask-detector-with-opencv-keras-tensorflow-and-deep-
learning," pyimagesearch, 4 May 2020. [Online].
[2] S. Mark , H. Andrew, Z. Menglong, Z. Audrey and C. Liang-Chieh, "MobileNetV2:
Inverted Residuals and Linear Bottlenecks," 21 Mar 2019. [Online].
z[3] S. Bhutani, "Touchfree automated temperature checkup and mask detection," hackster, 19
June 2020. [Online].
[4] Don Hun, "Automatic Door Opener using Arduino and PIR Sensor," electronichubs, 23
January 2018. [Online].
30
APPENDICES
31