Avoid cv2 window init code on Windows (#8712)

Resolves https://github.com/ultralytics/yolov5/issues/8642
This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-07-25 13:57:05 +02:00
1 parent 0ab303b044
commit 7215a0fb41
1 file changed
+2 -1
+2 -1
View File
@@ -26,6 +26,7 @@ Usage - formats:
import argparse
import os
import platform
import sys
from pathlib import Path
@@ -173,7 +174,7 @@ def run(
# Stream results
im0 = annotator.result()
if view_img:
if p not in windows:
if platform.system() == 'Linux' and 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])