Face Mask Detection Based Door Lock System.
For building face mask based door system, I used machine learning model using Keras, Tensorflow library in python language. After building model I used OpenCV to detect whether a person is wearing a mask or not in real time. This system contains mainly four devices. They are: servo, camera(webcam), buzzer, LCD and Arduino Uno. I used arduino Uno to control servo, camera, LCD and buzzer. If someone appears in front of the entrance wearing a mask properly, covering both their mouth and nose, then they will be let in. At the same time my display will show “Mask Detected”. But if someone appears without a mask then they will be denied entry, at the same time the system would display “Please wear mask” while the buzzer would alarm the person. This versatile system could be used with variety of entrances with different locking system. the image of demo working project is given below:
You have to run 'train_mask_detector.py' file in spyder or Jupyter Notebook to create a model named 'mask_detector.model' or you can use my previous trained model which I have provided in GitHub. For training 'train_mask_detector.py' file you need a dataset having two folders: 1. withMask 2. Withoutmask. I also provided the dataset in GitHub.
You have to run ‘myDetect.py’ file in spyder. For running this file you need 'res10_300x300_ssd_iter_140000.caffemodel', 'deploy.prototxt' and 'mask_detector.model' file which I have provided in the Github and you must connect your webcam with your PC but if you are using Laptop then you don't need any webcam. If you run everything successfully then your camera will be opened and you can test if it works with the mask or not.
Finally, you will add Serial Command to the facemask detection algorithm that will order the Arduino to send commands to the servo, buzzer, and LCD based on the state of detection. I have commented on the Arduino code in the myDetect.py file. If you want to use Arduino then first, you have to run and compile 'msdCode.ino' file on the Arduino board using Arduino Software. Next, you have to connect your Arduino with your pc or laptop using a USB cable and then you have to comment out the Arduino code from 'myDetect.py' file and run the file.
Remember you have to connect your Arduino with LCD, servo, and buzzer before running the code. the connection is given below:
Python and Arduino.
tensorflow, keras, imutils, cv2, numpy, time, os, serial
Arduino Uno, servo, buzzer, LCD, webcam.
Spyder, Arduino Software.