Use CF methods for now
This commit is contained in:
@@ -23,7 +23,7 @@ try:
|
||||
import Vision
|
||||
import objc
|
||||
from AppKit import NSData, NSImage, NSBundle
|
||||
from PyObjCTools.AppHelper import runConsoleEventLoop, stopEventLoop
|
||||
from CoreFoundation import CFRunLoopRun, CFRunLoopStop, CFRunLoopGetCurrent
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -349,7 +349,8 @@ class AppleLiveText:
|
||||
req.setLocales_(['ja','en'])
|
||||
self.result = None
|
||||
self.analyzer.processRequest_progressHandler_completionHandler_(req, lambda progress: None, self._process)
|
||||
runConsoleEventLoop()
|
||||
|
||||
CFRunLoopRun()
|
||||
|
||||
if not self.result:
|
||||
return (False, 'Unknown error!')
|
||||
@@ -362,7 +363,7 @@ class AppleLiveText:
|
||||
for line in lines:
|
||||
res += line.string() + '\n'
|
||||
self.result = res
|
||||
stopEventLoop()
|
||||
CFRunLoopStop(CFRunLoopGetCurrent())
|
||||
|
||||
def _preprocess(self, img):
|
||||
image_bytes = pil_image_to_bytes(img, 'tiff')
|
||||
|
||||
@@ -404,7 +404,7 @@ def run(read_from=None,
|
||||
for config_engine in config.get_general('engines').split(','):
|
||||
config_engines.append(config_engine.strip().lower())
|
||||
|
||||
for _,engine_class in sorted(inspect.getmembers(sys.modules[__name__], lambda x: hasattr(x, '__module__') and __package__ + '.ocr' in x.__module__ and inspect.isclass(x))):
|
||||
for _,engine_class in sorted(inspect.getmembers(sys.modules[__name__], lambda x: hasattr(x, '__module__') and x.__module__ and __package__ + '.ocr' in x.__module__ and inspect.isclass(x))):
|
||||
if len(config_engines) == 0 or engine_class.name in config_engines:
|
||||
if config.get_engine(engine_class.name) == None:
|
||||
engine_instance = engine_class()
|
||||
|
||||
Reference in New Issue
Block a user