glenn-jocher commited on
Commit
7215a0f
1 Parent(s): 0ab303b

Avoid cv2 window init code on Windows (#8712)

Browse files

Resolves https://github.com/ultralytics/yolov5/issues/8642

Files changed (1) hide show
  1. detect.py +2 -1
detect.py CHANGED
@@ -26,6 +26,7 @@ Usage - formats:
26
 
27
  import argparse
28
  import os
 
29
  import sys
30
  from pathlib import Path
31
 
@@ -173,7 +174,7 @@ def run(
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])
 
26
 
27
  import argparse
28
  import os
29
+ import platform
30
  import sys
31
  from pathlib import Path
32
 
 
174
  # Stream results
175
  im0 = annotator.result()
176
  if view_img:
177
+ if platform.system() == 'Linux' and p not in windows:
178
  windows.append(p)
179
  cv2.namedWindow(str(p), cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # allow window resize (Linux)
180
  cv2.resizeWindow(str(p), im0.shape[1], im0.shape[0])