ultralytics 8.2.57 new Solutions Tests and Docs (#14408)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Muhammad Rizwan Munawar 2024-07-14 23:00:14 +05:00 committed by GitHub
parent 100a73b6e9
commit c67a3039c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 143 additions and 50 deletions

View file

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.2.56"
__version__ = "8.2.57"
import os

View file

@ -24,7 +24,7 @@ class DistanceCalculation:
Initializes the DistanceCalculation class with the given parameters.
Args:
names (dict): Dictionary mapping class indices to class names.
names (dict): Dictionary of classes names.
pixels_per_meter (int, optional): Conversion factor from pixels to meters. Defaults to 10.
view_img (bool, optional): Flag to indicate if the video stream should be displayed. Defaults to False.
line_thickness (int, optional): Thickness of the lines drawn on the image. Defaults to 2.

View file

@ -18,7 +18,7 @@ class Heatmap:
def __init__(
self,
classes_names,
names,
imw=0,
imh=0,
colormap=cv2.COLORMAP_JET,
@ -44,7 +44,7 @@ class Heatmap:
self.shape = shape
self.initialized = False
self.names = classes_names # Classes names
self.names = names # Classes names
# Image information
self.imw = imw

View file

@ -17,7 +17,7 @@ class ObjectCounter:
def __init__(
self,
classes_names,
names,
reg_pts=None,
count_reg_color=(255, 0, 255),
count_txt_color=(0, 0, 0),
@ -37,7 +37,7 @@ class ObjectCounter:
Initializes the ObjectCounter with various tracking and counting parameters.
Args:
classes_names (dict): Dictionary of class names.
names (dict): Dictionary of class names.
reg_pts (list): List of points defining the counting region.
count_reg_color (tuple): RGB color of the counting region.
count_txt_color (tuple): RGB color of the count text.
@ -72,7 +72,7 @@ class ObjectCounter:
self.view_in_counts = view_in_counts
self.view_out_counts = view_out_counts
self.names = classes_names # Classes names
self.names = names # Classes names
self.annotator = None # Annotator
self.window_name = "Ultralytics YOLOv8 Object Counter"

View file

@ -17,7 +17,7 @@ class QueueManager:
def __init__(
self,
classes_names,
names,
reg_pts=None,
line_thickness=2,
track_thickness=2,
@ -34,7 +34,7 @@ class QueueManager:
Initializes the QueueManager with specified parameters for tracking and counting objects.
Args:
classes_names (dict): A dictionary mapping class IDs to class names.
names (dict): A dictionary mapping class IDs to class names.
reg_pts (list of tuples, optional): Points defining the counting region polygon. Defaults to a predefined
rectangle.
line_thickness (int, optional): Thickness of the annotation lines. Defaults to 2.
@ -69,7 +69,7 @@ class QueueManager:
self.view_queue_counts = view_queue_counts
self.fontsize = fontsize
self.names = classes_names # Class names
self.names = names # Class names
self.annotator = None # Annotator
self.window_name = "Ultralytics YOLOv8 Queue Manager"
@ -139,7 +139,7 @@ class QueueManager:
def display_frames(self):
"""Displays the current frame with annotations."""
if self.env_check:
if self.env_check and self.view_img:
self.annotator.draw_region(reg_pts=self.reg_pts, thickness=self.region_thickness, color=self.region_color)
cv2.namedWindow(self.window_name)
cv2.imshow(self.window_name, self.im0)

View file

@ -726,20 +726,18 @@ class Annotator:
)
cv2.putText(self.im, stage_text, stage_text_position, 0, self.sf, txt_color, self.tf)
def seg_bbox(self, mask, mask_color=(255, 0, 255), det_label=None, track_label=None):
def seg_bbox(self, mask, mask_color=(255, 0, 255), label=None, txt_color=(255, 255, 255)):
"""
Function for drawing segmented object in bounding box shape.
Args:
mask (list): masks data list for instance segmentation area plotting
mask_color (tuple): mask foreground color
det_label (str): Detection label text
track_label (str): Tracking label text
mask_color (RGB): mask foreground color
label (str): Detection label text
txt_color (RGB): text color
"""
cv2.polylines(self.im, [np.int32([mask])], isClosed=True, color=mask_color, thickness=2)
label = f"Track ID: {track_label}" if track_label else det_label
text_size, _ = cv2.getTextSize(label, 0, self.sf, self.tf)
cv2.rectangle(
@ -750,9 +748,10 @@ class Annotator:
-1,
)
cv2.putText(
self.im, label, (int(mask[0][0]) - text_size[0] // 2, int(mask[0][1])), 0, self.sf, (255, 255, 255), self.tf
)
if label:
cv2.putText(
self.im, label, (int(mask[0][0]) - text_size[0] // 2, int(mask[0][1])), 0, self.sf, txt_color, self.tf
)
def plot_distance_and_line(self, distance_m, distance_mm, centroids, line_color, centroid_color):
"""