mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-01 10:04:12 +08:00
lock
This commit is contained in:
parent
bbd7fb7e1a
commit
f89f98eab8
@ -17,7 +17,7 @@ from gui.usefulwidget import (
|
|||||||
from gui.dynalang import LPushButton
|
from gui.dynalang import LPushButton
|
||||||
import qtawesome, gobject
|
import qtawesome, gobject
|
||||||
from myutils.ocrutil import imagesolve, ocr_end, ocr_init
|
from myutils.ocrutil import imagesolve, ocr_end, ocr_init
|
||||||
from myutils.wrapper import Singleton_close
|
from myutils.wrapper import Singleton_close, threader
|
||||||
|
|
||||||
|
|
||||||
@Singleton_close
|
@Singleton_close
|
||||||
@ -79,6 +79,7 @@ def __label2(self):
|
|||||||
return self.threshold2label
|
return self.threshold2label
|
||||||
|
|
||||||
|
|
||||||
|
@threader
|
||||||
def __directinitend(engine, _ok):
|
def __directinitend(engine, _ok):
|
||||||
if _ok:
|
if _ok:
|
||||||
ocr_init()
|
ocr_init()
|
||||||
|
@ -6,7 +6,7 @@ from myutils.commonbase import ArgsEmptyExc
|
|||||||
from myutils.hwnd import screenshot
|
from myutils.hwnd import screenshot
|
||||||
from myutils.utils import stringfyerror
|
from myutils.utils import stringfyerror
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
import gobject, winsharedutils
|
import gobject, winsharedutils, threading
|
||||||
|
|
||||||
|
|
||||||
def qimage2binary(qimage: QImage, fmt="BMP"):
|
def qimage2binary(qimage: QImage, fmt="BMP"):
|
||||||
@ -82,15 +82,22 @@ def imageCut(hwnd, x1, y1, x2, y2, viscompare=True, rawimage=False) -> QImage:
|
|||||||
|
|
||||||
_nowuseocr = None
|
_nowuseocr = None
|
||||||
_ocrengine = None
|
_ocrengine = None
|
||||||
|
_initlock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
def ocr_end():
|
def ocr_end():
|
||||||
global _ocrengine, _nowuseocr
|
global _ocrengine, _nowuseocr
|
||||||
_nowuseocr = None
|
with _initlock:
|
||||||
_ocrengine = None
|
_nowuseocr = None
|
||||||
|
_ocrengine = None
|
||||||
|
|
||||||
|
|
||||||
def ocr_init():
|
def ocr_init():
|
||||||
|
with _initlock:
|
||||||
|
__ocr_init()
|
||||||
|
|
||||||
|
|
||||||
|
def __ocr_init():
|
||||||
global _nowuseocr, _ocrengine
|
global _nowuseocr, _ocrengine
|
||||||
use = None
|
use = None
|
||||||
for k in globalconfig["ocr"]:
|
for k in globalconfig["ocr"]:
|
||||||
@ -126,7 +133,7 @@ def ocr_run(qimage: QImage):
|
|||||||
msg = stringfyerror(e)
|
msg = stringfyerror(e)
|
||||||
msg = (
|
msg = (
|
||||||
"<msg_error_refresh>"
|
"<msg_error_refresh>"
|
||||||
+ (_TR(globalconfig["ocr"][_nowuseocr]["name"]) if _nowuseocr else "")
|
+ _TR(globalconfig["ocr"][_nowuseocr]["name"])
|
||||||
+ " "
|
+ " "
|
||||||
+ msg
|
+ msg
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user