From a2ff34e0fe81c6355ff5a0039c5ca8803a1cf9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sat, 20 Jul 2024 02:48:19 +0800 Subject: [PATCH] fix --- LunaTranslator/LunaTranslator/gui/showword.py | 4 ++-- LunaTranslator/LunaTranslator/myutils/ocrutil.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/showword.py b/LunaTranslator/LunaTranslator/gui/showword.py index 5f5b8627..22699794 100644 --- a/LunaTranslator/LunaTranslator/gui/showword.py +++ b/LunaTranslator/LunaTranslator/gui/showword.py @@ -9,7 +9,7 @@ from myutils.utils import parsekeystringtomodvkcode, unsupportkey from myutils.config import globalconfig, _TR, static_data, savehook_new_data from myutils.subproc import subproc_w from myutils.wrapper import threader, tryprint -from myutils.ocrutil import imageCut, ocr_run +from myutils.ocrutil import imageCut, ocr_run_2 from gui.rangeselect import rangeselct_function from gui.usefulwidget import ( closeashidewindow, @@ -131,7 +131,7 @@ class AnkiWindow(QWidget): @threader def asyncocr(self, img): - self.__ocrsettext.emit(ocr_run(img)) + self.__ocrsettext.emit(ocr_run_2(img)) def crop(self): def ocroncefunction(rect): diff --git a/LunaTranslator/LunaTranslator/myutils/ocrutil.py b/LunaTranslator/LunaTranslator/myutils/ocrutil.py index cf0189ec..2576cb8b 100644 --- a/LunaTranslator/LunaTranslator/myutils/ocrutil.py +++ b/LunaTranslator/LunaTranslator/myutils/ocrutil.py @@ -129,3 +129,19 @@ def ocr_run(qimage: QImage): msg = "" + _TR(globalconfig["ocr"][use]["name"]) + " " + msg text = msg return text + + +def ocr_run_2(qimage: QImage): + text = ocr_run(qimage) + + msgs = [ + "", + "", + "", + "", + "", + ] + for msg in msgs: + if text.startswith(msg): + return text[len(msg) :] + return text