New version
This commit is contained in:
@@ -102,7 +102,7 @@ class Config:
|
|||||||
'furigana_filter': True,
|
'furigana_filter': True,
|
||||||
'screen_capture_combo': '',
|
'screen_capture_combo': '',
|
||||||
'coordinate_selector_combo': '',
|
'coordinate_selector_combo': '',
|
||||||
'screen_capture_old_macos_api': False,
|
'screen_capture_old_macos_api': True,
|
||||||
'language': 'ja',
|
'language': 'ja',
|
||||||
'output_format': 'text',
|
'output_format': 'text',
|
||||||
'verbosity': -2,
|
'verbosity': -2,
|
||||||
|
|||||||
38
owocr/run.py
38
owocr/run.py
@@ -1000,12 +1000,15 @@ class ScreenshotThread(threading.Thread):
|
|||||||
return
|
return
|
||||||
|
|
||||||
with objc.autorelease_pool():
|
with objc.autorelease_pool():
|
||||||
width = CGImageGetWidth(image)
|
try:
|
||||||
height = CGImageGetHeight(image)
|
width = CGImageGetWidth(image)
|
||||||
raw_data = CGDataProviderCopyData(CGImageGetDataProvider(image))
|
height = CGImageGetHeight(image)
|
||||||
bpr = CGImageGetBytesPerRow(image)
|
raw_data = CGDataProviderCopyData(CGImageGetDataProvider(image))
|
||||||
img = Image.frombuffer('RGBA', (width, height), bytes(raw_data), 'raw', 'BGRA', bpr, 1)
|
bpr = CGImageGetBytesPerRow(image)
|
||||||
self.screencapturekit_queue.put(img)
|
img = Image.frombuffer('RGBA', (width, height), bytes(raw_data), 'raw', 'BGRA', bpr, 1)
|
||||||
|
self.screencapturekit_queue.put(img)
|
||||||
|
except:
|
||||||
|
self.screencapturekit_queue.put(None)
|
||||||
|
|
||||||
window_list = CGWindowListCopyWindowInfo(kCGWindowListOptionIncludingWindow, window_id)
|
window_list = CGWindowListCopyWindowInfo(kCGWindowListOptionIncludingWindow, window_id)
|
||||||
if not window_list or len(window_list) == 0:
|
if not window_list or len(window_list) == 0:
|
||||||
@@ -1092,12 +1095,15 @@ class ScreenshotThread(threading.Thread):
|
|||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
with objc.autorelease_pool():
|
with objc.autorelease_pool():
|
||||||
if self.old_macos_screenshot_api:
|
if self.old_macos_screenshot_api:
|
||||||
cg_image = CGWindowListCreateImageFromArray(CGRectNull, [self.window_id], kCGWindowImageBoundsIgnoreFraming | kCGWindowImageNominalResolution)
|
try:
|
||||||
width = CGImageGetWidth(cg_image)
|
cg_image = CGWindowListCreateImageFromArray(CGRectNull, [self.window_id], kCGWindowImageBoundsIgnoreFraming | kCGWindowImageNominalResolution)
|
||||||
height = CGImageGetHeight(cg_image)
|
width = CGImageGetWidth(cg_image)
|
||||||
raw_data = CGDataProviderCopyData(CGImageGetDataProvider(cg_image))
|
height = CGImageGetHeight(cg_image)
|
||||||
bpr = CGImageGetBytesPerRow(cg_image)
|
raw_data = CGDataProviderCopyData(CGImageGetDataProvider(cg_image))
|
||||||
img = Image.frombuffer('RGBA', (width, height), bytes(raw_data), 'raw', 'BGRA', bpr, 1)
|
bpr = CGImageGetBytesPerRow(cg_image)
|
||||||
|
img = Image.frombuffer('RGBA', (width, height), bytes(raw_data), 'raw', 'BGRA', bpr, 1)
|
||||||
|
except:
|
||||||
|
img = None
|
||||||
else:
|
else:
|
||||||
img = self.capture_macos_window_screenshot(self.window_id)
|
img = self.capture_macos_window_screenshot(self.window_id)
|
||||||
if not img:
|
if not img:
|
||||||
@@ -1241,6 +1247,8 @@ class ScreenshotThread(threading.Thread):
|
|||||||
self.write_result(img, is_combo)
|
self.write_result(img, is_combo)
|
||||||
|
|
||||||
if img == False:
|
if img == False:
|
||||||
|
logger.info('The window was closed or an error occurred.')
|
||||||
|
terminate_handler()
|
||||||
break
|
break
|
||||||
|
|
||||||
if self.screencapture_mode == 2:
|
if self.screencapture_mode == 2:
|
||||||
@@ -1795,11 +1803,7 @@ def run():
|
|||||||
skip_waiting = True
|
skip_waiting = True
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if img == False:
|
if img:
|
||||||
logger.info('The window was closed or an error occurred, terminated!')
|
|
||||||
terminated.set()
|
|
||||||
break
|
|
||||||
elif img:
|
|
||||||
output_result(img, filter_text, auto_pause, notify)
|
output_result(img, filter_text, auto_pause, notify)
|
||||||
if isinstance(img, Path) and delete_images:
|
if isinstance(img, Path) and delete_images:
|
||||||
Path.unlink(img)
|
Path.unlink(img)
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
;https://pynput.readthedocs.io/en/latest/keyboard.html#pynput.keyboard.Key
|
;https://pynput.readthedocs.io/en/latest/keyboard.html#pynput.keyboard.Key
|
||||||
;coordinate_selector_combo =
|
;coordinate_selector_combo =
|
||||||
|
|
||||||
;screen_capture_old_macos_api = False
|
;screen_capture_old_macos_api = True
|
||||||
|
|
||||||
;Two letter language code for filtering screencapture OCR results. Ex. "ja"
|
;Two letter language code for filtering screencapture OCR results. Ex. "ja"
|
||||||
;for Japanese, "zh" for Chinese, "ko" for Korean, "ar" for Arabic, "ru" for
|
;for Japanese, "zh" for Chinese, "ko" for Korean, "ar" for Arabic, "ru" for
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "owocr"
|
name = "owocr"
|
||||||
version = "1.18.1"
|
version = "1.18.2"
|
||||||
description = "Japanese OCR"
|
description = "Japanese OCR"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
|
|||||||
Reference in New Issue
Block a user