From 17477066ec2fd61d08652a22897e23d2040ff3e6 Mon Sep 17 00:00:00 2001 From: Charan K Date: Wed, 11 Sep 2024 23:10:40 +0530 Subject: [PATCH] `ultralytics 8.2.92` vertical `line` counter fix (#16163) Co-authored-by: UltralyticsAssistant Co-authored-by: RizwanMunawar Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com> Co-authored-by: Glenn Jocher --- ultralytics/__init__.py | 2 +- ultralytics/solutions/object_counter.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 5db8585676..1968fbaa2f 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.2.91" +__version__ = "8.2.92" import os diff --git a/ultralytics/solutions/object_counter.py b/ultralytics/solutions/object_counter.py index 24cbd488cd..ce6c1cb579 100644 --- a/ultralytics/solutions/object_counter.py +++ b/ultralytics/solutions/object_counter.py @@ -60,7 +60,6 @@ class ObjectCounter: self.out_counts = 0 self.count_ids = [] self.class_wise_count = {} - self.count_txt_thickness = 0 # Tracks info self.track_history = defaultdict(list) @@ -136,7 +135,7 @@ class ObjectCounter: # Extract tracks for box, track_id, cls in zip(boxes, track_ids, clss): # Draw bounding box - annotator.box_label(box, label=f"{self.names[cls]}#{track_id}", color=colors(int(track_id), True)) + annotator.box_label(box, label=self.names[cls], color=colors(int(track_id), True)) # Store class info if self.names[cls] not in self.class_wise_count: @@ -182,10 +181,9 @@ class ObjectCounter: self.count_ids.append(track_id) # Determine the direction of movement (IN or OUT) - direction = (box[0] - prev_position[0]) * ( - self.counting_region.centroid.x - prev_position[0] - ) - if direction > 0: + dx = (box[0] - prev_position[0]) * (self.counting_region.centroid.x - prev_position[0]) + dy = (box[1] - prev_position[1]) * (self.counting_region.centroid.y - prev_position[1]) + if dx > 0 and dy > 0: self.in_counts += 1 self.class_wise_count[self.names[cls]]["IN"] += 1 else: