All Projects → saimj7 → Social-Distancing-Detection-in-Real-Time

saimj7 / Social-Distancing-Detection-in-Real-Time

Licence: MIT license
Social distance monitoring in real-time with an IP camera. Optimized for better performance with threading.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Social-Distancing-Detection-in-Real-Time

Social-Distancing-Detector
An AI Tool to Help Customers Monitor Social Distancing in the Workplace.
Stars: ✭ 61 (+17.31%)
Mutual labels:  yolov3, social-distancing, social-distancing-detection
Automated-Social-Distancing-Monitoring
automated social distancing monitoring system
Stars: ✭ 1 (-98.08%)
Mutual labels:  yolov3, covid-19, social-distancing
awesome-social-distancing
😷 Collection of awesome resources, tools, and initiatives to alleviate loneliness, isolation, and other burdens imposed by "social distancing" measures.
Stars: ✭ 13 (-75%)
Mutual labels:  covid-19, social-distancing
COVID-19-US-State-Policy-Database
No description or website provided.
Stars: ✭ 60 (+15.38%)
Mutual labels:  covid-19, social-distancing
facetouch
Neural Network to predict face touch on live feed and warn you, "don't touch the face".
Stars: ✭ 24 (-53.85%)
Mutual labels:  yolov3, covid-19
People-Counting-in-Real-Time
People Counting in Real-Time with an IP camera.
Stars: ✭ 233 (+348.08%)
Mutual labels:  people-counter, covid-19
smart-social-distancing
Social Distancing Detector using deep learning and capable to run on edge AI devices such as NVIDIA Jetson, Google Coral, and more.
Stars: ✭ 129 (+148.08%)
Mutual labels:  social-distancing, social-distancing-detection
detection-pytorch
A pytorch Implementation of classical object detection.
Stars: ✭ 24 (-53.85%)
Mutual labels:  yolov3
detection util scripts
TF and YOLO utility scripts
Stars: ✭ 49 (-5.77%)
Mutual labels:  yolov3
flatten-the-curve
COVID-19: By the numbers. Presenting country comparisons and adjustable cumulative graphs. Looking for another developer to keep this up to date
Stars: ✭ 18 (-65.38%)
Mutual labels:  covid-19
web-coronavirus-stats
🌎 🦠 😷 Coronavirus disease (COVID-2019) global / world / country statistics and reports
Stars: ✭ 2 (-96.15%)
Mutual labels:  covid-19
oscovida
Explore COVID19 case numbers and deaths related to Coronavirus outbreak 2019/2020 in Pandas and in Jupyter notebook with MyBinder
Stars: ✭ 33 (-36.54%)
Mutual labels:  covid-19
OpenCovidDetector
New virsion for multi-categories were available. Since too many changes above old virsion, please refer to this site https://github.com/ChenWWWeixiang/diagnosis_covid19
Stars: ✭ 18 (-65.38%)
Mutual labels:  covid-19
Alturos.ImageAnnotation
A collaborative tool for labeling image data for yolo
Stars: ✭ 47 (-9.62%)
Mutual labels:  yolov3
covid19-algorithme-orientation
Documentation de l'algorithme d'orientation COVID19
Stars: ✭ 12 (-76.92%)
Mutual labels:  covid-19
CoopTilleulsSyliusClickNCollectPlugin
Sell and deliver securely during the COVID-19 pandemic!
Stars: ✭ 77 (+48.08%)
Mutual labels:  covid-19
CoronaDash
COVID-19 spread shiny dashboard with a forecasting model, countries' trajectories graphs, and cluster analysis tools
Stars: ✭ 20 (-61.54%)
Mutual labels:  covid-19
covid-19-visualization
US Covid-19 Visualization. Github pages automatic build.
Stars: ✭ 2 (-96.15%)
Mutual labels:  covid-19
COVID 19-Social-Dist-Simulation
COVID-19 social distancing simulator
Stars: ✭ 12 (-76.92%)
Mutual labels:  social-distancing
YOLO-Streaming
Push-pull streaming and Web display of YOLO series
Stars: ✭ 56 (+7.69%)
Mutual labels:  yolov3

Social-Distancing-in-Real-Time

