Social Distance Detector

A Real-Time Social Distance Monitoring Tool

Project Status: Active

Table of Contents


The current COVID-19 pandemic is showing negative effects on human health as well as on social and economic life. It is a critical and challenging task to revive public life while minimizing the risk of infection. Reducing interactions between people by social distancing is an effective and prevalent measure to reduce the risk of infection and spread of the virus within a community. And so, this project will help to monitor that.

YOLO Theory

YOLO or You Only Look Once is an algorithm that uses neural networks to provide real-time object detection. Object detection in YOLO is done as a regression problem and provides the class probabilities of the detected images. As the name suggests, the algorithm requires only a single forward propagation through a neural network to detect objects.

Detection Output


A single frame from Video 1

Detection Output 1

A single frame from Video 2

Detection Output 2

Tech Stack

  • Python


  • Detect people who are practicing social distancing and those who are not.
  • Draw a green coloured box around those who are practicing social distancing and red for those who are not.
  • Display the following information :
    • The threshold values used for detection.
    • Number of people recognized.
    • Number of people who are practicing social distancing.
    • Number of people who are not practicing social distancing.

To Do and Further Improvements

  • Using YOLO for Image Detection
  • Calculate the distance between people and categorise them as safe and unsafe
  • Draw green coloured boxes for those who follow social distancing and red for those who don’t.
  • Detect and draw boxes for image, video and live stream.
  • Adding Birds-Eye View for the Video
  • Work on the minimum pixel distance for different media.
  • Assign a score at the end of the video/stream for every person based on the time they were not socially distanced.


The following dependencies and modules(python) are required, to run this locally

  • os, sys, argparse
  • math
  • mimetypes
  • numpy==1.21.2
  • opencv-python==

To install the requirements run:

$ pip install -r requirements.txt

Run Locally

  • Clone the GitHub repository

$ git clone
  • Move to the Project Directory

$ cd Social-Distance-Detector
  • Create a Virtual Environment (Optional)

    • Install Virtualenv using pip (If it is not installed)

     $ pip install virtualenv
    • Create the Virtual Environment

    $ virtualenv sdd
    • Activate the Virtual Environment

      • In MAC OS/Linux

      $ source sdd/bin/activate
      • In Windows

      $ source sdd\Scripts\activate
  • Install the requirements

(sdd) $ pip install -r requirements.txt
  • Run the python script along with the appropriate arguements

(sdd) $ python3 -m v -p media/test.mp4
  • Usage

      usage: [-h] [-m MEDIA] [-p PATH]

    optional arguements:
      -h --help                 Show this screen and exit.
      -m MEDIA --media MEDIA    Media Type (image(or i), video(or v), webcam(or w))
      -p PATH --path PATH       Path of the Media File (For webcam enter any character)
  • Other options to Edit

       You can go to the utilities/ and change the threshold values based on the video and system requirements.
   # If you want to use GPU:
   Set USE_GPU = True
   # If you want to increase or decrease the minimum threshold distance
   Modify the DIST_THRES value
   # If you want to change the Non Maximum Supression Threshold or Confidence Threshold
   Modify the NMS_THRESH or CONF_THRESH values respectively
  • Dectivate the Virtual Environment (after you are done)

(sdd) $ deactivate


This project is under the Apache-2.0 License License. See LICENSE for Details.


Pranav B Kashyap

Prakhar Singh

Avi Tewari