Skip to content

Commit

Permalink
Allow detect.py to use video size for initial window size (ultralytic…
Browse files Browse the repository at this point in the history
…s#8330)

* fixed initial window size of detect.py being tiny

* cleanup

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
NicholasZolton and glenn-jocher committed Jun 26, 2022
1 parent 5c990e3 commit 0537e8d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 0537e8d

Please sign in to comment.