Social distancing in Real-Time using live video stream/IP camera in OpenCV.

This is an improvement/modification to (https://www.pyimagesearch.com/2020/06/01/opencv-social-distancing-detector/).

Please refer to the added Features.

Output Output
Output Output
  • Use case: counting the number of people in the stores/buildings/shopping malls etc., in real-time.
  • Sending an alert to the staff if the people are way over the social distancing limits.
  • Optimizing the real-time stream for better performance (with threading).
  • Acts as a measure to tackle COVID-19.

Table of Contents

Simple Theory

Object detection:

  • We will be using YOLOv3, trained on COCO dataset for object detection.
  • In general, single-stage detectors like YOLO tend to be less accurate than two-stage detectors (R-CNN) but are significantly faster.
  • YOLO treats object detection as a regression problem, taking a given input image and simultaneously learning bounding box coordinates and corresponding class label probabilities.
  • It is used to return the person prediction probability, bounding box coordinates for the detection, and the centroid of the person.

Distance calculation:

  • NMS (Non-maxima suppression) is also used to reduce overlapping bounding boxes to only a single bounding box, thus representing the true detection of the object. Having overlapping boxes is not exactly practical and ideal, especially if we need to count the number of objects in an image.
  • Euclidean distance is then computed between all pairs of the returned centroids. Simply, a centroid is the center of a bounding box.
  • Based on these pairwise distances, we check to see if any two people are less than/close to 'N' pixels apart.

Running Inference

  • Install all the required Python dependencies:
pip install -r requirements.txt
  • If you would like to use GPU, set USE_GPU = True in the config. options at 'mylib/config.py'.

  • Note that you need to build OpenCV with CUDA (for an NVIDIA GPU) support first:

Click here for build instructions on Windows.

This tutorial also might help. Click here.

  • Download the weights file from here and place it in the 'yolo' folder.

  • To run inference on a test video file, head into the directory/use the command:

python run.py -i mylib/videos/test.mp4
  • To run inference on an IP camera, Setup your camera url in 'mylib/config.py':
# Enter the ip camera url (e.g., url = 'http://191.138.0.100:8040/video')
url = ''
  • Then run with the command:
python run.py

Set url = 0 for webcam.

Features

The following are examples of the added features. Note: You can easily on/off them in the config. options (mylib/config.py):

1. Real-Time alert:

  • If selected, we send an email alert in real-time. Use case: If the total number of violations (say 10 or 30) exceeded in a store/building, we simply alert the staff.
  • You can set the max. violations limit in config (Threshold = 15).
  • This is pretty useful considering the COVID-19 scenario.

Note: To setup the sender email, please refer the instructions inside 'mylib/mailer.py'. Setup receiver email in the config.

2. Threading:

  • Multi-Threading is implemented in 'mylib/thread.py'. If you ever see a lag/delay in your real-time stream, consider using it.
  • Threading removes OpenCV's internal buffer (which basically stores the new frames yet to be processed until your system processes the old frames) and thus reduces the lag/increases fps.
  • If your system is not capable of simultaneously processing and outputting the result, you might see a delay in the stream. This is where threading comes into action.
  • It is most suitable for solid performance on complex real-time applications. To use threading:

set Thread = True in the config.

3. People counter:

  • If enabled, we simply count the total number of people: set People_Counter = True in the config.

4. Desired violations limits:

  • You can also set your desired minimum and maximum violations limits. For example, MAX_DISTANCE = 80 implies the maximum distance 2 people can be closer together is 80 pixels. If they fell under 80, we treat it as an 'abnormal' violation (yellow).
  • Similarly MIN_DISTANCE = 50 implies the minimum distance between 2 people. If they fell under 50 px (which is closer than 80), we treat it as a more 'serious' violation (red).
  • Anything above 80 px is considered as a safe distance and thus, 'no' violation (green).

References

Main:

Optional:


Thanks for the read & have fun!

To get started/contribute quickly (optional) ...

  • Option 1

    • 🍴 Fork this repo and pull request!
  • Option 2

    • 👯 Clone this repo:
    $ git clone https://github.com/saimj7/Social-Distancing-Detection-in-Real-Time.git
    
  • Roll it!


saimj7/ 02-11-2020 © Sai_Mj.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].