In these times of COVID-19, it is essential to go through thermal screening for checking one’s body temperature before entering any premises. However, it is a tiring process as it involves measuring body temperature of all people, one at a time. At the same time, those who carry out thermal screening are required to stand for more than 8 hours a day and check each and every person. This takes a lot of time and effort.
So to come up with a solution that can do this job effortlessly, we have built a Facial Recognition Thermal Screening System. The device works by recognising the face of each person and doing thermal screening to detect the body temperature. If a person is found to have a very high temperature, then the system will not allow entry and instead will automatically notify that person to take a COVID-19 test. If the body temperature falls between the required normal temperature range and is found to be okay, then entry is allowed after proper sanitization.
To start the project, collect the following components:-
Bill Of Materials
Make sure that your RPi has the latest Raspbian installed. It generally comes pre-installed with Python3 but if you didn’t find it, then install the latest Python environment and IDE as well.
Next, open the Linux terminal and install the following libraries using the command given below (Refer Fig 1):-
sudo pip3 install face-recognition
sudo apt-get install espeak
sudo apt-get install espeak python-espeak
sudo pip3 install opencv2
After installing the libraries, open the Python IDE and start writing the code by importing the following libraries to it:-
Espeak – To Announce the temperature and detect the face of a person.
Face_recoginition – To recognise the face.
Date and time – To add the date and time of a person entering an area and later store them in the database.
Opencv – To capture the video and process it frame-by-frame for facial recognition.
Next, set the image file name of each person we want to be recognised. If we don’t have an image of the person in the database then it is considered as unknown. After that we will create an array having the list of names and images of all identified people. The name and image need to be in the same order.
After that, the video frame will be processed in the while loop, which will recognise the name of the person and then match with the respective face that was detected. If it is different then it will use the MLX90614 sensor to measure the temperature of the person. Thereafter, using espeak the name and temperature of that person will be announced.
Next, the if() statements that we had written check whether the temperature is greater than 37 degrees Celsius or not. If the temperature is detected to be greater than that, then the system tells the person to not enter the area. It also captures the person’s image and temperature and saves them in a database folder with a timestamp.
.If a person’s temperature is found to be below 37 degrees Celsius, then the system allows that person to enter an area after proper sanitization. The person’s image is also saved in a separate database folder, which includes name and temperature along with a timestamp.
Below, we have the code that shows the image (taken from the captured video) along with the name and temperature. The outline of the rectangular frame showing your name and image will change its colour depending on the detected temperature (red = high temperature, green = low temperature).
After coding, connect the MLX sensor as shown in the table below. Connect the camera, HDMI display and sensor as shown in the picture below.
After setup, now power the Raspberry Pi and mount the device on a wall or a door. Rerun the code and wait for a few seconds. It will show the temperature and face of the person standing at the entrance. If the person is detected to have a high temperature/fever, the device will not allow entry to that person.
Now we will be able to check the database for information about each person going through the thermal screening process.