{"id":18412,"date":"2020-07-21T01:57:21","date_gmt":"2020-07-20T20:27:21","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/"},"modified":"2024-09-02T17:02:10","modified_gmt":"2024-09-02T11:32:10","slug":"yolo-object-detection-using-opencv","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/","title":{"rendered":"YOLO object detection using OpenCV"},"content":{"rendered":"\n<ol class=\"wp-block-list\">\n<li><a href=\"#sh1\">What is object detection?<\/a><\/li>\n\n\n\n<li><a href=\"#sh2\">How does object detection work?<\/a><\/li>\n\n\n\n<li><a href=\"#sh3\">What is YOLO object detection?<\/a><\/li>\n\n\n\n<li><a href=\"#sh4\">Overview of\u00a0 YOLO object detection algorithm<\/a><\/li>\n\n\n\n<li><a href=\"#sh5\">Non-Maximum Suppression<\/a> <\/li>\n\n\n\n<li><a href=\"#sh6\">Implementation of YOLO with OpenCV<\/a><\/li>\n\n\n\n<li><a href=\"#sh7\">Custom Object detection with YOLO<\/a><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-object-detection\"><strong>What is Object Detection?<\/strong><br><\/h2>\n\n\n<figure class=\"wp-block-image aligncenter size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1.png\"><img decoding=\"async\" width=\"474\" height=\"266\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1.png\" alt=\"Object detection\" class=\"wp-image-18075\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1.png 474w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1-300x168.png 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/figure>\n\n\n\n<p>Object detection is a computer vision technique in which a software system can detect, locate, and trace the object from a given image or video. The special attribute about object detection is that it identifies the class of object (person, table, chair, etc.) and their location-specific coordinates in the given image. The location is pointed out by drawing a bounding box around the object. The bounding box may or may not accurately locate the position of the object. The ability to locate the object inside an image defines the performance of the algorithm used for detection. Face detection is one of the examples of object detection.<\/p>\n\n\n\n<p>These object detection algorithms might be pre-trained or can be trained from scratch. In most use cases, we use pre-trained weights from pre-trained models and then <a href=\"https:\/\/www.mygreatlearning.com\/blog\/what-is-fine-tuning\/\">fine-tune<\/a> them as per our requirements and different use cases.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-does-object-detection-work\"><strong>How does Object Detection work?<\/strong><br><\/h2>\n\n\n\n<p>In this section, we will briefly go through the different approaches that are taken in Object detection tasks. There are two approaches to Object detection and they are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Two-shot detection.<\/li>\n\n\n\n<li>Single-shot detection.<\/li>\n<\/ol>\n\n\n\n<p>Let us first find about Two-shot detection method. As the name suggests there are two stages involved in this method. One is region proposal and then in the second stage, the classification of those regions and refinement of the location prediction takes place.<\/p>\n\n\n\n<p>Faster-RCNN variants are the popular choice of usage for two-shot models. Here during the region proposal stage, we use a network such as ResNet50 as a feature extractor. We do this by removing the last layers of this network and just use the rest of the layers to extract features from the images. This is usually a better approach as the network is already trained and can extract features from the images. Next, a small fully connected network slides over the feature layer to predict class-agnostic box proposals, with respect to a grid of anchors tiled in space, scale and aspect ratio.<\/p>\n\n\n\n<p>In the second stage, these box proposals are used to crop features from the intermediate feature map which was already computed in the first stage. The proposed boxes are fed to the remainder of the feature extractor in which the prediction and regression heads are added on top of the network. Finally, in the output, we get the class and class-specific box refinement for each proposal box.&nbsp;<br><\/p>\n\n\n\n<p>On the contrary side, Single-shot detection skips the region proposal stage and yields final localization and content prediction at once.YOLO is a popular example of this approach and we are going to discuss the working of it in the coming sections.<br><\/p>\n\n\n\n<p>It must be noted that two-shot detection models achieve better performance but single-shot detection is in the sweet spot of performance and speed\/resources which makes it more suitable for tasks like detecting objects in live feed or object tracking where the speed of prediction is of more importance.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-yolo-object-detection\"><strong>What is YOLO object detection?<br><\/strong><\/h2>\n\n\n\n<p>As mentioned already, YOLO which stands for \u201cYou only look once\u201d is a single shot detection algorithm which was introduced by Joseph Redmon in May 2016. Although the name of the algorithm may sound strange, it gives a perfect description of this algorithm as it predicts classes and bounding boxes for the whole image in one run of the algorithm.<\/p>\n\n\n\n<p>YOLO performed surprisingly well as compared to the other single-shot detectors of that time in terms of speed and accuracy. It is not the most accurate algorithms when it comes to object detection but certainly, it makes that up with its impressive speed and thus is a good balance between speed and accuracy.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"overview-of-yolo-object-detection-algorithm\"><strong>Overview of&nbsp; YOLO object detection algorithm<br><\/strong><\/h2>\n\n\n\n<p>The YOLO network splits the input image into a grid of S\u00d7S cells. If the centre of the ground truth box falls into a cell, that cell is responsible for detecting the existence of that object.&nbsp;<br><\/p>\n\n\n\n<p>Each grid cell predicts B number of bounding boxes and their objectness score along with their class predictions as follows:<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/1q.png\"><img decoding=\"async\" width=\"457\" height=\"457\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/1q.png\" alt=\"yolo object detection\" class=\"wp-image-18414\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/1q.png 457w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/1q-300x300.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/1q-150x150.png 150w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/1q-420x420.png 420w\" sizes=\"(max-width: 457px) 100vw, 457px\" \/><figcaption class=\"wp-element-caption\">Source: Original YOLO research paper<\/figcaption><\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Coordinates of B bounding boxes -YOLO predicts 4 coordinates for each bounding box (bx,by,bw,bh) with respect to the corresponding grid cell. Here bx, by are the x and y coordinates of the midpoint of the object with respect to this grid. The value of bh is the ratio of the height of the bounding box to the height of the corresponding grid cell and bw is the ratio of the width of the bounding box to the width of the grid cell.\u00a0<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Objectness score (P0) - indicates the probability that the cell contains an object. The objectness score is passed through a sigmoid function to be treated as a probability with a value range between 0 and 1.\u00a0<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Class prediction - if the bounding box contains an object, the network predicts the probability of K number of classes. Where K is the total number of classes in your problem.<\/li>\n<\/ol>\n\n\n\n<p>The predicted bounding boxes may look something like the following (the higher the confidence score, the fatter the box is drawn):<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2q.png\"><img decoding=\"async\" width=\"466\" height=\"466\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2q.png\" alt=\"yolo object detection\" class=\"wp-image-18415\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2q.png 466w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2q-300x300.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2q-150x150.png 150w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2q-420x420.png 420w\" sizes=\"(max-width: 466px) 100vw, 466px\" \/><figcaption class=\"wp-element-caption\"> <em>Source: Original YOLO research paper<\/em> <\/figcaption><\/figure>\n\n\n\n<p>Finally, the confidence score for the bounding box and the class prediction are combined into one final score that tells us the probability that this bounding box contains a specific type of object. For example, the big fat yellow box on the left is quite sure it contains the object \u201cdog\u201d:<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3q.png\"><img decoding=\"async\" width=\"458\" height=\"458\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3q.png\" alt=\"yolo object detection\" class=\"wp-image-18416\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3q.png 458w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3q-300x300.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3q-150x150.png 150w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3q-420x420.png 420w\" sizes=\"(max-width: 458px) 100vw, 458px\" \/><figcaption class=\"wp-element-caption\"> <em>Source: Original YOLO research paper<\/em> <\/figcaption><\/figure>\n\n\n\n<p>It turns out that most of these boxes will have very low confidence scores, so we only keep the boxes whose final score is above some threshold. Also, Non-maximum Suppression (NMS) intends to cure the problem of multiple detections of the same image. In the next section, we will briefly go over it. The final prediction is then:<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/5q.png\"><img decoding=\"async\" width=\"458\" height=\"458\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/5q.png\" alt=\"yolo object detection\" class=\"wp-image-18417\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/5q.png 458w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/5q-300x300.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/5q-150x150.png 150w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/5q-420x420.png 420w\" sizes=\"(max-width: 458px) 100vw, 458px\" \/><figcaption class=\"wp-element-caption\"> <em>Source: Original YOLO research paper<\/em> <\/figcaption><\/figure>\n\n\n\n<p>It is important to note that before v3, YOLO used softmax function for the class scores. In v3 the authors have decided to use sigmoid instead. The reason is that Softmax imposes the assumption that each box has exactly one class which is often not the case. In other words, if an object belongs to one class, then it's guaranteed it cannot belong to another class. While this assumption is true for some datasets, it may not work when we have classes like Women and Person. A multilabel approach models the data more accurately. This is the reason that authors have steered clear of using a Softmax activation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"non-maximum-suppression\"><strong>Non-maximum Suppression<br><\/strong><\/h2>\n\n\n\n<p>Non-maximum Suppression or NMS uses the very important function called \"Intersection over Union\", or IoU. Here is how we calculate IoU.<br><\/p>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/08\/q.png\"><img decoding=\"async\" width=\"624\" height=\"143\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/08\/q.png\" alt=\"\" class=\"wp-image-18748\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/08\/q.png 624w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/08\/q-300x69.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><figcaption class=\"wp-element-caption\"> <em>IoU for two overlapping boxes<\/em> <\/figcaption><\/figure>\n\n\n\n<p>We define a box using its two corners (upper left and lower right): (<em>x1, y1, x2, y2<\/em>) rather than the midpoint and height\/width. Next, we also need to find the coordinates (<em>xi1, yi1, xi2, yi2<\/em>) of the intersection of two boxes where :<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">xi1 = maximum of the x1 coordinates of the two boxes\nyi1 = maximum of the y1 coordinates of the two boxes\nxi2 = minimum of the x2 coordinates of the two boxes\nyi2 = minimum of the y2 coordinates of the two boxes <\/pre>\n\n\n\n<p>Note that to calculate the area a rectangle (or a box) we can to multiply its height (y2 - y1) by its width (x2 - x1).<\/p>\n\n\n\n<p>So to calculate IoU, first calculate the area of intersection by this formula<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">area_intersection =(xi2 - xi1)*(yi2 - yi1)<\/pre>\n\n\n\n<p>Next, calculate the area of union<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">union _area = (area of box 1 + area of box 2) - area_intersection<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Therefore IoU=area_intersection\/union_area<\/pre>\n\n\n\n<p>Now, to implement non-max suppression, the steps are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Select the box that has the highest score.<\/li>\n\n\n\n<li>Compute its overlap with all other boxes, and remove boxes that overlap it more than a certain threshold which we call iou_threshold.<\/li>\n\n\n\n<li>Go back to step 1 and iterate until there are no more boxes with a lower score than the currently selected box<\/li>\n<\/ol>\n\n\n\n<p>These steps will remove all boxes that have a large overlap with the selected boxes. Only the best boxes remain.<br><\/p>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Untitled-document-1.png\"><img decoding=\"async\" width=\"643\" height=\"317\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Untitled-document-1.png\" alt=\"YOLO object detection\" class=\"wp-image-18426\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Untitled-document-1.png 643w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Untitled-document-1-300x148.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/Untitled-document-1-324x160.png 324w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><figcaption class=\"wp-element-caption\">Before and after applying NMS<\/figcaption><\/figure>\n\n\n\n<p><strong><em><a href=\"https:\/\/www.kaggle.com\/mirzamujtaba\/yolo-object-detection-using-keras\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Click here to see the Keras Implementation of YOLO algorithm (opens in a new tab)\">Click here to see the Keras Implementation of YOLO algorithm<\/a><\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"implementation-of-yolo-with-opencv\"><strong>Implementation of YOLO with OpenCV<br><\/strong><\/h2>\n\n\n\n<p>There are various implementations of YOLO algorithm and perhaps most popular of them is the Darknet. But here we are going to use OpenCV to implement YOLO algorithm as it is really simple. To get started you need to install OpenCV on your Pc using this command in you command prompt.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install opencv-python<\/code><\/pre>\n\n\n\n<p>To use YOLO via OpenCV, we need three files viz -\u2019yoloV3.weights\u2019, \u2018yoloV3.cfg\u2019 and \u201ccoco.names\u201d ( contain all the names of the labels on which this model has been trained on).Click on them o download and then save the files in a single folder. Now open a python script in this folder and start coding:<\/p>\n\n\n\n<p>First, we are going to load the model using the function \u201ccv2.dnn.ReadNet()\u201d.This function loads the network into memory and automatically detects configuration and framework based on file name specified.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import cv2\nimport numpy as np\n\n# Load Yolo\nprint(\"LOADING YOLO\")\nnet = cv2.dnn.readNet(\"yolov3.weights\", \"yolov31.cfg\")\n#save all the names in file o the list classes\nclasses = &#91;]\nwith open(\"coco.names\", \"r\") as f:\n    classes = &#91;line.strip() for line in f.readlines()]\n#get layers of the network\nlayer_names = net.getLayerNames()\n#Determine the output layer names from the YOLO model \noutput_layers = &#91;layer_names&#91;i&#91;0] - 1] for i in net.getUnconnectedOutLayers()]\nprint(\"YOLO LOADED\")\n<\/code><\/pre>\n\n\n\n<p>After loading the model now either we can use it detects objects in an image or you can even use it for real-time object detection for which you are going to need a PC with good processing speed.<\/p>\n\n\n\n<p>Here is the code to detect&nbsp; objects in images&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> # Capture frame-by-frame\n    img = cv2.imread(\"test_img.jpg\")\n#     img = cv2.resize(img, None, fx=0.4, fy=0.4)\n    height, width, channels = img.shape\n\n    # USing blob function of opencv to preprocess image\n    blob = cv2.dnn.blobFromImage(img, 1 \/ 255.0, (416, 416),\n     swapRB=True, crop=False)\n    #Detecting objects\n    net.setInput(blob)\n    outs = net.forward(output_layers)\n\n    # Showing informations on the screen\n    class_ids = &#91;]\n    confidences = &#91;]\n    boxes = &#91;]\n    for out in outs:\n        for detection in out:\n            scores = detection&#91;5:]\n            class_id = np.argmax(scores)\n            confidence = scores&#91;class_id]\n            if confidence &gt; 0.5:\n                # Object detected\n                center_x = int(detection&#91;0] * width)\n                center_y = int(detection&#91;1] * height)\n                w = int(detection&#91;2] * width)\n                h = int(detection&#91;3] * height)\n\n                # Rectangle coordinates\n                x = int(center_x - w \/ 2)\n                y = int(center_y - h \/ 2)\n\n                boxes.append(&#91;x, y, w, h])\n                confidences.append(float(confidence))\n                class_ids.append(class_id)\n    \n    #We use NMS function in opencv to perform Non-maximum Suppression\n    #we give it score threshold and nms threshold as arguments.\n    indexes = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4)\n    colors = np.random.uniform(0, 255, size=(len(classes), 3))\n    for i in range(len(boxes)):\n        if i in indexes:\n            x, y, w, h = boxes&#91;i]\n            label = str(classes&#91;class_ids&#91;i]])\n            color = colors&#91;class_ids&#91;i]]\n            cv2.rectangle(img, (x, y), (x + w, y + h), color, 2)\n            cv2.putText(img, label, (x, y -5),cv2.FONT_HERSHEY_SIMPLEX,\n\t\t\t1\/2, color, 2)\n\n    cv2.imshow(\"Image\",img)\n    cv2.waitKey(0)<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<figure class=\"wp-block-gallery alignfull has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/test_img.jpg\"><img decoding=\"async\" width=\"474\" height=\"272\" data-id=\"18419\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/test_img.jpg\" alt=\"\" class=\"wp-image-18419\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/test_img.jpg 474w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/test_img-300x172.jpg 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><figcaption class=\"wp-element-caption\">INPUT<\/figcaption><\/figure>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/10q.png\"><img decoding=\"async\" width=\"474\" height=\"271\" data-id=\"18420\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/10q.png\" alt=\"\" class=\"wp-image-18420\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/10q.png 474w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/10q-300x172.png 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><figcaption class=\"wp-element-caption\">OUTPUT<\/figcaption><\/figure>\n<\/figure>\n\n\n\n<p> <strong><em><a rel=\"noreferrer noopener\" href=\"https:\/\/www.kaggle.com\/mirzamujtaba\/yolo-object-detection-using-keras\" target=\"_blank\">Click here to see the Keras Implementation of YOLO algorithm<\/a><\/em><\/strong> <\/p>\n\n\n\n<p>Here is the code to detect&nbsp; objects in real-time using webcam<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>video_capture = cv2.VideoCapture(0)\nwhile True:\n    # Capture frame-by-frame\n    re,img = video_capture.read()\n    img = cv2.resize(img, None, fx=0.4, fy=0.4)\n    height, width, channels = img.shape\n\n    # USing blob function of opencv to preprocess image\n    blob = cv2.dnn.blobFromImage(img, 1 \/ 255.0, (416, 416),\n     swapRB=True, crop=False)\n    #Detecting objects\n    net.setInput(blob)\n    outs = net.forward(output_layers)\n\n    # Showing informations on the screen\n    class_ids = &#91;]\n    confidences = &#91;]\n    boxes = &#91;]\n    for out in outs:\n        for detection in out:\n            scores = detection&#91;5:]\n            class_id = np.argmax(scores)\n            confidence = scores&#91;class_id]\n            if confidence &gt; 0.5:\n                # Object detected\n                center_x = int(detection&#91;0] * width)\n                center_y = int(detection&#91;1] * height)\n                w = int(detection&#91;2] * width)\n                h = int(detection&#91;3] * height)\n\n                # Rectangle coordinates\n                x = int(center_x - w \/ 2)\n                y = int(center_y - h \/ 2)\n\n                boxes.append(&#91;x, y, w, h])\n                confidences.append(float(confidence))\n                class_ids.append(class_id)\n    \n    #We use NMS function in opencv to perform Non-maximum Suppression\n    #we give it score threshold and nms threshold as arguments.\n    indexes = cv2.dnn.NMSBoxes(boxes, confidences, 0.5, 0.4)\n    font = cv2.FONT_HERSHEY_PLAIN\n    colors = np.random.uniform(0, 255, size=(len(classes), 3))\n    for i in range(len(boxes)):\n        if i in indexes:\n            x, y, w, h = boxes&#91;i]\n            label = str(classes&#91;class_ids&#91;i]])\n            color = colors&#91;class_ids&#91;i]]\n            cv2.rectangle(img, (x, y), (x + w, y + h), color, 2)\n            cv2.putText(img, label, (x, y + 30), font, 2, color, 3)\n\n    cv2.imshow(\"Image\",cv2.resize(img, (800,600)))\n    if cv2.waitKey(1) &amp; 0xFF == ord('q'):\n        break\nvideo_capture.release()\ncv2.destroyAllWindows()<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Real-time Object Detection Using TensorFlow object detection API (opens in a new tab)\"><strong><em>Real-time<\/em><\/strong> <strong><em>Object Detection Using TensorFlow object detection API<\/em><\/strong><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"custom-object-detection-with-yolo\"><strong>Custom Object detection with YOLO<\/strong><\/h2>\n\n\n\n<p>In this section, we will see how we can create our own custom YOLO object detection model which can detect objects according to our preference. Here I am going to show how we can detect a specific bird known as Alexandrine parrot using YOLO. Note that this model can only detect the parrot but we can train it to detect more than one object.<br><\/p>\n\n\n\n<p>The first thing we need is images of parrots. We can download them manually from the internet but that is really slow and tiring. Alternatively, you can use tools which are freely available on GitHub. Here is <a href=\"https:\/\/github.com\/hardikvasa\/google-images-download\">one<\/a> that you can use and you can find the instructions to use it from the same&nbsp; GitHub page. You need to download at least 300 images to get decent results.<br><\/p>\n\n\n\n<p>Next, we need to manually label each image with the location of the parrots in the images. We can use a tool labelImg for this and it can make our work really easy but still it is going to take time as we have to do this manually. Remember to change the settings and keep it for YOLO as I will point out in the video below. Before moving forward make sure that all your images are in the same folder and the folder contains only the images we want.<\/p>\n\n\n\n<p>Now zip the folder which contains all the images along with the .txt files containing the location of the object and upload them to your google drive. Also, make a folder in your drive by the name of yolov3 and place the zip file in that folder.<br><\/p>\n\n\n\n<p>Next, open this <a href=\"https:\/\/colab.research.google.com\/drive\/1VVnPN-cL1aRo4GtotEeTucNQrTdiNY4l?usp=sharing\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Colab Notebook (opens in a new tab)\">Colab Notebook<\/a> via your account and run all the cells. Be sure to change all the paths according to your files or you can change the name of the zip folder of your data to \u2018logo\u2019 as I have, and then you don\u2019t need to change anything.&nbsp;<br><\/p>\n\n\n\n<p>It may take around 5-6 hours before you can see your average loss touching 0.1 and then you can stop the training but interrupting the cell. You will see the new weights file in the yolov3 folder of your google drive.<\/p>\n\n\n\n<p>Now all you need to do is modify the above code and you have your custom object detector. Just replace the weights with the new weights we got after training and just put one item i.e \"Alexandrine parrot\"  in classes list.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\"><figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/7.jpg\"><img decoding=\"async\" width=\"300\" height=\"168\" data-id=\"18431\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/7.jpg\" alt=\"\" class=\"wp-image-18431\"><figcaption class=\"wp-element-caption\">Input<\/figcaption><\/figure>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/7-1.jpg\"><img decoding=\"async\" width=\"300\" height=\"168\" data-id=\"18432\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/7-1.jpg\" alt=\"\" class=\"wp-image-18432\"><figcaption class=\"wp-element-caption\">Output<\/figcaption><\/figure>\n<\/figure>\n\n\n\n<p>This brings us to the end of this article where we learned what is YOLO and how can we can use OpenCV to implement YOLO. To get a free course on Computer vision, click the banner below. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Object Detection? Object detection is a computer vision technique in which a software system can detect, locate, and trace the object from a given image or video. The special attribute about object detection is that it identifies the class of object (person, table, chair, etc.) and their location-specific coordinates in the given image. [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":18423,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2],"tags":[],"content_type":[],"class_list":["post-18412","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-artificial-intelligence"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Object Detection Using OpenCV YOLO | Great Learning<\/title>\n<meta name=\"description\" content=\"Object Detection Using OpenCV YOLO: YOLO which stands for \u201cYou only look once\u201d is a single shot detection algorithm which was introduced by Joseph Redmon in May 2016.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"YOLO object detection using OpenCV\" \/>\n<meta property=\"og:description\" content=\"Object Detection Using OpenCV YOLO: YOLO which stands for \u201cYou only look once\u201d is a single shot detection algorithm which was introduced by Joseph Redmon in May 2016.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-20T20:27:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-02T11:32:10+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"YOLO object detection using OpenCV\",\"datePublished\":\"2020-07-20T20:27:21+00:00\",\"dateModified\":\"2024-09-02T11:32:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/\"},\"wordCount\":2000,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/shutterstock_591808460.jpg\",\"articleSection\":[\"AI and Machine Learning\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/\",\"name\":\"Object Detection Using OpenCV YOLO | Great Learning\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/shutterstock_591808460.jpg\",\"datePublished\":\"2020-07-20T20:27:21+00:00\",\"dateModified\":\"2024-09-02T11:32:10+00:00\",\"description\":\"Object Detection Using OpenCV YOLO: YOLO which stands for \u201cYou only look once\u201d is a single shot detection algorithm which was introduced by Joseph Redmon in May 2016.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/shutterstock_591808460.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/shutterstock_591808460.jpg\",\"width\":1000,\"height\":600,\"caption\":\"yolo object detection\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/yolo-object-detection-using-opencv\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AI and Machine Learning\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/artificial-intelligence\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"YOLO object detection using OpenCV\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Object Detection Using OpenCV YOLO | Great Learning","description":"Object Detection Using OpenCV YOLO: YOLO which stands for \u201cYou only look once\u201d is a single shot detection algorithm which was introduced by Joseph Redmon in May 2016.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/","og_locale":"en_US","og_type":"article","og_title":"YOLO object detection using OpenCV","og_description":"Object Detection Using OpenCV YOLO: YOLO which stands for \u201cYou only look once\u201d is a single shot detection algorithm which was introduced by Joseph Redmon in May 2016.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2020-07-20T20:27:21+00:00","article_modified_time":"2024-09-02T11:32:10+00:00","og_image":[{"width":1000,"height":600,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"YOLO object detection using OpenCV","datePublished":"2020-07-20T20:27:21+00:00","dateModified":"2024-09-02T11:32:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/"},"wordCount":2000,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg","articleSection":["AI and Machine Learning"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/","url":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/","name":"Object Detection Using OpenCV YOLO | Great Learning","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg","datePublished":"2020-07-20T20:27:21+00:00","dateModified":"2024-09-02T11:32:10+00:00","description":"Object Detection Using OpenCV YOLO: YOLO which stands for \u201cYou only look once\u201d is a single shot detection algorithm which was introduced by Joseph Redmon in May 2016.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg","width":1000,"height":600,"caption":"yolo object detection"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"AI and Machine Learning","item":"https:\/\/www.mygreatlearning.com\/blog\/artificial-intelligence\/"},{"@type":"ListItem","position":3,"name":"YOLO object detection using OpenCV"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg",1000,600,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460-300x180.jpg",300,180,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460-768x461.jpg",768,461,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg",1000,600,false],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg",1000,600,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg",1000,600,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg",640,384,false],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg",96,58,false],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_591808460.jpg",150,90,false]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":1,"uagb_excerpt":"What is Object Detection? Object detection is a computer vision technique in which a software system can detect, locate, and trace the object from a given image or video. The special attribute about object detection is that it identifies the class of object (person, table, chair, etc.) and their location-specific coordinates in the given image.&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/18412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=18412"}],"version-history":[{"count":16,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/18412\/revisions"}],"predecessor-version":[{"id":106821,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/18412\/revisions\/106821"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/18423"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=18412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=18412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=18412"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=18412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}