DEV Community

Social Distancing Analyzer using OpenCV and YOLO

Sherwyn D'souza on July 09, 2020

Introduction Social distancing is deliberately increasing the physical space between people to avoid spreading illness. Staying at lea...
Collapse
 
hemantsain55 profile image
Hemant Kumar Sain
    writer = cv2.VideoWriter(OUTPUT_PATH, fourcc, 30,(frame.shape[1], frame.shape[0]), True)
Enter fullscreen mode Exit fullscreen mode

throwing error on google colab

'NoneType' object has no attribute 'shape'

kindly help

Collapse
 
sakshipardeshi profile image
Sakshi Pardeshi

I'm getting the same error. Were you able to resolve it Hemant?

Collapse
 
sherwyn11 profile image
Sherwyn D'souza

Hey! I ran the code on Google Colab and the code ran without any error. I think something went wrong while processing the frame.

Collapse
 
drk_babu profile image
DRK BABU👑

hey plz send that code i need it

Thread Thread
 
sherwyn11 profile image
Sherwyn D'souza
Collapse
 
kodumuri369 profile image
Kodumuri sai Krishna

can you share limitations and importance of the project

Collapse
 
sherwyn11 profile image
Sherwyn D'souza

Limitations:
This project does not take into account the camera perspective.
It does not leverage a proper camera calibration (Distances are not measure accurate).

Importance:
Social distancing is deliberately increasing the physical space between people to avoid spreading illness. Staying at least six feet away from other people lessens your chances of contracting COVID-19. We can use OpenCV and YOLO to monitor/analyze whether people are maintaining social distancing or not. It could be used for just keeping a track whether people are maintaining social distancing.

Collapse
 
ashgrey profile image
ashg

hi may i know the 60 in safe distance is in what unit? and how you determine it?

Thread Thread
 
sherwyn11 profile image
Sherwyn D'souza

Hi... As I have said in the limitations, this project does not take into consideration actual perspective. So, the 60 is just a rough estimate for safe estimate for this camera angle.

Collapse
 
pushpak1300 profile image
Pushpak Chhajed

Awesome! :o

Collapse
 
sherwyn11 profile image
Sherwyn D'souza

Thank you :)

Collapse
 
masterhareesh profile image
masterhareesh

where is the constant.py file bruh!!!

Collapse
 
sherwyn11 profile image
Sherwyn D'souza • Edited

I've attached a file directory structure image above. So create a constants.py file accordingly and then add this:

YOLOV3_LABELS_PATH = './yolov3/coco.names'
YOLOV3_CFG_PATH = './yolov3/yolov3.cfg'
YOLOV3_WEIGHTS_PATH = './yolov3/yolov3.weights'
VIDEO_PATH = './videos/video.mp4'
OUTPUT_PATH = './output/output.avi'
SAFE_DISTANCE = 60
Enter fullscreen mode Exit fullscreen mode