DIY Mask/QR Code Recognition Smart Access Device W Raspberry Pi

by Elecrow in Circuits > Raspberry Pi

1396 Views, 13 Favorites, 0 Comments

DIY Mask/QR Code Recognition Smart Access Device W Raspberry Pi

新建项目 (6).png

Yo, my hood's been hit by another wave of COVID-19 and some of my coworkers are showing symptoms of a second infection, yet they still refuse to mask up! To remind them to wear their masks and to keep myself healthy, I decided to make a punch-clock-like device that can detect whether my colleagues have properly masked up, check their temps, and even scan their health codes. To make it look cooler, I used OpenCV and Python to recognize and display different images of masked and unmasked faces, and slapped on an infrared thermal imaging module to display body temps. I'm pretty sure my coworkers will think it's dope when they see it and be more willing to cooperate with the checks. This project is not only gonna keep us healthy during the pandemic, but also help us understand target recognition and HTTPS protocol.

Supplies

IMG_20230609_102509.jpg

Raspberry Pi 4B x1 ---> I will use it as my main control board. It has a powerful configuration, can run OpenCV, and its performance is much smoother than the 3B+ (before this, I tried to run OpenCV on the 3B+, but the image was very slow).

7 inch Screen x1 ---> "This screen fits perfectly with the size of my case, and the image is very clear. It is also touch-enabled, although I haven't used the touch function yet. During my testing, I found that the touch screen is very responsive, which surprised me.

Infrared module x1 ---> "I will use it to help me determine whether a phone is approaching after the prompt 'Please show the health code'.

Camera x2 --->Camera 1 is used for recognizing faces and masks, while Camera 2 is used for recognizing health codes. However, I recently discovered that Elecrow has launched a QR code recognition module. This means that after completing this small project, I can eliminate one camera and use the QR code recognition module to replace it.

Device casing x1 ---> The case is not custom-made, so everyone can design it according to their own preferences or use a similar case. Implementing the functionality is our primary goal and the most enjoyable part of the project.

MLX90640 Thermal imaging module x1 ---> I will use this module to implement thermal imaging functionality, and it can help me measure the body temperature of the user. It looks very cool.

Buzzer module x1 --> It will make a 'beep' sound after taking a photo of the health code.

MP3 module & Speaker x1 ---> It will play the voice prompt that I have pre-recorded and stored in the SD card, to guide the user on what to do.

SD card x2 ---> One is used to run the Raspberry Pi system, while the other is used to store MP3 files.

Battery x1 ---> I plan to use a battery to power my device, and I must strictly follow the power requirements of the Raspberry Pi, which is 5V and 3A.

Switch x1 ---> A switch that helps me control the power on and off.

DuPont wires xN --->The tool that helps me connect modules together.

Make the Case

IMG_20230608_184207.jpg
IMG_20230608_184224.jpg
IMG_20230608_185327.jpg
IMG_20230608_190443.jpg
QQ截图20230612163535.png
QQ截图20230612163604.png
QQ截图20230612163719.png
QQ截图20230612163753.png
QQ截图20230612163859.png
QQ截图20230612163929.png

To speed up the process of making my device, I bought a case online that was close to what I needed. I then modified it to fit my requirements better. Here's what I did:

First, I cut a small hole in the case to make sure the screen's wires wouldn't be blocked. I smoothed out the edges with a file.

Next, I noticed that the case didn't close properly when I put in the Raspberry Pi. So I had to cut off a few pillars on the back cover of the case. After that, I could easily close the case even with the Raspberry Pi inside.

Lastly, I made a hole on the case bigger so that I could fit my switch button.

Make and Connect the Switch

QQ截图20230612164102.png
QQ截图20230612164031.png

When I was planning it out, I totally forgot about the on/off switch. It wasn't until I was halfway through making it that I suddenly remembered. I realized that if I didn't include a switch, it would be a real pain to turn the thing on and off - I'd have to keep opening up the box and plugging/unplugging the power cord. But if I put in a switch, it would be way easier to control the power.

Connect All Modules Together

bee_n_frare.png
mlx90640.png
mp3player.png

After preparing the case, you can start connecting all the modules together. This step is crucial and requires careful attention. Make sure you don't connect the wires incorrectly, especially the positive and negative poles. If there is a short circuit, it may damage the modules or even your Raspberry Pi!

In addition, there are two cameras that you need to connect to the Raspberry Pi. One is a QR code camera that can be plugged into any USB port on the Pi, and the other is a mask recognition camera that should be connected to the Pi's default CAMERA interface.

Here is the wiring diagram that I prepared. You can follow this diagram to connect the modules. Please make sure you don't connect them incorrectly.

Fixing and Assembly

QQ截图20230615202408.png
QQ截图20230615202445.png
QQ截图20230615202520.png
QQ截图20230615202545.png

First, let's use some hot glue to stick the screen and QR code camera onto the front of the case. This will make things easier when we're putting everything together later. Then we can fix all the other parts onto the back of the case. I decided where to put them based on the case I'm using, but you can arrange them however you like as long as everything can connect properly and the case closes up completely.

Wrtie the Image

QQ截图20230612185423.png

I've finished the hardware part, and now in this step, I need to download an image onto my computer. Setting up the environment is a bit complicated and if I make a mistake, it could mess up the software and I'd have to start all over again, which takes a lot of time. That's why I highly recommend using the image I'm providing.

Before I can burn the image, I need to download and install a software called "Win32 Disk Imager," which will help me burn the image onto an SD card. After I've installed the software, I'll open it, find the image I'm using, choose the SD card, and click "Write" to burn the image.

Once the burning process is complete, I'll insert the SD card into the Raspberry Pi, and then it's ready to be turned on!

Set Up WIFI

because my program requires internet access to upload the health code photo taken to a cloud-based API via HTTPS, wait for the API to recognize the code and return the result, and then display the result accordingly.

To set up Wi-Fi, first execute the command:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Locate the following code:

network={

ssid="YOUR_WIFI_NETWORK_NAME"

psk="YOUR_WIFI_PASSWORD"

}

Replace "YOUR_WIFI_NETWORK_NAME" and "YOUR_WIFI_PASSWORD" with your own Wi-Fi network name and password.

After modifying the Wi-Fi network and password, save the file and exit the editor, then restart. The Raspberry Pi will automatically connect to your Wi-Fi network.

Power It Up !

微信图片_20230615113131.png
QQ截图20230615204054.png
QQ截图20230615204453.png
DIY Simple Face Recognition System With Raspberry Pi 4 Model B

I have placed the program in the directory "Mask_nd_Temp/New_jkm" on the desktop. If you don't want the program to automatically run at startup, you can go to the "/etc/rc.local" file.

Locate the following code:

sudo bash /home/njl/runapp.sh

put a "#" in front of it, and then save the file. This will disable the automatic startup.


After completing all of the above steps, I can see the same effect as shown in the video. Isn't it amazing? And it only requires a Raspberry Pi 4B to achieve such a cool function, which impressed my colleagues and made me very happy. It also helps remind my colleagues to wear masks and reduce the risk of infection.

Finally, I wish all my friends who have read this good health and happiness every day!