YOLO With OpenCV

Ishan Mazumder
The Startup
Published in
2 min readAug 19, 2020

Multiple object detection

You only look once

Today we will look at how we can use YOLO in OpenCV framework.
YOLO first came out in 2016, which is used for multiple object detection.
Its compatible with OpenCV framework but we need to download “yolov3.weights” and also “yolov3.cfg”. I have uploaded these file along with the code on my github repo.

Lets go through the code now, its fairly simple.
So the first step would be to import the model and read “coco.names” which contains the image labels and get the output layer.

Next thing would be to read the input image, and create blob to extract the features from the input image. The input dimension of the image was 416*416 and (0,0,0) signifies the color space of the image.

We will loop through the blob and find out the objects which has been detected. But before that we have to feed blob to the yolo algorithm and extract its features from the output layer. We can relate it to a CNN model.
Also we are interested in object with more than 50% confidence prediction.

The challenge is to separate out the redundant object which the algorithm detects. Finally we can create a bounding box and display the image.

I hope the article was useful to understand how we can use YOLO in OpenCV framework. You can get the code and the necessary files on my git account.

Thanks for reading!

--

--