ultralytics 8.0.226 Validator Path and Tuner space (#6901)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.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: DennisJ <106725464+DennisJcy@users.noreply.github.com> Co-authored-by: Kirill Ionkin <56236621+kirill-ionkin@users.noreply.github.com>
This commit is contained in:
parent
6e660dfaaf
commit
412eb57fca
12 changed files with 60 additions and 22 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import cv2
|
||||
|
||||
from ultralytics.utils.checks import check_imshow
|
||||
from ultralytics.utils.plotting import Annotator
|
||||
|
||||
|
||||
|
|
@ -32,6 +33,9 @@ class AIGym:
|
|||
self.view_img = False
|
||||
self.annotator = None
|
||||
|
||||
# Check if environment support imshow
|
||||
self.env_check = check_imshow(warn=True)
|
||||
|
||||
def set_args(self,
|
||||
kpts_to_check,
|
||||
line_thickness=2,
|
||||
|
|
@ -120,7 +124,7 @@ class AIGym:
|
|||
|
||||
self.annotator.kpts(k, shape=(640, 640), radius=1, kpt_line=True)
|
||||
|
||||
if self.view_img:
|
||||
if self.env_check and self.view_img:
|
||||
cv2.imshow('Ultralytics YOLOv8 AI GYM', self.im0)
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
return
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from collections import defaultdict
|
|||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from ultralytics.utils.checks import check_requirements
|
||||
from ultralytics.utils.checks import check_imshow, check_requirements
|
||||
from ultralytics.utils.plotting import Annotator
|
||||
|
||||
check_requirements('shapely>=2.0.0')
|
||||
|
|
@ -50,6 +50,9 @@ class Heatmap:
|
|||
self.count_reg_color = (0, 255, 0)
|
||||
self.region_thickness = 5
|
||||
|
||||
# Check if environment support imshow
|
||||
self.env_check = check_imshow(warn=True)
|
||||
|
||||
def set_args(self,
|
||||
imw,
|
||||
imh,
|
||||
|
|
@ -155,7 +158,7 @@ class Heatmap:
|
|||
|
||||
im0_with_heatmap = cv2.addWeighted(self.im0, 1 - self.heatmap_alpha, heatmap_colored, self.heatmap_alpha, 0)
|
||||
|
||||
if self.view_img:
|
||||
if self.env_check and self.view_img:
|
||||
self.display_frames(im0_with_heatmap)
|
||||
|
||||
return im0_with_heatmap
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from collections import defaultdict
|
|||
|
||||
import cv2
|
||||
|
||||
from ultralytics.utils.checks import check_requirements
|
||||
from ultralytics.utils.checks import check_imshow, check_requirements
|
||||
from ultralytics.utils.plotting import Annotator, colors
|
||||
|
||||
check_requirements('shapely>=2.0.0')
|
||||
|
|
@ -46,6 +46,9 @@ class ObjectCounter:
|
|||
self.track_thickness = 2
|
||||
self.draw_tracks = False
|
||||
|
||||
# Check if environment support imshow
|
||||
self.env_check = check_imshow(warn=True)
|
||||
|
||||
def set_args(self,
|
||||
classes_names,
|
||||
reg_pts,
|
||||
|
|
@ -136,7 +139,7 @@ class ObjectCounter:
|
|||
else:
|
||||
self.in_counts += 1
|
||||
|
||||
if self.view_img:
|
||||
if self.env_check and self.view_img:
|
||||
incount_label = 'InCount : ' + f'{self.in_counts}'
|
||||
outcount_label = 'OutCount : ' + f'{self.out_counts}'
|
||||
self.annotator.count_labels(in_count=incount_label, out_count=outcount_label)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue