From a2c9ca2b341cee4e631a762b31e893ddd9f0775c Mon Sep 17 00:00:00 2001 From: NewUserHa <32261870+NewUserHa@users.noreply.github.com> Date: Sat, 27 May 2023 15:25:57 +0800 Subject: [PATCH] Update utils.py EaseOCR now can read Unicode filenames. --- easyocr/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/easyocr/utils.py b/easyocr/utils.py index 02b1dcbcc0..aab1ee02ea 100644 --- a/easyocr/utils.py +++ b/easyocr/utils.py @@ -733,10 +733,10 @@ def reformat_input(image): if type(image) == str: if image.startswith('http://') or image.startswith('https://'): tmp, _ = urlretrieve(image , reporthook=printProgressBar(prefix = 'Progress:', suffix = 'Complete', length = 50)) - img_cv_grey = cv2.imread(tmp, cv2.IMREAD_GRAYSCALE) + img_cv_grey = cv2.imdecode(np.fromfile(tmp, dtype=np.uint8), cv2.IMREAD_GRAYSCALE) os.remove(tmp) else: - img_cv_grey = cv2.imread(image, cv2.IMREAD_GRAYSCALE) + img_cv_grey = cv2.imdecode(np.fromfile(image, dtype=np.uint8), cv2.IMREAD_GRAYSCALE) image = os.path.expanduser(image) img = loadImage(image) # can accept URL elif type(image) == bytes: @@ -832,4 +832,4 @@ def set_result_with_confidence(results): key=lambda x: x[1])[0] final_result.append(results[best_row][col_ix]) - return final_result \ No newline at end of file + return final_result