Merge pull request #4 from 283375/path-unicode

fix: unicode character in image path
This commit is contained in:
283375 2023-06-23 15:05:11 +08:00 committed by GitHub
commit e01f6cd6bc
2 changed files with 11 additions and 1 deletions

View File

@ -7,6 +7,7 @@ from .crop import *
from .device import Device
from .mask import *
from .ocr import *
from .utils import imread_unicode
__all__ = [
"process_digits_ocr_img",
@ -72,7 +73,7 @@ class RecognizeResult:
def recognize(img_filename: str, device: Device):
img = imread(img_filename)
img = imread_unicode(img_filename)
img_hsv = cvtColor(img, COLOR_BGR2HSV)
pure_roi = crop_to_pure(img_hsv, device)

View File

@ -0,0 +1,9 @@
from cv2 import IMREAD_UNCHANGED, Mat, imdecode
from numpy import fromfile as np_fromfile
from numpy import uint8
def imread_unicode(filepath: str) -> Mat:
# https://stackoverflow.com/a/57872297/16484891
# CC BY-SA 4.0
return imdecode(np_fromfile(filepath, dtype=uint8), IMREAD_UNCHANGED)