Inspiration

I saw many posted videos online, where many customers at stores were being asked to leave unless they wore a mask due to the current COVID-19 pandemic. In my opinion, I think the store workers are working too hard when dealing with many of these customers which is why I thought of an idea that could help with maintaining the number of people that enter a store and how many that wear masks.

What it does

The web camera connected to the raspberry pi would capture photos then check for how many people are wearing masks. It will also display it on a screen. Then, it will save the data from that day and time into a folder with the entry logs of the customers separated by date. These logs can be read in a python file and can be checked on by the staff when needed.

How I built it

I started by trying to make a classifier for masks on my laptop, but I quickly changed to base it off of what facial features are detected. Since I had a Raspberry PI, I thought I could make the camera more portable and also have multiple (because Raspberry PIs are cheaper than laptops). I took some old facial feature classifiers I used in the past that were saved on my laptop, transferred them to the Raspberry PI, and changed the program to check for a nose feature and mouth feature in each face. Then, I made a state for "mask" and "no mask" to draw the bounding boxes with the respective colours and text. After, I added a counter for the number of people wearing masks and the number of people not wearing masks in each frame. Next, I tried making the counters saveable in a "logs" folder with text files separated by date. Finally, I added a new python file to read the files from the "logs" folder from a command line instead of manually going to the folders and looking for a file by date. In total, I believe I have spent around 20-30 hours on this project (I was not actually keeping track of it).

Challenges I ran into

  1. I first tried to make a classifier for masks, but I could not find datasets with everybody wearing masks of different types (because not all masks look the same due to the shortage of surgical masks and I did not want to judge customers that were not able to get surgical masks). Because of this, I changed to detecting masks based on whether the mouth and nose facial features were detected.
  2. I haven't used the raspberry PI in a long time and I was not very experienced with it, so I had some issues connecting the raspberry PI to my computer through PuTTY and VNC Viewer. After a while, I finally got connected to my raspberry PI through my laptop. My project is meant to be based on my laptop, but for my comfort, I decided to do everything on an HDMI display until I finished.
  3. I tried using a PI camera at first and I had no idea how to stream videos and capture multiple frames with it. There were so many different methods (that I tried later on), but each came with different issues that I did not know how to handle which lead me to use a method that works with all cameras (VideoStream).
  4. On the PI camera, I ran into some quality issues (I do not know why, but I think it is because my PI camera is at least a year old and I have not kept it in a safe place). After a long while, I realized I had a USB web camera and decided to switch to that.
  5. I found that the streaming from the raspberry PI was significantly slow (and it was even slower with cascade classifiers running) and tried many other solutions. Yet again, I was still inexperienced with the PI camera and general streaming that I decided to decrease the resolution to increase the speed. ## Accomplishments that I'm proud of Classifying masks on a raspberry PI is the biggest accomplishment I am proud of. ## What I learned I learned how to use the Raspberry PI console and many commands that aren't on Windows, stream videos on a raspberry PI and edit the frames, use a pi camera and webcam, use a touchscreen LCD display, and file manipulation. ## What's next for Face Mask Detection Security Camera In the future, I want to create a GUI for accessing the logs so it is more user friendly. I also want to improve the general aspects such as the camera stream speed and the detection accuracy. Some additional features I would like to add would be a speaker to alert people not wearing a mask to wear a mask before entering the store and a way to notify the staff when somebody without a mask enters the store so they do not have to stand by the door and personally watch for people that are not wearing a mask.

Built With

Share this project:

Updates