Professional Documents
Culture Documents
Dr. Chandrika J
Professor
(Department of Computer Science and Engineering)
2020-2021
Social Distance Detector Using machine Learning
External Viva
Name of the Examiners Signature with Date
1.
2.
ACKNOWLEDGEMENT
We present with immense pleasure this work titled ”Social Distance Detector”.
An endeavor over a long period can be successful with the advice and support of many well
wishes. We take this opportunity to express our gratitude and appreciation to all of them.
The satisfaction that accompany the successful completion of any task would be incomplete
without mentioning the people who made it possible. So, with gratitude we acknowledge all those
whose guidance and encouragement made to successfully complete this project.
We would like to express sincere thanks to our Principal Dr. C.V.Venkatesh , Malnad College of
Engineering for his encouragement made to successfully completion of the project work.
We wish to express our gratitude to Dr. Geetha Kiran A , Professor and head, department of
CS&E for providing a good working environment and for her constant support and
encouragement.
We would also like to thank all the staff of Computer Science and Engineering department who
have directly or indirectly helped us in the completion of the project work.
At last we would hereby acknowledge and thank our parents who have been a source of
inspiration and also instrumental in the successful completion of this mini project work.
Project Associates
Abstract 05
1 INTRODUCTION 06
2 LITERATURE SURVEY 08
ABSTRACT
Pervasive COVID-19 disease, initially reported at Wuhan, China is a rampant global crisis
thrusting the world to pandemic. It has laid major economic and societal activities to cessation.
According to WHO norms it is prescribed to maintain Maintaining social distance, which has
challenged day to day interactions and transactions, demanding the need to redefine the default
behaviour and social setting of human. Humans to adjust to this setting, purely by
consciousness and common sense is near to impossible. Rules and regulations cannot enforce
distancing at personal level. There is a need for greater awareness and better approach to deal
this crisis. People fail to maintain distance in market and other crowded places. It is also
annoying to always analyse people around us and check if they at suitable distance from us.
This extra screening needs to be facilitated so that people can carry on with their choirs without
hustle and fear of folks violating the new norm. Deriving motivation from this unbridled
circumstance, the project aims at two level detection. One at the monitoring level, detecting
the objects breaking the social distance through pixel calculations. At individual scale, involves
finding distance from the camera to the humans by computer vision and machine learning
techniques. The project aims to screen the surrounding objects or humans and detect the safe
distance violations between the user(camera) and the individuals at the sight of OpenCV.
OpenCV is an open source computer vision and machine learning software library majorly
used in the project. The count of people violating the safe distance is also detected which can
be extended to individual alert messages .
CHAPTER 1
INTRODUCTION
Social distancing is an effective measure against the novel Corona Virus Disease 2019
(COVID-19) pandemic. To limit the spread of an infectious disease, for instance, Covid-19, is
to practice social distancing. This is not a new concept, as most societies have been aware of
the value of keeping away from people who are suffering from an infection for many
generations. Social distancing is arguably the most effective nonpharmaceutical way to prevent
the spread of a disease — by definition, if people are not close together, they cannot spread
germs. healthcare system. It is an action taken to minimize contact with other individuals. It
has been suggested that maintaining a distance of approximately 2 metres from another
individual result in a marked reduction in transmission of most flu virus strains, including
COVID19. Deploying such an active surveillance system requires serious ethical
considerations and smart system design.
In practice, this means that avoiding close proximity to other people will aid in slowing the
spread of infectious diseases. Social distancing is one of the nonpharmaceutical infection
control actions that can stop or slow down the spread of a highly contagious disease. The virus
that causes COVID-19 is currently spreading easily from person-to-person. When a healthy
person comes into contact with respiratory droplets from coughs or sneezes of an infected
person, they are can catch the infection. This study is proposed to support the actions on
Covid19 spread mitigation. It provides a solution for detecting people gathering in public
places such as banks, shopping malls, clinics etc. The concept of person detection algorithm is
used to accurately detect a person’s presence in areas of interest and is then followed by
measuring the distance between the detected persons.
Object Detection
YOLO is used for object detection. You Only Look Once details an object detector capable of
super real-time object detection. YOLO is trained on COCO dataset which includes 80labels
for detection. We use only person class among 80 labels.
Object Tracking
People detected in every frame of vedio is assigned id. Detected object has centroid marked in
every frames and same person is detected.
Distance measurement
The distance between the two centroids is calculated using Euclidean distance, the shorter
distances are detected.
CHAPTER 2
LITERATURE SURVEY
[1] In this proposed system Python, Computer Vision and Deep learning is used to monitor
social distancing at public places and workplaces. As the input video may be taken from an
arbitrary perspective view, the first step is to transform perspective of view to a bird’s-eye (top-
down) view. As the input frames are monocular (taken from a single camera), the simplest
transformation method involves selecting four points in the perspective view which define ROI
where we want to monitor social distancing and mapping them to the corners of a rectangle in
the bird’s-eye view. Also these points should form parallel lines in real world if seen from
above (bird’s eye view). This assumes that every person is standing on the same flat ground
plane. This top view or bird eye view has the property that points are distributed uniformly
horizontally and vertically (scale for horizontal and vertical direction will be different).From
this mapping, we can derive a transformation that can be applied to the entire perspective. It
uses Approach of detecting humans in the frame with yolov3. Then calculate the distance
between every human who is detected in the frame. The output shows how many people are at
High, Low and Not at risk.
[2] The detection model identifies peoples using detected bounding box information. Using the
Euclidean distance, the detected bounding box centroid's pairwise distances of people are
determined. To estimate social distance violations between people, we used an approximation
of physical distance to pixel and set a threshold. A violation threshold is established to evaluate
whether or not the distance value breaches the minimum social distance threshold. In addition,
a tracking algorithm is used to detect individuals in video sequences such that the person who
violates/crosses the social distance threshold is also being tracked.
2.3 Person Detection for Social Distancing and Safety Violation Alert based
on Segmented ROI
[3] This paper presents the detection of people with social distance monitoring as a
precautionary measure in reducing physical contact between people. It focuses on detecting
people in areas of interest using the MobileNet Single Shot Multibox Detector (SSD) object
tracking model and OpenCV library for image processing. The distance will be computed
between the persons detected in the captured footage and then compared to a fixed pixels’
values. The distance is measured between the central points and the overlapping boundary
between persons in the segmented tracking area. With the detection of unsafe distances
between people, alerts or warnings can be issued to keep the distance safe. In addition to social
distance measure, another key feature of the system is detecting the presence of people in
restricted areas, which can also be used to trigger warnings. Here Object Detection is achieved,
by MobileNet SSD due to the short time taken for the execution. Threading Parallelism
incorporated improves the execution time to process the object detection on each frame.
Multithreading approach will be used to run the frame and processing the object detection at
the same time. Masking frame for ROI area estimation is used. Masking is a technique in image
processing which define as a small image piece and use it to modify a larger image. In
determining the position of a person’s bounding box as well as the segment involved, each
ground plane point is used to compare the ROI range. Location of person is thus calculated and
distance between the bounding box is determined.
2.4 Vision-based Social Distancing and Critical Density Detection System for
COVID-19
[4] An active surveillance system capable of detecting distances between individuals and
warning them can slow down the spread of the deadly disease. Furthermore, measuring social
density in a region of interest (ROI) and modulating inflow can decrease social distancing
violation occurrence chance. A monocular camera and deep learning-based real-time object
detectors are used to measure social distancing. If a violation is detected, a non-intrusive audio-
visual warning signal is emitted without targeting the individual who breached the social
distancing measure. Also, if the social density is over a critical value, the system sends a control
signal to modulate inflow into the ROI.
[6] This is a Hybrid Computer Vision and YOLOv4-based Deep Neural Network (DNN)
model for automated people detection in the crowd in indoor and outdoor environments using
common CCTV security cameras. The proposed DNN model in combination with an adapted
inverse perspective mapping (IPM) technique and SORT tracking algorithm leads to a robust
people detection and social distancing monitoring. It is a three-stage model including people
detection, tracking, inter-distance estimation as a total solution for social distancing
monitoring and zone-based infection risk analysis.
CHAPTER 3
METHODOLOGY
The system uses YOLO Object Detector which includes the following features:
To help increase the speed of deep learning-based object detectors, both Single Shot Detectors
(SSDs) and YOLO use a one-stage detector strategy. These algorithms treat object detection as
a regression problem, taking a given input image and simultaneously learning bounding box
coordinates and corresponding class label probabilities. Single-stage detectors tend to be less
accurate than two-stage detectors but are significantly faster. We are using YOLOv3 in
particular, YOLO trained on the COCO dataset. The COCO dataset consists of 80 labels in
which people class is important in the project.
No
Webcam
Input Frame
Initialise Bounding
Box to Green
People
YOLO V3 Detection
No If Index in Yes
Violation Set
Compute
Pre Trained on Pairwise Color Green Color Red
COCO Dataset
Used Centroid
Distance matrix Tracking Algorithm
for People
Display No. of
Violations
Detected Person
Bounding Box
CHAPTER 4
IMPLEMENTATION
define the minimum safe distance (in pixels) that two people can be from each other
MODEL_PATH = "yolo-coco"
MIN_CONF = 0.3
NMS_THRESH = 0.3
USE_GPU = False
MIN_DISTANCE = 50
Social_distance_detector. py
import social_distancing_config
import detect_people from detection
from scipy.spatial import distance
import numpy as np
import argparse
import imutils
import cv2
import os
ap = argparse.ArgumentParser()
ap= add argument path to (optional) input video file
ap= add argument path to (optional) output video file
ap=add argument path whether or not output frame should be displayed
args = parse ap
labelsPath = set path for COCO dataset names of trained YOLO model
LABELS = load COCO class labels
weightsPath = derive the paths to the YOLO weights
CHAPTER 5
RESULTS
We tested our model using video stream and webcam. Of which, we could see the proper
detection of people according to the distance between a pair. Also, the count of the
violations made were counted and were constantly updating.
The results obtained by the model are displayed . The red and green coloured images
displayed indicate if the person is maintaining social distancing or not. Red indicates
violation of social distancing.
While using the webcam, it is necessary to have people moving continuously. Or else the
detection goes incorrect. This could happen due to the detection method, where in the
entire frame is detected, and further, the distance calculation and comparison between the
centroids take place.
CHAPTER 6
Social distancing detector implemented here did not leverage a proper camera calibration. We
could not map distances in pixels to actual measurable units (i.e., meters, feet, etc.).
Therefore, the first step to improving our social distancing detector is to utilize a proper
camera calibration. Distance between the 2 centroid is calculated using, D = (W*F) / P
where, P=Pixel value, F=Focal length, W=Object width, D=Distance between 2 centroid .
Doing so will yield better results and enable to compute actual measurable units (rather than
pixels).
Applying the distance calculations to the top-down view of the pedestrians, leads to a better
distance approximation.
OpenCV’s YOLO implementation is quite slow not because of the model itself but because
of the additional post-processing required by the model. To further speedup the pipeline,
consider utilizing a Single Shot Detector (SSD) running on your GPU — that will improve
frame throughput rate considerably.
CHAPTER 7
CONCLUSION
Social distancing is one of the important precautions in reducing physical contact that may
lead to spread of coronavirus. Consequences of non-compliance with these guidelines will be
causing the higher rates of virus transmission. A system has been developed using Python
and OpenCV library to implement proposed features. The feature is on detecting violations
of social distancing and returning the number of violations.
The study is seen to meet all of its objectives. However, there are limitations to the
results obtained. Based on the tests performed on the system, the results show that the
object detection model used for detecting persons is having the difficulty in detecting people
correctly through webcam with no motion and has not been calibrated to measure the exact
distance. For further improvement in the future, a better object detection model can be
implemented.
The project proposes an efficient framework to automate process of monitoring the social
distancing via object detection and tracking approaches, where each individual is identified
with the help of bounding boxes. The generated bounding boxes aid in identifying the
clusters or groups of people satisfying the closeness property computed with the help of
pairwise vectorized approach.
The number of violations are confirmed by computing the number of groups formed and
violation index term computed as the ratio of the number of people to the number of groups.
This system can be used in CCTV for object detection. The classifier was surveillance
of people during pandemics. Mass screening is possible and hence can be used in crowded
places like railway streets, mall entrances, schools, colleges, etc. By monitoring the distance
between two individuals, we can make sure that an individual is maintaining social distancing
in the right way which will enable us to curb the virus.
Since this application is intended to be used in any working environment; accuracy and
precision is highly desired to serve the purpose. Higher numbers of false positives may raise
discomfort and panic situations among people being observed. There may also be genuinely
raised concerns about privacy and individual rights which can be addressed with some
additional measures such as prior consents for such working environments, hiding a person's
identity in general, maintaining transparency about its fair uses within limited stakeholders.
CHAPTER 8
REFERENCES
[1] Social Distancing Detection System with Artificial Intelligence using Computer Vision
and Deep Learning https://www.irjet.net/archives/V7/i8/IRJET-V7I8698.pdf
[3] Person Detection for Social Distancing and Safety Alert based on Segmented ROI
https://ieeexplore.ieee.org/document/9204934
[4] A Vision-based Social Distancing and Critical Density Detection System for COVID-19
https://www.researchgate.net/publication/342763051
[5] Person detection and tracking via fine-tuned YOLOv3 and Deepsort techniques
https://arxiv.org/pdf/2005.01385.pdf
[6] DeepSOCIAL: Social Distancing Monitoring and Infection Risk Assessment in COVID-19
Pandemic https://www.researchsquare.com/article/rs-68650/v1