Design and Implementation of The Smart Door Lock System With Face Recognition Method Using The Linux Platform Raspberry Pi
Design and Implementation of The Smart Door Lock System With Face Recognition Method Using The Linux Platform Raspberry Pi
1, 2, 3, 4
School of Computer Science,
Nanjing University of Posts and Telecommunications,
Nanjing 210023, China
Abstract - Privacy and Security are two universal rights and, to ensure that in our daily life we are secure, a lot of research
is going on in the field of home security, and IoT is the turning point for the industry, where we connect everyday objects to
share data for our betterment. House security matters and people always try to make life easier at the same time. That’s why
we put up with this project, Face Recognition Door Lock System. Facial recognition is a well-established process in which
the face is detected and identified out of the image. We aim to create a smart door, which secures the gateway on the basis of
who we are. We want to develop this system based on Raspberry-pi 3, to make the house only accessible when your face is
recognized by the recognition algorithms from Open CV library and meanwhile you are allowed in by the house owner, who
could monitor entrance remotely. By doing so, the system is less likely to be deceived: since the owner can check each
visitor in the remote console, getting recognized by the camera using a photo won’t work. I want to add passcode function
for entrance in case that face recognition part corrupts.
1. Introduction
from the user or adding Infra-Red or Bluetooth
n today’s world of connectivity and smart modules to operate these devices.
For face recognition, an image will be captured by a
382
Copyright (c) 2018 International Journal of Computer Science and Network. All Rights Reserved.
IJCSN - International Journal of Computer Science and Network, Volume 7, Issue 6, December 2018
ISSN (Online): 2277-5420
www.IJCSN.org
Impact Factor: 1.5
4.4 SERVO
Figure1:Framework
383
Copyright (c) 2018 International Journal of Computer Science and Network. All Rights Reserved.
IJCSN - International Journal of Computer Science and Network, Volume 7, Issue 6, December 2018
ISSN (Online): 2277-5420
www.IJCSN.org
Impact Factor: 1.5
384
Copyright (c) 2018 International Journal of Computer Science and Network. All Rights Reserved.
IJCSN - International Journal of Computer Science and Network, Volume 7, Issue 6, December 2018
ISSN (Online): 2277-5420
www.IJCSN.org
Impact Factor: 1.5
such as less brightness and contrast problems For better working, each stage of the cascade
and noise in the image and make sure the facial must have a low false negative rate, because if
features always be in a constant position. In this the actual object is classified as a non-object,
project we use histogram equalization for face then the classification of that branch stops, with
preprocessing. For efficiency we use separate no way to correct the mistake made. However,
preprocessing which is histogram equalization each stage can have a relatively high false
for left and right face. So histogram equalization positive rate, because even if the n-th stage
is done three times, firstly for the whole face and classifies the non-object as actually being the
the other two for side faces [6]. object, then this mistake can be fixed in n+1-the
and subsequent stages of the classifier [7].
385
Copyright (c) 2018 International Journal of Computer Science and Network. All Rights Reserved.
IJCSN - International Journal of Computer Science and Network, Volume 7, Issue 6, December 2018
ISSN (Online): 2277-5420
www.IJCSN.org
Impact Factor: 1.5
recognize, please try again’ will appear on the show up when Pi B receives an image. The
screen for 3 seconds before screen return to image will be displayed on its PiTFT screen plus
‘main’ level. Otherwise, the recognized image 2 buttons ‘Yes’ or ‘No’, by pressing which the
will be displayed until remote confirmation is corresponding response will be sent to Pi A.
made. If Pi A receives a positive response from
Pi B, that is, the one is allowed in by the house 6.1.3 Test
owner, the door will be unlocked by the servo Since there are many levels of touch buttons and
and ‘The door is unlocked’ will show up on the we need to display various messages in different
screen. If Pi A receives a negative response from circumstances, we observed pygame window on
Pi B, you will be told that ‘Entrance not allowed the computer monitor and debugged our user
by the house owner’. At last, after 3 seconds, the interfaces layer by layer. We tested the
system will return to its ‘main’ level. sensitivity and reaction time of each touch
When a user presses the ‘Enter Passcode’ button button and experimented with different sleep
on the screen, the text ‘Please enter the time to make sure buttons all work well. Besides
passcode, end with #’ can be seen on the these, we also did some corner tests to see what
touchscreen and the user needs to enter the would happen.
passcode using the 3x4 matrix keypad. Each
pressed number on the keypad will be displayed 7. Face Detection and Haar Cascade
on the screen and then be covered by a star if the Classifier
next key has been pressed. If the passcode
entered is wrong, then we have the PiTFT
After preprocessing, like resizing and cropping,
display a message, ‘Password does not match,
the image will be used as input of Haar Cascade
please try again’, which will last for 3 seconds
Classifier to detect whether there is a single face
before going back to ‘main’ level.
detected in this image.
On the other hand, if the passcode entered is
Face detection is a process of finding out the
correct, the system will get into the second-level
face area in the image. In the project, we use
buttons: ‘Unlock’, ‘Reset Passcode’ and
Haar Cascade to detect faces. Haar-like features
‘Return’. Users could unlock the door by
such as edge features, line features, and center-
pressing ‘Unlock’ button and the servo will be
surround features are used and they are inputs of
driven to open the door. The password could be
classifiers. Cascade classifiers test the image by
reset by pressing the ‘Reset Passcode’ button.
cascade features. Since the amount of features is
The new passcode needs to be entered through
large, instead of applying all features on the
the keyboard too and will take effect next time.
window, the features are divided into different
The ‘Return’ button is designed to return to the
stages. The window will be tested stage by stage
previous level. For security reason, we set the
and initial stages usually have less haar-like
upper limit for times of entering the wrong
features. If the window fails in a stage, it will be
passcode. If the upper constraint is reached, the
discarded and the following stages won’t be
whole system will be locked for a certain
tested. The window which successfully passes
amount of time, such as 15 minutes and screen
all the stages is considered to be face image.
will tell the user that ‘Maximum failed passcode
Haar cascade classifiers has an advantage of its
attempts in restriction. Please try again after 5
fast detection speed compared to other
minutes.
classifiers.
6.1.2 Rasp Pi B
7.1 Test
386
Copyright (c) 2018 International Journal of Computer Science and Network. All Rights Reserved.
IJCSN - International Journal of Computer Science and Network, Volume 7, Issue 6, December 2018
ISSN (Online): 2277-5420
www.IJCSN.org
Impact Factor: 1.5
will try to recognize the cropped face and return special function. We changed the connection to
the confidence of its prediction at the same time. GPIO 21 and the problem was solved.
By setting a threshold for the predicting
confidence, we can determine when to 10. Communication over TCP Sockets
acknowledge that the face is truly recognized.
Face recognition is matching the input signal The two Raspberry is in the project are set to
with the pre-stored library. Though the input communicate using TCP sockets via wifi
signal is noisy due to the different angle, modular and a wifi router. The Raspberry Pi A,
position and intensity of light, the image could which displays main buttons, is the client and the
be recognized according to the position of eyes, other Raspberry Pi B, for remote confirmation, is
face, and mouth in the face, and their relative the server. With specific IP addresses, the client
distances between each other. These features are could connect to the server and send files like
called eigenfaces and they could be extracted images over TCP socket. Then the server will
from original image data by principal component send a response back to the client and once the
analysis. Each face is represented by a subset of response received, the client is going to close the
eigenfaces and the face could be reconstructed if connection. We developed a python script code
eigenface could be correctly calculated for each for the above communication routine by
proportion. The new image will be recognized leveraging python library ‘socket’. See details in
based upon eigenvectors and the Euclidean ‘server.py’ and ‘client.py’ & ‘client2.py’.
distance between eigenvectors.
10.1 Test
8.1 Test
When we started this communication part, there
We tested the eigenface classifier with different were 2 choices when deciding which Pi worked
confidence threshold to get the best recognition as a server or client. We tested on both 2
accuracy. After the system could recognize one methods and found that Pi B needs to wait for
face successfully, we also considered making the images sent by Pi A at any time, so it’d better be
system recognize multiple faces by setting up a server. By doing so, whenever Pi A, the client,
several classifiers and let them do recognition is trying to send an image to PiB, it could be
work in turns or in multi-thread way. As a result, connected to Pi B successfully since the server
due to the limited time, we continued on the keeps on all the time.
former choice which is simpler than multi-
thread. 11. Conclusion
9. Passcode Implementation We successfully finished a face recognition door
lock system as we planned. The passcode and
In the implementation of the keypad, the face recognition works well. There is high
approach for deciding the pressed button is accuracy in recognizing house owner faces and it
firstly setting outputs (column pins) and inputs could realize sending the matched face image to
(row pins) as high. When a button is pressed, it another Raspberry Pi in time and give a good
will produce a low signal. Then each column is output. And it takes a little bit time to recognize.
scanned in a ‘for’ loop. If the low signal is At all, we all are satisfied to build it.
detected, we could know which button is
pressed. See details in ‘passcode.py’ in code Acknowledgement
appendix. First of all, we are thankful to all our team
members for working hard around two months
9.1 Test on this project and gave their great approach on
it. At beginning of this project we were in
In the test of passcode function, the system trouble for starting it with the appropriate way.
worked well on the monitor screen at the We all were confused from where can start, at
beginning. But in the condition that all buttons that fortunately we got an opportunity to discuss
and layers were displayed on the PiTFT screen, this matter to our honorable lecturer Professor
the PiTFT screen would display sliding messy Xu he who was representing about a project
codes when we entered the password ending related to IoT. By getting that chance we told
with ‘#’. The TA helped us debugging and told him at once about our problem. Then he gave the
us the problem was caused by wrong circuit suggestion and guided us for the correct way.
connection. We checked our circuit and found Whenever we faced difficulty to work on it then
the reason is that we attached one of the keypad we never felt hesitate to go through him and
interface pins to GPIO 25 which is used for every time he made our work to overcome all the
387
Copyright (c) 2018 International Journal of Computer Science and Network. All Rights Reserved.
IJCSN - International Journal of Computer Science and Network, Volume 7, Issue 6, December 2018
ISSN (Online): 2277-5420
www.IJCSN.org
Impact Factor: 1.5
difficulty. So we all give him a great credit and [4] W. F. Abaya, J. Basa, M. Sy, A. C. Abad and E.
thanks as well. Finally, we are also delighted to P. Dadios, "Low cost smart security camera
complete this project as our demands eventually with night vision capability using Raspberry Pi
outweigh any negative challenges. and OpenCV," 2014 International Conference
on Humanoid, Nanotechnology, Information
gave the suggestion and guided us for the correct Technology, Communication and Control,
way. Whenever we faced difficulty to work on it Environment and Management (HNICEM),
then we never felt hesitate to go through him and Palawan, 2014, pp. 1-6
every time he made our work to overcome all the [5] Priya Pasumarti1, P. Purna Sekhar “Classroom
difficulty. So we all give him a great credit and Attendance Using Face Detection and
thanks as well. Finally, we are also delighted to Raspberry-Pi” International Research journal of
complete this project as our demands eventually Engineering and Technology (IRJET), Volume:
outweigh any negative challenges. 05 Issue: 03. p3-p5,Mar-2018
[6] S Rajkumar, J Prakash, “Automated attendance
using Raspberry pi”, International Journal Of
References Pharmacy & Technology (IJPT), Vol. 8, No. 3,
pp. 16214-16221, September 2016.
[1] Jie-Ci Yang et. all An Intelligent Automated [7] T. M. Inc., “Train a Cascade Object Detector,”
Door Control System Based on a Smart [Online]. Available:
Camera. http://www.mathworks.se/help/vision/ug/train-
[2] S. Nazeem Basha et all An Intelligent Door a-cascadeobject-d
system using Raspberry pi and Amazon Web
services IOT.
[3] Richard Grimmett, Raspberry Pi Robotic
Projects. Packt Publishing.
388
Copyright (c) 2018 International Journal of Computer Science and Network. All Rights Reserved.