You are on page 1of 4

Social Distancing using face detection

What is social distancing and why it is needed ?


Social Distancing is a buzz word in this pandemic situation. It is viewed as an one of
the best method to avoid getting contaminated from corona virus. Social Distancing
is a way to maintain distance between humans, so that one does not comes across
any other human who is contaminated. This prevents many people getting sick at the
same time.

Role of Artificial Intelligence in measuring social distancing


Data Scientists and AI Engineers all around the globe are researching and
developing projects in order to fight against covid 19 and make things simpler and
easier. Some of them are

 Offices need monitoring devices to ensure that social distancing is maintained


among people.
 Detecting whether a patient is covid 19 positive or not using AI by training a
model using CT Scans or x-ray of previous patients.
 CCTV Detection system for governments to ensure social distancing and alert
police before no. of people increases in an area

This Example
In this example, we will be detecting human faces in an image and find out distance
between them, displaying people whose faces are too close to each other.  

Original Image

CODE
OPEN CV - a library of programming functions mainly aimed at real-time computer
vision.

1. Firstly, we will import two libraries math and cv2.


2. Then we will load the pre-trained haar cascade model, which is an xml file,
using cascade classifier.
3. Then image is read and converted into gray scale image using cvtColor()
function.
4. Then we detect the faces using detectMultiScale function.
5. Detect MultiScale Parameters : 

 In detectMultiScale, the first parameter passed is the image name.


 The second parameter passed is the scale factor, which is a parameter
specifying how much the image size is reduced at each image scale.
 The minNeighbors, specifies how many neighbors each candidate rectangle
should have to retain it.
 minSize is the minimum possible object size. Objects smaller than that are
ignored.

ADVANCE VERSION
This method has a lot of disadvantages. 

 It will only work with faces. 


 In real life scenarios, people will not be facing the camera face-to-face, so in
that case it won't detect every person.
 It does not ensures physical touch is there or not

So, now we will detect full person and then calculate the distance between them.

ADVANCED VERSION OUTPUT


The green rectangle is the humans detected and the red line shows that these
humans are not following social distancing or are too close to each other. 

Several governments and Industries in view of COVID 19 situation now wants to ensure that
social distancing is followed or not. This is a human detection system which checks
whether social distancing is followed or not and produces an alert in case it is not followed.

Social Distance Alert System


What is Social Distancing ?
Social Distancing is methodology in which humans stay away from each other
physically. For example, in current COVID-19 situation it is being followed widely, in
order to prevent the spread of the disease. 

Why do we need Social Distancing ?


In order to slow down the spread of the corona virus we need some preventive
measure. If people don't come in contact with each other the chances of the disease
being transmitted reduces at a significant level.

Social Distancing Alert System 


1. This system detects humans in the video and finds out distance between
them. 
2. If they are walking too close by it shows a red line between them. 
3. It also counts number of humans in each frame and raises an alert in case no.
of people increases in a particular frame. 
4. It saves the frames in two folders.
5. In first folder all the frames are saved from the video.
6. In second folder only those frames are saved in which count of people
exceeds a particular value.

Problem statement:

The problem Social Distancing Detector solves

People can use it for such situations like standing in queue and wants to
detect person after him is atleast 6 feet distance like for ulitmate solution of
coronavirus situation.It makes person notified and user can ask the nearby
person to be at some distance far from him. It also makes the problem
more easier by examining whether you have corona symptoms or not
through self assessment test. It make the authorities to even use in public
areas as it tracks the person from live camera lies at public places to detect
the person in nearby shops standing with some distance apart and stores
the captured images if we have ram available.

The technical methodology of this tool involves three main steps, which are: 

 Calibration 
 Detection and 
 Measurement. 

Calibration
Calibration is the first step of the pipeline, which works by computing the transform,
specifically the homography that morphs a perspective view into a bird’s-eye view. In the
above video, we can notice an instance of the birds-eye view at the right corner.

In this process, the simplest calibration method involves selecting four points in the
perspective view and mapping them to the corners of a rectangle in the bird’s-eye view. The
process assumes that every person is standing on the same flat ground plane. 

Detection
Detection is the second step of the pipeline that involves applying a pedestrian detector to the
perspective views to draw a bounding box around each pedestrian. For this process, the
company used an open-source pedestrian detection network based on the Faster R-CNN
architecture, non-max suppression (NMS), and various rule-based heuristics. Non-max
suppression (NMS) and various rule-based heuristics have been applied to clean up the output
bounding boxes.  

Measurement
This is the third step of the pipeline, where the (x, y) location of the bounding box for each
person has been estimated in the bird’s-eye view. According to the company, the last step is
to compute the bird’s eye view distance between every pair of people and scale the distances
by the scaling factor estimated from calibration. The people whose distance is below the
minimum acceptable distance has been depicted in red, and the rest are coloured as green,
and a line is drawn between the people to emphasize this measure. 

You might also like