Inspiration get form facebook developer community, where each and every member develop out of the box projects.

What it does

Using Computer vision along with deep learning and machine learning provides effective solutions to measure social distancing among humans across the moving frames.

To achieve the above objective, I developed the algorithm which would do pedestrian detection & then measuring the distance between the 2 or more pedestrian by using camera calibration technique. To determine the distance in depth I use the adaptive threshold method with respect to human height.

To visualize it, we used the Red & Green color bounding box across the pedestrians in a frame.

  • Red color - persons in close proximity & don't follow social distancing.
  • Green color – persons are far away & follow social distancing

That's how AI will ensure people are far away from each other & follow social distancing.

How I built it

The steps to build a social distancing detector include:

Step #1: Apply object detection to detect all people (and only people) in a video stream (see this tutorial on building an OpenCV people counter).

Step #2: Compute the pairwise distances between all detected people

Step #3: Based on these distances, check to see if any two people are less than N pixels apart


Challenges I ran into

  1. Collecting the large dataset and preprocessing them was a more cumbersome and challenging task.
  2. The calculating distancing between the 2 clusters using camera calibration is one of the challenging tasks.

Accomplishments that I'm proud of

  • Real-time pre-processing
  • 0.1% latency and 99.4% accurate
  • Lightweight models used for deploying into production
  • Easily Integrate with embedded system and mobile device


  1. Live video surveillance to fight against the covid-19 spread

  2. The project can be integrated with embedded systems for application in airports, railway stations, offices, schools, and public places to ensure that public safety guidelines are followed.

  3. Real-time face mask detection and for social distancing tracking the crowd movement across the day time.

  4. Hot-spot areas can be monitored by security forces from the central station.

  5. If AI-based solutions used by authority then there will be less chance to get infected security forces.

What I learned

  1. Integration of pedestrian detection + calibration (i.e checking the distance between the 2 or more objects with respect to the current object.

  2. Model optimization using Mini-batch size, Learning rate, Regularization factors, pruning i.e Layer-specific hyperparameters (like dropout), and batch norm.

What's next for Real-time social distancing Detector

  1. Deploy the model on google cloud
  2. Use docker for faster installation of package and software
  3. Integrate with embedded systems for real-time alert systems.
  4. Integrate with mobile and web devices for message alert system.
  5. Face recognition to allow the authentic users to access to the main data source.
  6. Using blockchain technology, creating a decentralized chain network for security i.e only allows legitimate user to access the main server example: Security agent, IT Professional and admin, project manager

Built With

Share this project: