Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detect.py --view-img for non-ASCII paths #7093

Merged
merged 15 commits into from
Mar 25, 2022
9 changes: 8 additions & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,9 @@ def increment_path(path, exist_ok=False, sep='', mkdir=False):


# OpenCV Chinese-friendly functions ------------------------------------------------------------------------------------
imshow_ = cv2.imshow # copy to avoid recursion errors


def imread(path):
return cv2.imdecode(np.fromfile(path, np.uint8), cv2.IMREAD_COLOR)

Expand All @@ -917,7 +920,11 @@ def imwrite(path, im):
return False


cv2.imread, cv2.imwrite = imread, imwrite # redefine
def imshow(path, im):
imshow_(path.encode('unicode_escape').decode(), im)


cv2.imread, cv2.imwrite, cv2.imshow = imread, imwrite, imshow # redefine

# Variables ------------------------------------------------------------------------------------------------------------
NCOLS = 0 if is_docker() else shutil.get_terminal_size().columns # terminal window size for tqdm