First of all, let’s gather the components required for the project.
Bill Of Material
I hope you already have the Raspberry Pi board ready with the latest Raspbian OS so that we can install the required modules and libraries. Open the Linux terminal and the install the following libraries
Or you can use the following command to install the library:
sudo pip install library name
sudo apt-get update
sudo apt-get upgrade
sudo nano /etc/dphys-swapfile
Then change the line CONF_SWAPSIZE=100 to CONF_SWAPSIZE=1024
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start
sudo pip3 install opencv
sudo pip3 install numpy
pip3 install dlib
pip3 install face-recognition
Next, we install the gpiozero, espeak and ultrasonic libraries.
After that, we can now start our coding.
Coding for Home Quarantine Using Face Recognition
First, create a new project folder and copy into it the images of family members who are allowed to enter the house. Now rename those images with the original name of the family members. Next, create a new Python file. Here I have created a Python file named “Home.py”. Open this file in PYTHON IDE and then create the code as described.
First, import the required libraries in the code and then define the servo motor GPIO pin with its min and max angle. After that, define the ultrasonic sensor pin number. Here we are using pin nos. 27 and 22. (Refer Fig 1)
Next, we will set the image file name within the list of family members allowed to enter the house in the quarantine period. This code will then analyse the face of the person on the camera. If detected as a person from the list of allowed family members, then the system will request to sanitize themselves before entering the house. It will then check the ultrasonic sensor reading using an if() condition. So, if the distance between the hands and the sanitizing tap/nozzle is below the threshold, then the sensor will get to know that someone has placed their hands near the tap/nozzle. After this, the tap/nozzle valve will open to allow sanitization.
It counts for 30 seconds so that person is sanitized thoroughly. By moving the servo to an open position, that person can be allowed entry into the house, hospital,or office. (Refer Fig 2.)
Now connect the components as described in the circuit diagram.
Testing for Home Quarantine Using Face Recognition
After powering the Raspberry Pi and other components, run the code that we have written and wait a few seconds for the camera window to open. When ready, the camera window will show the live video of the person standing in front of the camera. If it detects the person as a family member, then it will automatically ask you to sanitize your hand. To do so, the person has to place their hands near the ultrasonic sensor for them to be detected. Then the sanitizer will be sprayed onto your hands and will count to 30 seconds so that the hands get sanitized well. After that, the servo motor will move to unlock position, thus allowing you to enter the house.