From bea704ca6c875b5f708526b6cc8688fe2c26868d 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: Sun, 5 May 2024 21:27:03 +0800 Subject: [PATCH] reinit --- .../LunaTranslator/ocrengines/baseocrclass.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/LunaTranslator/LunaTranslator/ocrengines/baseocrclass.py b/LunaTranslator/LunaTranslator/ocrengines/baseocrclass.py index 17a6d411..72ee8838 100644 --- a/LunaTranslator/LunaTranslator/ocrengines/baseocrclass.py +++ b/LunaTranslator/LunaTranslator/ocrengines/baseocrclass.py @@ -94,13 +94,21 @@ class baseocr(commonbase): ######################################################## def level2init(self): + self.needinit = True try: self.initocr() except Exception as e: raise e + self.needinit = False def _private_ocr(self, imgpath): - text = self.ocr(imgpath) + if self.needinit: + self.level2init() + try: + text = self.ocr(imgpath) + except Exception as e: + self.needinit = True + raise e return self._100_f(text) def _100_f(self, line):