From b2ae30b45c10474eecd3463c248371f75ed48a5e Mon Sep 17 00:00:00 2001 From: YoursFunny Date: Sun, 5 May 2024 16:08:35 +0800 Subject: [PATCH] fix(ocr): force substitute % with / in DigitCounter --- module/ocr/ocr.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/module/ocr/ocr.py b/module/ocr/ocr.py index 4d36f7a..7619c78 100644 --- a/module/ocr/ocr.py +++ b/module/ocr/ocr.py @@ -349,6 +349,11 @@ class DigitCounter(Ocr): def __init__(self, button: ButtonWrapper, lang='en', name=None): super().__init__(button, lang=lang, name=name) + def after_process(self, result): + result = super().after_process(result) + result = result.replace('%', '/') + return result + def format_result(self, result) -> tuple[int, int, int]: """ Do OCR on a counter, such as `14/15`, and returns 14, 1, 15 @@ -356,7 +361,7 @@ class DigitCounter(Ocr): Returns: int: """ - result = super().after_process(result) + result = self.after_process(result) logger.attr(name=self.name, text=str(result)) res = re.search(r'(\d+)/(\d+)', result)