fix ocr func for Chinese path issus (#1755)

This commit is contained in:
fushall 2021-01-22 19:15:42 +08:00 committed by GitHub
parent 811712aebe
commit 8216aa9e3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -290,7 +290,9 @@ class PaddleOCR(predict_system.TextSystem):
image_file = img
img, flag = check_and_read_gif(image_file)
if not flag:
img = cv2.imread(image_file)
with open(image_file, 'rb') as f:
np_arr = np.frombuffer(f.read(), dtype=np.uint8)
img = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
if img is None:
logger.error("error in loading image:{}".format(image_file))
return None