Professional Documents
Culture Documents
Software Setup
1. Download Raspberry Pi Imager for your Operating System from the Raspberry Pi Download Page.
2. Attach the SD card to your computer, Select the Latest Version of Raspberry Pi OS and click Write to
flash the OS to your Card.
3. Attach the SD card to the Raspberry Pi, connect it to a monitor, and Power it. Wait for a few minutes until
the Raspberry Pi Boots up.
4. Connect your WiFi with your local WiFi Router by clicking the Wifi Icon Upper Right Corner of the Screen
and entering your
Enter the following commands in the Terminal one by one to install various Packages and Libraries.
Updating pip3
$ pip3 install --upgrade pip3
Expanding Swap Size and Changing Memory
Note- These need to be changed back after all the installations are Completed.
$ sudo nano /etc/dphys-swapfile
A new file will open. Navigate to CONF_SWAPSIZE=100 and change it to CONF_SWAPSIZE=1024. Then
click Ctr + O, then Enter and then Ctr + X to save the changes.
Then,
$ sudo raspi-config
and Navigate to Advanced Options => Memory Split and change from 128 => 16.
Installing Requirements
$ sudo pip3 install numpy
Installing OpenCV
Instaling OpenCV
$ sudo apt-get install python3-opencv
Installing TensorFlow
Note- The Model was trained on Tensorflow-2.2, if you are using any other versions of Tensorflow it may
cause some problems.
$ sudo apt-get install -y libhdf5-dev libc-ares-dev libeigen3-dev gcc gfortran python-dev libgfortran5 \
libatlas3-base libatlas-base-dev libopenblas-dev libopenblas-base libblas-dev \ liblapack-dev cython
libatlas-base-dev openmpi-bin libopenmpi-dev python3-dev
$ wget
"https://raw.githubusercontent.com/PINTO0309/Tensorflow-bin/master/tensorflow-2.2.0-cp37-cp37m-linux_armv7l_do
wnload.sh"
$ ./tensorflow-2.2.0-cp37-cp37m-linux_armv7l_download.sh
>>> tensorflow.__version__
2.2.0
>>> exit()
If you get no error in this step, it means you have successfully installed Tensorflow.
Installing DLIB
$ pip3 install dlib
>>> exit()
If you get no error in this step, it means you have successfully installed DLIB.
A new file will open. Navigate to CONF_SWAPSIZE=1024 and change it to CONF_SWAPSIZE=100. Then
click Ctr + O, then Enter and then Ctr + X to save the changes.
Then,
$ sudo raspi-config
and Navigate to Advanced Options => Memory Split and change from 16 => 128.
$ cd covid
This will open a file, at the end of the file add the following lines if you want to get email alerts
export SEND_EMAIL="TRUE"
export EMAIL_ID="your-email-id@something.com"
export EMAIL_PWD="your-email-password"
export COUNTER_ID=0
Email Setup
To use the email Alert Service you will need a Gmail Account and you will need to Allow Less Secure Apps.
Or, if you use 2 Factor Authentication then you might need to create an App Password.
Hardware Setup
Schematic
Attach the Servos X and the Sensor Y as Given in the Circuit Diagram. All the Connections can be made as
per the diagram. The Camera has to be connected to the Camera Connector and Raspberry Pi Display can
be connected to the Display Connector. If you are using a Generic 3.5 inch Touch Screen, you can connect
the screen to the required GPIOs. The GPIOs connecting to Servos will still be free, but you will need to
solder to get 5v and SDA, SCL pins for the Sensor.
Note- Servo X is the Servo which moves Right-Left. Servo Y is the Servo which moves Up-Down.
Sensor Setup
$ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- 5a -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
$ cd ~/covid
$ nano app.py
$ cd ~/covid
$ nano temp_checker.py
Testing
$ cd ~
$ cd covid
You can 3D Print the Enclosure using the files given below or else you can make Your own Makeshift
Enclosure using Cardboard, Wood, etc.
I have 3D Printed this enclosure made by Stephen Wilson for my 3.5 inch Touch Screen Display.
Raspberry Pi 3.5 inch Touch Screen Case by Stephen Wilson
If you are using the Official Raspberry Pi Display try finding Enclosures on Thingiverse. I liked this one a lot
but have not tested it out.
Note- These Cases are for Raspberry Pi 2/3 and will not work with Pi 4. For Pi 4 you will need to find a
different Case. The files attached below for the Camera-Sensor Enclosure do not have any screw holes for
the sensor (As the sensor comes in Many Shapes and Sizes). If you want to have Screw Holes feel free to
edit these files.
Final Design
Debugging
Note- This might be tricky if you get stuck at any step feel free to contact me!
1. Take Some Pictures on Your Raspberry Pi with mask and without a mask using the command-
$ raspistill -o image-name.jpg
2. Go to the Google Collab Notebook here and Duplicate it. Change the Runtime Type in Runtime =>
Change Runtime Type to GPU.
3. Then in your notebook Run the first 4 Cells. This will create two folders in files with mask and without
mask. Add the images taken by you to these folders and run all other Cells.
4. Then a new model will be created as mask_detector.h5. Download this model and replace the old model
in covid => models on your Raspberry Pi with it.
The Temperature Checkup requires proper lighting. Make sure you have proper lighting and that your
Servos are working well.
Shoutout to Adrian Rosebrock for his amazing Computer Vision Blogs.
Camera-Sensor-Enclosure
Schematics
Schematic Diagram
All the Connections can be made as per the diagram. The Camera can be connected to the Camera Connector and Raspberry Pi Display
can be connected to the Display Connector. If you are using a Generic 3.5 inch Touch Screen, you can connect the screen to the required
GPIOs. The GPIOs connecting to Servos will still be free, but you will need to solder to get 5v and SDA, SCL pins for the Sensor.
Fritzing File
Code
saksham2001 / TouchFree-v1
32
TouchFree v1: AI-based Mask Detection and Temperature Check — Read More
Latest commit to the master branch on 8-21-2020