Real-Time Social Distance Monitoring tool using Computer Vision

Overview

Social Distance Detector

A Real-Time Social Distance Monitoring Tool

Project Status: Active

Table of Contents

Motivation

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

animated


A single frame from Video 1

Detection Output 1

A single frame from Video 2

Detection Output 2

Tech Stack

  • Python

Functionalities

  • 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.

Requirements

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

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

To install the requirements run:

$ pip install -r requirements.txt

Run Locally

  • Clone the GitHub repository
$ git clone git@github.com:Pranav1007/Social-Distance-Detector.git
  • 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 run.py along with the appropriate arguements
(sdd) $ python3 run.py -m v -p media/test.mp4
  • Usage
"""
    Usage:
      usage: run.py [-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/config.py 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

License

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

Contributors


Pranav B Kashyap


Prakhar Singh


Avi Tewari

You might also like...
Computer vision - fun segmentation experience using classic and deep tools :)
Computer vision - fun segmentation experience using classic and deep tools :)

Computer_Vision_Segmentation_Fun Segmentation of Images and Video. Tools: pytorch Models: Classic model - GrabCut Deep model - Deeplabv3_resnet101 Flo

TCNN Temporal convolutional neural network for real-time speech enhancement in the time domain
TCNN Temporal convolutional neural network for real-time speech enhancement in the time domain

TCNN Pandey A, Wang D L. TCNN: Temporal convolutional neural network for real-time speech enhancement in the time domain[C]//ICASSP 2019-2019 IEEE Int

Open source Python module for computer vision

About PCV PCV is a pure Python library for computer vision based on the book "Programming Computer Vision with Python" by Jan Erik Solem. More details

PyTorchCV: A PyTorch-Based Framework for Deep Learning in Computer Vision.
PyTorchCV: A PyTorch-Based Framework for Deep Learning in Computer Vision.

PyTorchCV: A PyTorch-Based Framework for Deep Learning in Computer Vision @misc{CV2018, author = {Donny You ([email protected])}, howpubl

Build fully-functioning computer vision models with PyTorch
Build fully-functioning computer vision models with PyTorch

Detecto is a Python package that allows you to build fully-functioning computer vision and object detection models with just 5 lines of code. Inferenc

Implementation of self-attention mechanisms for general purpose. Focused on computer vision modules. Ongoing repository.
Implementation of self-attention mechanisms for general purpose. Focused on computer vision modules. Ongoing repository.

Self-attention building blocks for computer vision applications in PyTorch Implementation of self attention mechanisms for computer vision in PyTorch

Datasets, Transforms and Models specific to Computer Vision

torchvision The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision. Installat

Repository providing a wide range of self-supervised pretrained models for computer vision tasks.

Hierarchical Pretraining: Research Repository This is a research repository for reproducing the results from the project "Self-supervised pretraining

A PyTorch-Based Framework for Deep Learning in Computer Vision

TorchCV: A PyTorch-Based Framework for Deep Learning in Computer Vision @misc{you2019torchcv, author = {Ansheng You and Xiangtai Li and Zhen Zhu a

Comments
  • separator_index < line.size() in function 'ReadDarknetFromCfgStream'

    separator_index < line.size() in function 'ReadDarknetFromCfgStream'

    Hi guys,

    When I ran the bellow error has occurred.

    $ python3 run.py -m v -p media/test.mp4
    Traceback (most recent call last):
      File "../Social-Distance-Detector/run.py", line 3, in <module>
        from utilities.helper import video, image, webcam
      File "../Social-Distance-Detector/utilities/helper.py", line 3, in <module>
        from .functions import main_func, findObjects, load_model
      File "../Social-Distance-Detector/utilities/functions.py", line 8, in <module>
        classNames, modelNet = load_model()                 # Load the yolo model
      File "../Social-Distance-Detector/utilities/model.py", line 24, in load_model
        modelNet = cv2.dnn.readNetFromDarknet(modelConfig, modelWeights)    # Loading the YOLO Object Detector Model
    cv2.error: OpenCV(4.5.3) /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-req-build-vy_omupv/opencv/modules/dnn/src/darknet/darknet_io.cpp:659: error: (-215:Assertion failed) separator_index < line.size() in function 'ReadDarknetFromCfgStream'
    
    opened by monxarat 1
  • Bump numpy from 1.21.2 to 1.22.0

    Bump numpy from 1.21.2 to 1.22.0

    Bumps numpy from 1.21.2 to 1.22.0.

    Release notes

    Sourced from numpy's releases.

    v1.22.0

    NumPy 1.22.0 Release Notes

    NumPy 1.22.0 is a big release featuring the work of 153 contributors spread over 609 pull requests. There have been many improvements, highlights are:

    • Annotations of the main namespace are essentially complete. Upstream is a moving target, so there will likely be further improvements, but the major work is done. This is probably the most user visible enhancement in this release.
    • A preliminary version of the proposed Array-API is provided. This is a step in creating a standard collection of functions that can be used across application such as CuPy and JAX.
    • NumPy now has a DLPack backend. DLPack provides a common interchange format for array (tensor) data.
    • New methods for quantile, percentile, and related functions. The new methods provide a complete set of the methods commonly found in the literature.
    • A new configurable allocator for use by downstream projects.

    These are in addition to the ongoing work to provide SIMD support for commonly used functions, improvements to F2PY, and better documentation.

    The Python versions supported in this release are 3.8-3.10, Python 3.7 has been dropped. Note that 32 bit wheels are only provided for Python 3.8 and 3.9 on Windows, all other wheels are 64 bits on account of Ubuntu, Fedora, and other Linux distributions dropping 32 bit support. All 64 bit wheels are also linked with 64 bit integer OpenBLAS, which should fix the occasional problems encountered by folks using truly huge arrays.

    Expired deprecations

    Deprecated numeric style dtype strings have been removed

    Using the strings "Bytes0", "Datetime64", "Str0", "Uint32", and "Uint64" as a dtype will now raise a TypeError.

    (gh-19539)

    Expired deprecations for loads, ndfromtxt, and mafromtxt in npyio

    numpy.loads was deprecated in v1.15, with the recommendation that users use pickle.loads instead. ndfromtxt and mafromtxt were both deprecated in v1.17 - users should use numpy.genfromtxt instead with the appropriate value for the usemask parameter.

    (gh-19615)

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Owner
Pranav B
Pranav B
Real-Time-Student-Attendence-System - Real Time Student Attendence System

Real-Time-Student-Attendence-System The Student Attendance Management System Pro

Rounak Das 1 Feb 15, 2022
Hunt down social media accounts by username across social networks

Hunt down social media accounts by username across social networks Installation | Usage | Docker Notes | Contributing Installation # clone the repo $

null 1 Dec 14, 2021
Rohit Ingole 2 Mar 24, 2022
Monk is a low code Deep Learning tool and a unified wrapper for Computer Vision.

Monk - A computer vision toolkit for everyone Why use Monk Issue: Want to begin learning computer vision Solution: Start with Monk's hands-on study ro

Tessellate Imaging 507 Dec 4, 2022
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 360 Dec 10, 2022
LeafSnap replicated using deep neural networks to test accuracy compared to traditional computer vision methods.

Deep-Leafsnap Convolutional Neural Networks have become largely popular in image tasks such as image classification recently largely due to to Krizhev

Sujith Vishwajith 48 Nov 27, 2022
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 359 Jan 5, 2023
Face Mask Detection System built with OpenCV, TensorFlow using Computer Vision concepts

Face mask detection Face Mask Detection System built with OpenCV, TensorFlow using Computer Vision concepts in order to detect face masks in static im

Vaibhav Shukla 1 Oct 27, 2021
Lacmus is a cross-platform application that helps to find people who are lost in the forest using computer vision and neural networks.

lacmus The program for searching through photos from the air of lost people in the forest using Retina Net neural nwtwork. The project is being develo

Lacmus Foundation 168 Dec 27, 2022
Spiking Neural Network for Computer Vision using SpikingJelly framework and Pytorch-Lightning

Spiking Neural Network for Computer Vision using SpikingJelly framework and Pytorch-Lightning

Sami BARCHID 2 Oct 20, 2022