Heatmaps bug fix (#17634)

pull/17628/head^2
Muhammad Rizwan Munawar 2 weeks ago committed by GitHub
parent 35b6fed814
commit bde3105813
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      ultralytics/solutions/heatmap.py
  2. 2
      ultralytics/solutions/object_counter.py

@ -104,12 +104,12 @@ class Heatmap(ObjectCounter):
self.annotator.draw_region(reg_pts=self.region, color=(104, 0, 123), thickness=self.line_width * 2) self.annotator.draw_region(reg_pts=self.region, color=(104, 0, 123), thickness=self.line_width * 2)
self.store_tracking_history(track_id, box) # Store track history self.store_tracking_history(track_id, box) # Store track history
self.store_classwise_counts(cls) # store classwise counts in dict self.store_classwise_counts(cls) # store classwise counts in dict
current_centroid = ((box[0] + box[2]) / 2, (box[1] + box[3]) / 2)
# Store tracking previous position and perform object counting # Store tracking previous position and perform object counting
prev_position = None prev_position = None
if len(self.track_history[track_id]) > 1: if len(self.track_history[track_id]) > 1:
prev_position = self.track_history[track_id][-2] prev_position = self.track_history[track_id][-2]
self.count_objects(self.track_line, box, track_id, prev_position, cls) # Perform object counting self.count_objects(current_centroid, track_id, prev_position, cls) # Perform object counting
if self.region is not None: if self.region is not None:
self.display_counts(im0) # Display the counts on the frame self.display_counts(im0) # Display the counts on the frame

@ -63,7 +63,7 @@ class ObjectCounter(BaseSolution):
>>> track_id = 1 >>> track_id = 1
>>> prev_position = (120, 220) >>> prev_position = (120, 220)
>>> cls = 0 >>> cls = 0
>>> counter.count_objects(track_line, box, track_id, prev_position, cls) >>> counter.count_objects(current_centroid, track_id, prev_position, cls)
""" """
if prev_position is None or track_id in self.counted_ids: if prev_position is None or track_id in self.counted_ids:
return return

Loading…
Cancel
Save