mirror of
https://github.com/283375/arcaea-offline-ocr.git
synced 2025-04-16 03:50:18 +00:00
Merge pull request #4 from 283375/path-unicode
fix: unicode character in image path
This commit is contained in:
commit
e01f6cd6bc
@ -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)
|
||||
|
9
src/arcaea_offline_ocr/utils.py
Normal file
9
src/arcaea_offline_ocr/utils.py
Normal 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)
|
Loading…
x
Reference in New Issue
Block a user