BASICS
At the beginning of the program, the needed libraries and tools are imported, the camera is set up, and the location of the directories that will be used is given.
MAIN LOOP
In this section, the program continually checks every frame in real time to see whether there is a person in the frame or not. Based on that result, it would classify the person. One way is that the person's image is in the database of known people, so it can identify the person and display their name on the screen. If the person is not in the known people database, the program names the person as unknown, and saves an image into a folder for later identification along with the number of times that person has visited. Each time that unknown person appears in front of the camera, the image is resaved with the most recent frame, and the appearance is counted as a new visit. The final way the person may be identified is as masked. If the person is wearing a mask, their image is saved into a separate folder along with a list of people from the known database that the masked individual most closely resembles.
MACHINE LEARNING
There are other pieces of code used to make this program work. One very important part is the Convolutional Neural Network. The model is what is used to determine if someone is wearing a mask or not. To make the model work, the program starts off with the code that creates a CSV file. This file is created using a folder of images with masked and unmasked individuals. The program reads images, and based on the image name, labels it as a masked or unmasked individual. Using the CSV file, a dataset and a data loader is created. The data loader is then inputted in the Convolutional Neural Network. All of this teaches and trains the model to determine whether a person is wearing a mask or not. This model is what enables the program to identify that a person is masked in the main loop so that the image is saved properly.
CITATIONS
Doorbell Camera
Geitgey, A. (2020, October 5). Build a face recognition system for $60 with the new Nvidia Jetson Nano 2GB and Python. Medium. https://medium.com/@ageitgey/build-a-face-recognition-system-for-60-with-the-new-nvidia-jetson-nano-2gb-and-python-46edbddd7264
​
Facial Recognition
Face-recognition. (2020, February 20). PyPI. https://pypi.org/project/face-recognition/
​
Github Dataset
Cabani/maskedface-net: Maskedface-net is a dataset of human faces with a correctly and incorrectly worn mask based on the dataset flickr-faces-HQ (FFHQ). (2021, April 28). GitHub. https://github.com/cabani/MaskedFace-Net
​
CNN in PyTorch
Pahinkar, A. (2020, August 25). Implementing CNN in PyTorch with custom dataset and transfer learning. Medium. https://medium.com/analytics-vidhya/implementing-cnn-in-pytorch-with-custom-dataset-and-transfer-learning-1864daac14cc
​
PyTorch
Training a classifier — PyTorch tutorials 1.9.0+cu102 documentation. (2021). PyTorch. https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html