Allow detect.py to use video size for initial window size (#8330)
Browse files* fixed initial window size of detect.py being tiny
* cleanup
Co-authored-by: Glenn Jocher <[email protected]>
detect.py
CHANGED
@@ -106,7 +106,7 @@ def run(
|
|
106 |
|
107 |
# Run inference
|
108 |
model.warmup(imgsz=(1 if pt else bs, 3, *imgsz)) # warmup
|
109 |
-
|
110 |
for path, im, im0s, vid_cap, s in dataset:
|
111 |
t1 = time_sync()
|
112 |
im = torch.from_numpy(im).to(device)
|
@@ -173,7 +173,10 @@ def run(
|
|
173 |
# Stream results
|
174 |
im0 = annotator.result()
|
175 |
if view_img:
|
176 |
-
|
|
|
|
|
|
|
177 |
cv2.imshow(str(p), im0)
|
178 |
cv2.waitKey(1) # 1 millisecond
|
179 |
|
|
|
106 |
|
107 |
# Run inference
|
108 |
model.warmup(imgsz=(1 if pt else bs, 3, *imgsz)) # warmup
|
109 |
+
seen, windows, dt = 0, [], [0.0, 0.0, 0.0]
|
110 |
for path, im, im0s, vid_cap, s in dataset:
|
111 |
t1 = time_sync()
|
112 |
im = torch.from_numpy(im).to(device)
|
|
|
173 |
# Stream results
|
174 |
im0 = annotator.result()
|
175 |
if view_img:
|
176 |
+
if p not in windows:
|
177 |
+
windows.append(p)
|
178 |
+
cv2.namedWindow(str(p), cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # allow window resize (Linux)
|
179 |
+
cv2.resizeWindow(str(p), im0.shape[1], im0.shape[0])
|
180 |
cv2.imshow(str(p), im0)
|
181 |
cv2.waitKey(1) # 1 millisecond
|
182 |
|