Avoid cv2 window init code on Windows (#8712)

Resolves https://github.com/ultralytics/yolov5/issues/8642
pull/8714/head
Glenn Jocher 2022-07-25 13:57:05 +02:00 committed by GitHub
parent 0ab303b044
commit 7215a0fb41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -26,6 +26,7 @@ Usage - formats:
import argparse import argparse
import os import os
import platform
import sys import sys
from pathlib import Path from pathlib import Path
@ -173,7 +174,7 @@ def run(
# Stream results # Stream results
im0 = annotator.result() im0 = annotator.result()
if view_img: if view_img:
if p not in windows: if platform.system() == 'Linux' and p not in windows:
windows.append(p) windows.append(p)
cv2.namedWindow(str(p), cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # allow window resize (Linux) 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.resizeWindow(str(p), im0.shape[1], im0.shape[0])