Facial Recognition Door Lock
A door lock that uses facial recognition to allow authorized users to lock and unlock it. The facial recognition is regulated by a Raspberry Pi, which also controls the lock function. Additionally, the lock can be remotely controlled with the use of an application.
Area of Interest
Artificial Intelligence, Facial Recognition
Monta Vista High School
Design and Code
Third and Final Milestone
For my final milestone, I added the finishing touches to my door lock system. I used a paper clip to connect the servo to the door lock, and used duct tape to fill in the grooves in the door lock so that the pin would not get stuck. When the servo spins, the torque on the servo is converted into force applied on the door lock’s pin through the paper clip, which pushes or pulls it from one end to the other. I placed all my parts on a cardboard sheet, which I punched a flap into to represent a door.
One particular issue I ran into was optimization. I had to add delay to the program to ensure the servo did not twitch too much, but could not add a delay so large as to make the program almost unresponsive. Another roadblock I had to overcome was mistyping the ‘and’ operator for python. I believed it was the ampersand instead of the literal keyword ‘and’, and because using an ampersand did not create a compiler error, it took me a long time to discover and fix.
Next, for a potential modification to my project, I want to create an application that will allow me to manually lock and unlock the door lock remotely. Additionally, I’ll work on adding features such as viewing a log of when the door was accessed or adding new users.
For the second part of my project, I worked with the facial recognition component of my project. First, I installed the vital libraries I would need to create the facial recognition program. I used OpenCV, face_recognition, and many other libraries to create a program that turns a servo when it detects my face. After creating the frame and initializing helper variables, the program runs a loop that continuously takes in input from the camera and checks it for faces. If it detects a face, it draws a box around the area where the face is detected. If the face is in the library, it will also display the name; otherwise, the face will be labeled as “Unknown”.
One of the drawbacks I still face is that the program seems to struggle in detecting faces that are not upright, possibly a result of the cascades. It also greatly struggles if the photos in the database do not have a similar resolution/coloring to that of the live camera feed. Finally, the program has low framerate when provided too many photos, because it has to check many more photos per frame.
One of my primary struggles while creating this program was installation of all the software I needed. Much of the information I found while researching on the internet was either outdated or not suited to my specifications, making debugging difficult. In the end, I discovered that reviewing the documentation was the best course of action, as it is the most reliable place to find up-to-date information.
Next, I’m going to be connecting the servo to the door lock to finish the door locking mechanism.
For my first milestone, I made sure the hardware I would use with my project was functioning. First, I set up my Raspberry Pi, which would control input from the camera and control the servo, which would lock/unlock the door lock. The Raspberry Pi is relatively powerful for its size, but I still verified that the Raspberry Pi had the capability to perform real-time facial recognition; previous projects with facial recognition and a Raspberry Pi proved that this was indeed possible. Next, I downloaded Raspbian and mounted the image onto an SD card using my personal computer, and installed it on the Raspberry Pi. After consulting a manual for the Raspberry Pi, I hooked the servo up to the pins. With the Raspberry Pi set up, I created a simple program with python and RPi.GPIO to move the servo 90 degrees one way and back. Next, I installed the Raspberry Pi camera module in the camera slot. I created another simple program with python to test the camera; the program displayed a video feed for ten seconds so I could check its orientation.
One of the hurdles I encountered while doing this was learning about duty cycles. My servo had different specifications from many of those I found online, so I used the datasheet for the servo and trial and error to determine what numbers to use to move the servo 90 degrees.
Next, I’m going to work with combining two servos for the locking and unlocking mechanism and printing parts for my lock.