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 .

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

### 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

$${}$$