Hey folks!! In my previous blog, we have created a social distance monitoring tool using SSD object detection algorithm. You may access my previous article here.

In this article, we will be looking at ways to improve the results by trying another SOTA model, i.e., YOLO v3. 

Setting up YOLO model with pre-trained weights

You Only Look Once or more popularly known as YOLO is one of the fastest real-time object detection algorithms. Weights and cfg files for YOLO v3 can be downloaded from https://pjreddie.com/darknet/yolo .

I have used the readNetFromDarknet() method in OpenCV to load the saved weights into the network. If you are having difficulty in setting up YOLO weights for your model then you can refer this article to learn more.

Pedestrian Detection and Localization

I have used the YOLOv3 model that is trained on the COCO dataset to detect the pedestrians and create bounding boxes around them by using the “Person” class in COCO dataset.

Marking region of interest and distance scale

  • In my previous post, we were using a 4 point marking system to create a polygon denoting the region of interest. We were then asking the user to mark 2 points to get the distance scale for 6 feet.
  • We are following a similar approach this time also except that we have added an extra point to mark both the vertical and horizontal distance scale separately.

 

  • Now, we’ll compute the distance between every pair of people in the frame and mark the ones who are too close to each other, i.e., in the range of 6 feet from each other.
  • I have marked the people in green that are at safe distances, yellow if they are moderately close, and red if they are violating the social distancing.

  • Lastly, I have drawn lines between the bounding boxes and marked them in respective colors according to danger to make it more intuitive.

We could see that the YOLOv3 model performed significantly slower than the SSD model but it was more accurate.

Outcome

To download YOLO weights, you can click here.

To access the source code, click here.

Conclusion

It was a fun experience learning about different object detection models and seeing how different they are with each other. I learnt about different techniques like creating bird’s eye view, perspective transformation and testing the advantages and disadvantages of different Object Detection Models.

Looking forward to creating more practical solutions with what I learnt from this!

Roshan Mishra


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Insert math as
Block
Inline
Additional settings
Formula color
Text color
#333333
Type math using LaTeX
Preview
\({}\)
Nothing to preview
Insert