Add speed_estimation and distance_calculation in ultralytics solutions (#7325)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Muhammad Rizwan Munawar 2024-01-05 14:38:13 +05:00 committed by GitHub
parent 2f9ec8c0b4
commit 61fa12460d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 642 additions and 23 deletions

View file

@ -198,7 +198,9 @@ class ObjectCounter:
txt_color=self.count_txt_color,
color=self.count_color)
if self.env_check and self.view_img:
def display_frames(self):
"""Display frame."""
if self.env_check:
cv2.namedWindow('Ultralytics YOLOv8 Object Counter')
if len(self.reg_pts) == 4: # only add mouse event If user drawn region
cv2.setMouseCallback('Ultralytics YOLOv8 Object Counter', self.mouse_event_for_region,
@ -219,8 +221,15 @@ class ObjectCounter:
self.im0 = im0 # store image
if tracks[0].boxes.id is None:
return
if self.view_img:
self.display_frames()
return
else:
return
self.extract_and_process_tracks(tracks)
if self.view_img:
self.display_frames()
return self.im0