Crowd Detection Camera To Prevent COVID-19

Ashwini Kumar Sinha

29903
 
COVID-19 Crowd Detection Camera
Fig

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.

Bill for Crowd Detection Camera

Prerequisites

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.

  • Espeak
  • Numpy
  • Scipy
  • Opencv
  • Dlib
  • Keras
  • 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

wget https://bootstrap.pypa.io/get-pip.py

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. 

Coding 

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:

  • Bike
  • Bicycle
  • People
  • Bus
  • Car 

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.

Using Opencv
Fig 1.
Path for Crowd Detection models
Fig 2.
Tensorflow model processing
Fig 3
Counting people fro crowd detection
Fig 4.

Connection 

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.

Csmera for crowd detection
Fig 5.

Testing

Camera attached to raspberry pi
Fig 6.

 

Dtecting drowd and people
Fig 7. Detecting the people on Road

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.

Download Source Code

51 COMMENTS

  1. Not a bad idea, I’m working on prototypes for jamming signals and surveillance systems. Not everyone likes their privacy exposed.

  2. After successfully cloning, go to the directory → research folder → create a new Python file and paste the code attached with the article.

    I can’t find where is research folder? please helps.

    • The project does not require a circuit diagram or block diagram.It works on following way:-
      RPI camera takes video—> video is sliced into frames—–>frame is resized For processing—>Tensor flow process the frames and detect people

  3. Sir, I am doing this project for semester . So can I get complete details of the project(circuit diagram, code and libraries) .Can you send me the details to my mail i.e. [email protected] is urgent so kindly send the details as quickly as possible sir

  4. Hello, i would like to seek clarification for this part ,”After successfully cloning, go to the directory → research folder → create a new Python file and paste the code attached with the article. ” I am not sure what should i do in my Pi desktop now. Please advise thank you!

  5. after running the code it is showing no module name util what do plz help and in program there no syntax for buzzer can clarify

  6. i am getting (from utils import label_map_util
    ModuleNotFoundError: No module named ‘utils’) this problem while implementing
    and in code there is no syntax for buzzer

    • probably you do not have the modules file get the modules file https://github.com/tensorflow/models
      copy it tensorflow folder purt the code in object detection folder and then go to data folder inside research folder then open the mscoco_label_map.pbtxt and delete all other object to detect except people

      • I didn’t understood anything you said, open the folders in order you said i got a code (item {
        name: “/m/01g317”
        id: 1
        display_name: “person”
        }) like this and so on
        I have to copy only person code and then what i have to do if this is the way of process you told

        • the file is .pbtx have the list of objects to detected so delete all and let only person, car, bicycle in the list to detect and count them. and then save that file. now in the object detection folder copy my code and run it

      • i didn’t understood what exactly you told, if you are saying open folder one by one then at last i got code in that I saw ‘person code’, what should I do now. If your asking to copy source code and all I didn’t understood please clarify exactly

SHARE YOUR THOUGHTS & COMMENTS

Please enter your comment!
Please enter your name here