{"id":336342,"date":"2022-07-29T09:00:24","date_gmt":"2022-07-29T09:00:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=336342"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=336342","title":{"rendered":"<span>\u041f\u043e\u0438\u0441\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u043f\u043e\u0438\u0441\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python \u0438 OpenCV. \u041f\u043e\u043c\u0438\u043c\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0432\u0438\u0434\u0435\u043e, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0430\u043c\u0435\u0440\u044b.  <\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438 \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 \u043c\u043e\u0435\u043c\u00a0<a href=\"https:\/\/github.com\/paveldat\/object_detection_on_video\" rel=\"noopener noreferrer nofollow\">Github<\/a>.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; <a href=\"https:\/\/habr.com\/ru\/post\/678644\/\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0438\u0441\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0444\u043e\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python<\/a>. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0435\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435, \u044f \u0440\u0430\u0441\u043f\u0438\u0448\u0443 \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e \u043d\u043e\u0432\u043e\u0439.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code>pip install opencv-python pip install numpy pip install art<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 YOLO \u0438 \u043e\u0442\u043c\u0435\u0447\u0430\u0442\u044c \u0438\u0445.<\/p>\n<p>\u0421\u043a\u0430\u0447\u0430\u0435\u043c \u0441 \u043c\u043e\u0435\u0433\u043e\u00a0<a href=\"https:\/\/github.com\/paveldat\/object_detection_on_video\/tree\/main\/Resources\" rel=\"noopener noreferrer nofollow\">Github<\/a>\u00a0\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e\u00a0<code>Resources<\/code>\u00a0\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430\u0448\u0430 \u0431\u0443\u0434\u0443\u0449\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430:<\/p>\n<pre><code>'person', 'bicycle', 'car', 'motorbike', 'aeroplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'sofa', 'pottedplant', 'bed', 'diningtable', 'toilet', 'tvmonitor', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code>import cv2 import numpy as np from art import tprint<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f YOLO. \u0421 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438\u0445 \u0433\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438.<\/p>\n<pre><code class=\"python\">def apply_yolo_object_detection(image_to_process):     \"\"\"     Recognition and determination of the coordinates of objects on the image     :param image_to_process: original image     :return: image with marked objects and captions to them     \"\"\" height, width, _ = image_to_process.shape blob = cv2.dnn.blobFromImage(image_to_process, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">1&lt;\/span> \/ &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">255&lt;\/span>, (&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">608&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">608&lt;\/span>),                              (&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>), swapRB=&lt;span class=\"hljs-literal\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">True&lt;\/span>, crop=&lt;span class=\"hljs-literal\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">False&lt;\/span>) net.setInput(blob) outs = net.forward(out_layers) class_indexes, class_scores, boxes = ([] &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">for&lt;\/span> i &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">in&lt;\/span> range(&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">3&lt;\/span>)) objects_count = &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>  &lt;span class=\"hljs-comment\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(142, 144, 140); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\"># Starting a search for objects in an image&lt;\/span> &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">for&lt;\/span> out &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">in&lt;\/span> outs:     &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">for&lt;\/span> obj &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">in&lt;\/span> out:         scores = obj[&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">5&lt;\/span>:]         class_index = np.argmax(scores)         class_score = scores[class_index]         &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">if&lt;\/span> class_score &amp;gt; &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>:             center_x = int(obj[&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>] * width)             center_y = int(obj[&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">1&lt;\/span>] * height)             obj_width = int(obj[&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">2&lt;\/span>] * width)             obj_height = int(obj[&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">3&lt;\/span>] * height)             box = [center_x - obj_width \/\/ &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">2&lt;\/span>, center_y - obj_height \/\/ &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">2&lt;\/span>,                    obj_width, obj_height]             boxes.append(box)             class_indexes.append(class_index)             class_scores.append(float(class_score))  &lt;span class=\"hljs-comment\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(142, 144, 140); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\"># Selection&lt;\/span> chosen_boxes = cv2.dnn.NMSBoxes(boxes, class_scores, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0.0&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0.4&lt;\/span>) &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">for&lt;\/span> box_index &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">in&lt;\/span> chosen_boxes:     box_index = box_index     box = boxes[box_index]     class_index = class_indexes[box_index]      &lt;span class=\"hljs-comment\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(142, 144, 140); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\"># For debugging, we draw objects included in the desired classes&lt;\/span>     &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">if&lt;\/span> classes[class_index] &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">in&lt;\/span> classes_to_look_for:         objects_count += &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">1&lt;\/span>         image_to_process = draw_object_bounding_box(image_to_process,                                                     class_index, box)  final_image = draw_object_count(image_to_process, objects_count) &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">return&lt;\/span> final_image  <\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0431\u0432\u0435\u0434\u0435\u0442 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0433\u0440\u0430\u043d\u0438\u0446, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00a0<code>apply_yolo_object_detection<\/code>:<\/p>\n<pre><code class=\"python\">def draw_object_bounding_box(image_to_process, index, box): \"\"\" Drawing object borders with captions :param image_to_process: original image :param index: index of object class defined with YOLO :param box: coordinates of the area around the object :return: image with marked objects \"\"\" x, y, w, h = box start = (x, y) end = (x + w, y + h) color = (&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">255&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>) width = &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">2&lt;\/span> final_image = cv2.rectangle(image_to_process, start, end, color, width)  start = (x, y - &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">10&lt;\/span>) font_size = &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">1&lt;\/span> font = cv2.FONT_HERSHEY_SIMPLEX width = &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">2&lt;\/span> text = classes[index] final_image = cv2.putText(final_image, text, start, font,                           font_size, color, width, cv2.LINE_AA)  &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">return&lt;\/span> final_image  <\/code><\/pre>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"python\">def draw_object_count(image_to_process, objects_count): \"\"\" Signature of the number of found objects in the image :param image_to_process: original image :param objects_count: the number of objects of the desired class :return: image with labeled number of found objects \"\"\" start = (&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">10&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">120&lt;\/span>) font_size = &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">1.5&lt;\/span> font = cv2.FONT_HERSHEY_SIMPLEX width = &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">3&lt;\/span> text = &lt;span class=\"hljs-string\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(113, 140, 0); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">\"Objects found: \"&lt;\/span> + str(objects_count)  &lt;span class=\"hljs-comment\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(142, 144, 140); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\"># Text output with a stroke&lt;\/span> &lt;span class=\"hljs-comment\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(142, 144, 140); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\"># (so that it can be seen in different lighting conditions of the picture)&lt;\/span> white_color = (&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">255&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">255&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">255&lt;\/span>) black_outline_color = (&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>) final_image = cv2.putText(image_to_process, text, start, font, font_size,                           black_outline_color, width * &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">3&lt;\/span>, cv2.LINE_AA) final_image = cv2.putText(final_image, text, start, font, font_size,                           white_color, width, cv2.LINE_AA)  &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">return&lt;\/span> final_image&lt;\/code>&lt;\/pre>&lt;!--EndFragment-->   <\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u043f\u043e \u043a\u0430\u0434\u0440\u0430\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<pre><code class=\"python\">def start_video_object_detection(video: str):     \"\"\"     Real-time video capture and analysis     \"\"\"      while True:         try:             # Capturing a picture from a video             video_camera_capture = cv2.VideoCapture(video)                          while video_camera_capture.isOpened():                 ret, frame = video_camera_capture.read()                 if not ret:                     break                                  # Application of object recognition methods on a video frame from YOLO                 frame = apply_yolo_object_detection(frame)                                  # Displaying the processed image on the screen with a reduced window size                 frame = cv2.resize(frame, (1920 \/\/ 2, 1080 \/\/ 2))                 cv2.imshow(\"Video Capture\", frame)                 cv2.waitKey(1)                          video_camera_capture.release()             cv2.destroyAllWindows()              except KeyboardInterrupt:             pass<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043a\u0440\u0430\u043d\u0430 \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043b\u044e\u0431\u043e\u0439 \u043a\u043b\u0430\u0432\u0438\u0448\u0438:<\/p>\n<pre><code class=\"python\">def start_video_object_detection(video: str):     \"\"\"     Real-time video capture and analysis     \"\"\"      while True:         try:             # Capturing a picture from a video             video_camera_capture = cv2.VideoCapture(video)                          while video_camera_capture.isOpened():                 ret, frame = video_camera_capture.read()                 if not ret:                     break                                  # Application of object recognition methods on a video frame from YOLO                 frame = apply_yolo_object_detection(frame)                                  # Displaying the processed image on the screen with a reduced window size                 frame = cv2.resize(frame, (1920 \/\/ 2, 1080 \/\/ 2))                 cv2.imshow(\"Video Capture\", frame)                 cv2.waitKey(0):                 break                          video_camera_capture.release()             cv2.destroyAllWindows()              except KeyboardInterrupt:             pass<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>main<\/code>, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043d\u043e \u044f \u0437\u0430\u0445\u043e\u0442\u0435\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:<\/p>\n<pre><code class=\"python\"># Logo     tprint(\"Object detection\")     tprint(\"by\")     tprint(\"paveldat\")<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<code>main<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043d\u0430\u0448\u0443 \u0441\u0435\u0442\u044c:  <\/p>\n<pre><code class=\"python\">if __name__ == '__main__': # Loading YOLO scales from files and setting up the network     net = cv2.dnn.readNetFromDarknet(\"Resources\/yolov4-tiny.cfg\",                                      \"Resources\/yolov4-tiny.weights\")     layer_names = net.getLayerNames()     out_layers_indexes = net.getUnconnectedOutLayers()     out_layers = [layer_names[index - 1] for index in out_layers_indexes]      # Loading from a file of object classes that YOLO can detect     with open(\"Resources\/coco.names.txt\") as file:         classes = file.read().split(\"\\n\")      # Determining classes that will be prioritized for search in an image     # The names are in the file coco.names.txt      video = input(\"Path to video (or URL): \")     look_for = input(\"What we are looking for: \").split(',')          # Delete spaces     list_look_for = []     for look in look_for:         list_look_for.append(look.strip())      classes_to_look_for = list_look_for      start_video_object_detection(video)<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c \u0434\u043e \u0432\u0438\u0434\u0435\u043e \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438. \u0412\u043c\u0435\u0441\u0442\u043e \u043f\u0443\u0442\u0438 \u0434\u043e \u0432\u0438\u0434\u0435\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0441 \u043a\u0430\u043c\u0435\u0440\u044b. \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e, \u0435\u0441\u043b\u0438 \u0438\u0445 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c.<\/p>\n<pre><code>Path to video (or URL): Result\/input\/example.mp4 What we are looking for: person, car, bus<\/code><\/pre>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/397\/721\/761\/397721761c31eea27a28c814efd29709.gif\" width=\"1920\" height=\"1080\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/397\/721\/761\/397721761c31eea27a28c814efd29709.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e2b\/bc4\/39a\/e2bbc439a703c9c3bd169a3768d15062.gif\" width=\"960\" height=\"540\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e2b\/bc4\/39a\/e2bbc439a703c9c3bd169a3768d15062.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438, \u043a\u0430\u043a \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c YOLO \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0441 \u0442\u0435\u0441\u0442\u0430\u043c. \u041f\u043e\u0433\u0440\u0435\u0448\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0435 \u0436\u0435 \u0435\u0441\u0442\u044c, \u043d\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/678706\/\"> https:\/\/habr.com\/ru\/post\/678706\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u043f\u043e\u0438\u0441\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python \u0438 OpenCV. \u041f\u043e\u043c\u0438\u043c\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0432\u0438\u0434\u0435\u043e, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0430\u043c\u0435\u0440\u044b.  <\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438 \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 \u043c\u043e\u0435\u043c\u00a0<a href=\"https:\/\/github.com\/paveldat\/object_detection_on_video\" rel=\"noopener noreferrer nofollow\">Github<\/a>.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; <a href=\"https:\/\/habr.com\/ru\/post\/678644\/\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0438\u0441\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0444\u043e\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python<\/a>. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0435\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435, \u044f \u0440\u0430\u0441\u043f\u0438\u0448\u0443 \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e \u043d\u043e\u0432\u043e\u0439.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code>pip install opencv-python pip install numpy pip install art<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 YOLO \u0438 \u043e\u0442\u043c\u0435\u0447\u0430\u0442\u044c \u0438\u0445.<\/p>\n<p>\u0421\u043a\u0430\u0447\u0430\u0435\u043c \u0441 \u043c\u043e\u0435\u0433\u043e\u00a0<a href=\"https:\/\/github.com\/paveldat\/object_detection_on_video\/tree\/main\/Resources\" rel=\"noopener noreferrer nofollow\">Github<\/a>\u00a0\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e\u00a0<code>Resources<\/code>\u00a0\u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430\u0448\u0430 \u0431\u0443\u0434\u0443\u0449\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430:<\/p>\n<pre><code>'person', 'bicycle', 'car', 'motorbike', 'aeroplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'sofa', 'pottedplant', 'bed', 'diningtable', 'toilet', 'tvmonitor', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code>import cv2 import numpy as np from art import tprint<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f YOLO. \u0421 \u0435\u0435 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438\u0445 \u0433\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438.<\/p>\n<pre><code class=\"python\">def apply_yolo_object_detection(image_to_process):     \"\"\"     Recognition and determination of the coordinates of objects on the image     :param image_to_process: original image     :return: image with marked objects and captions to them     \"\"\" height, width, _ = image_to_process.shape blob = cv2.dnn.blobFromImage(image_to_process, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">1&lt;\/span> \/ &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">255&lt;\/span>, (&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">608&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">608&lt;\/span>),                              (&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>, &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>), swapRB=&lt;span class=\"hljs-literal\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">True&lt;\/span>, crop=&lt;span class=\"hljs-literal\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">False&lt;\/span>) net.setInput(blob) outs = net.forward(out_layers) class_indexes, class_scores, boxes = ([] &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">for&lt;\/span> i &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">in&lt;\/span> range(&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">3&lt;\/span>)) objects_count = &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>  &lt;span class=\"hljs-comment\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(142, 144, 140); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\"># Starting a search for objects in an image&lt;\/span> &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">for&lt;\/span> out &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">in&lt;\/span> outs:     &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">for&lt;\/span> obj &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">in&lt;\/span> out:         scores = obj[&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">5&lt;\/span>:]         class_index = np.argmax(scores)         class_score = scores[class_index]         &lt;span class=\"hljs-keyword\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; font-weight: 700; color: rgb(137, 89, 168); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">if&lt;\/span> class_score &amp;gt; &lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>:             center_x = int(obj[&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">0&lt;\/span>] * width)             center_y = int(obj[&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\">1&lt;\/span>] * height)             obj_width = int(obj[&lt;span class=\"hljs-number\" style=\"transition: opacity 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s, text-decoration 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s, -webkit-text-decoration 0.2s ease-in-out 0s; color: rgb(245, 135, 31); quotes: &amp;quot;\u00ab&amp;quot; &amp;quot;\u00bb&amp;quot;;\"><\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-336342","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=336342"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/336342\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=336342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=336342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=336342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}