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.


Vincent Z.

Area of Interest

Artificial Intelligence, Facial Recognition


Monta Vista High School


Incoming Senior

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.

Second Milestone

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.

First Milestone

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.


During Project Selection, I had actually picked my main project before my starter project. After seeing so many cool main projects, I felt a little bit underwhelmed looking at the starter projects. However, I quickly realized that I had no idea what soldering was among other skills, so I chose the MintyBoost starter project, which seemed to be simple and straightforward. Additionally, I found it to be one of the most practical starter projects: portable batteries specialized for recharging phones are common and useful. I’m glad I did, as it made for a valuable learning experience. I learned not just physical skills such as soldering and using the dremel but also the importance of planning ahead. Additionally, I learned more about circuit design and the inner workings of components such as inductors and microcontrollers. One of the largest struggles I faced was learning how to solder. My hands were incredibly shaky and when I messed up I found desoldering to be another big challenge, as the pins on the circuit board were really close to each other.


  • https://www.pyimagesearch.com/2018/06/25/raspberry-pi-face-recognition/

STEM Summer Camps Coding & Robotics Classes For Kids San Francisco Coding & Robotics Classes For Kids New York Coding & Robotics Classes For Kids Denver Coding & Robotics Classes For Kids Palo Alto STEM Summer Camps For Kids in New York STEM Summer Camps For Kids in Palo Alto STEM Summer Camps For Kids San Francisco STEM Classes For Kids in New York STEM Classes For Kids in Palo Alto STEM Classes For Kids in San Francisco Code Classes For Kids Code Classes For Kids in New York Code Classes For Kids in Palo Alto Code Classes For Kids in San Francisco STEM Summer Camps For Kids

Leave a Comment

Start typing and press Enter to search