From 0537e8dd13859c4b44db3bf6f39b9ff20eaf163b Mon Sep 17 00:00:00 2001 From: Nicholas Zolton <78943323+NicholasZolton@users.noreply.github.com> Date: Sun, 26 Jun 2022 17:04:11 -0500 Subject: [PATCH] Allow detect.py to use video size for initial window size (#8330) * fixed initial window size of detect.py being tiny * cleanup Co-authored-by: Glenn Jocher --- detect.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/detect.py b/detect.py index 9d92e4c169e4..bb09ce171a96 100644 --- a/detect.py +++ b/detect.py @@ -106,7 +106,7 @@ def run( # Run inference model.warmup(imgsz=(1 if pt else bs, 3, *imgsz)) # warmup - dt, seen = [0.0, 0.0, 0.0], 0 + seen, windows, dt = 0, [], [0.0, 0.0, 0.0] for path, im, im0s, vid_cap, s in dataset: t1 = time_sync() im = torch.from_numpy(im).to(device) @@ -173,7 +173,10 @@ def run( # Stream results im0 = annotator.result() if view_img: - cv2.namedWindow(str(p), cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # allow window resize (Linux) + if p not in windows: + windows.append(p) + cv2.namedWindow(str(p), cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # allow window resize (Linux) + cv2.resizeWindow(str(p), im0.shape[1], im0.shape[0]) cv2.imshow(str(p), im0) cv2.waitKey(1) # 1 millisecond