In this time when COVID-19 is spreading rapidly, it is essential to maintain social distance and avoid large public gatherings at one place to break the chain of corona infection.But maintaining this is not easy. Many people, knowingly or unknowingly, gather and roam on the streets. Keeping an eye on all these activities is not an easy job. The authorities need reliable technology that can survey such places to prevent any unnecessary movement. Our COVID-19 Crowd Detection Camera can help in isolating the poeple
So, today we have decided to make a Smart COVID-19 Crowd Detection Camera that will keep a watchful eye on all illegal activities and detect any crowd/person/vehicle on the road. The device also can alert the authorities regarding unnecessary gatherings.
However, this camera is not just limited to this. It can be used to:
- Detect high traffic on roads.
- Identify any unauthorised human entry in a restricted area.
- Observe the number of people in a hall/auditorium.
- Maintain and monitor the flow of the crowd in a protest demonstration.
How it works?
We are going to use an RPi with a camera for capturing live video. The video is then processed frame-by-frame.
By using image processing with the help of TensorFlow, people and vehicles in the video are identified. When that happens, the device gives an alert by speaking and/or by triggering the lights/bulb.
Bill Of Materials
Let’s start our project by collecting the following components.
Assuming that you already have the RPi ready with Raspbian Image and Python environment setup, we can install the required libraries and modules.
Firstly, install the following libraries in Python.
- TensorFlow/TensorFlow Lite
To install the above libraries, open the LX terminal and then type the following commands:
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 tensorflow
After the installation you can now proceed with the cloning of TF modules and examples and files using the following command:
git clone https://github.com/tensorflow/tensorflow.git
After successfully cloning, go to the directory → research folder → create a new Python file and paste the code attached with the article.
In the first part of the code, we have to initialize the required library. Then we will have the code that uses the camera module to take live video and then process it frame-by-frame to detect the desired objects such as:
Now using the if() condition, we will check whether any desired objects have been detected. If nothing is detected, then no action will be taken. But if detected, the code will trigger the speaker to give an alert. You can also attach a bulb/buzzer to pin 17 to get the alert notification.
Now connect the camera to the RPi4 board using a ribbon cable and power the Raspberry Pi using an adaptor. To get a live video output from the camera, you can either use an RCA Cable with RCA Input of TV or use HDMI cable with TV.
You can also use a VNC. Just connect RPi and PC/Laptop with your network/hotspot and then mirror its screen using VNC. Now, connect a speaker to the audio port of RPI and power it. If you want any alert using bulb/buzzer, then connect the buzzer to GPIO pin 17 of Raspberry Pi.
After making all the connections and setup, now let’s test our project. Open the folder and then run the code. Wait for a few seconds to let the Python initialize all the modules. Then run the code. After a few seconds, a new window opens up and shows the results of the cam. The detected people are shown in the window and an alert is given about their presence on the road.