ultralytics 8.0.237 cv2.CAP_PROP fix and in_counts and out_counts displays (#7380)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: ayush chaurasia <ayush.chaurarsia@gmail.com> Co-authored-by: Muhammad Rizwan Munawar <chr043416@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: 曾逸夫(Zeng Yifu) <41098760+Zengyf-CVer@users.noreply.github.com>
This commit is contained in:
parent
71fe5e919d
commit
8c2b2f56b2
15 changed files with 108 additions and 90 deletions
|
|
@ -33,6 +33,8 @@ class ObjectCounter:
|
|||
self.im0 = None
|
||||
self.tf = None
|
||||
self.view_img = False
|
||||
self.view_in_counts = True
|
||||
self.view_out_counts = True
|
||||
|
||||
self.names = None # Classes names
|
||||
self.annotator = None # Annotator
|
||||
|
|
@ -61,6 +63,8 @@ class ObjectCounter:
|
|||
line_thickness=2,
|
||||
track_thickness=2,
|
||||
view_img=False,
|
||||
view_in_counts=True,
|
||||
view_out_counts=True,
|
||||
draw_tracks=False,
|
||||
count_txt_thickness=2,
|
||||
count_txt_color=(0, 0, 0),
|
||||
|
|
@ -74,6 +78,8 @@ class ObjectCounter:
|
|||
Args:
|
||||
line_thickness (int): Line thickness for bounding boxes.
|
||||
view_img (bool): Flag to control whether to display the video stream.
|
||||
view_in_counts (bool): Flag to control whether to display the incounts on video stream.
|
||||
view_out_counts (bool): Flag to control whether to display the outcounts on video stream.
|
||||
reg_pts (list): Initial list of points defining the counting region.
|
||||
classes_names (dict): Classes names
|
||||
track_thickness (int): Track thickness
|
||||
|
|
@ -88,6 +94,8 @@ class ObjectCounter:
|
|||
"""
|
||||
self.tf = line_thickness
|
||||
self.view_img = view_img
|
||||
self.view_in_counts = view_in_counts
|
||||
self.view_out_counts = view_out_counts
|
||||
self.track_thickness = track_thickness
|
||||
self.draw_tracks = draw_tracks
|
||||
|
||||
|
|
@ -192,11 +200,23 @@ class ObjectCounter:
|
|||
|
||||
incount_label = 'In Count : ' + f'{self.in_counts}'
|
||||
outcount_label = 'OutCount : ' + f'{self.out_counts}'
|
||||
self.annotator.count_labels(in_count=incount_label,
|
||||
out_count=outcount_label,
|
||||
count_txt_size=self.count_txt_thickness,
|
||||
txt_color=self.count_txt_color,
|
||||
color=self.count_color)
|
||||
|
||||
# Display counts based on user choice
|
||||
counts_label = None
|
||||
if not self.view_in_counts and not self.view_out_counts:
|
||||
counts_label = None
|
||||
elif not self.view_in_counts:
|
||||
counts_label = outcount_label
|
||||
elif not self.view_out_counts:
|
||||
counts_label = incount_label
|
||||
else:
|
||||
counts_label = incount_label + ' ' + outcount_label
|
||||
|
||||
if counts_label is not None:
|
||||
self.annotator.count_labels(counts=counts_label,
|
||||
count_txt_size=self.count_txt_thickness,
|
||||
txt_color=self.count_txt_color,
|
||||
color=self.count_color)
|
||||
|
||||
def display_frames(self):
|
||||
"""Display frame."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue