Added Live Screenshot data functionality

This commit is contained in:
2025-03-05 21:01:35 -07:00
parent 17b99ca836
commit 0c16b74b49
4 changed files with 90 additions and 9 deletions

View File

@ -35,7 +35,6 @@ regions = {}
app_instance = None
def _ensure_qapplication():
"""
Ensures that QApplication is initialized before creating widgets.
@ -45,6 +44,15 @@ def _ensure_qapplication():
if app_instance is None:
app_instance = QApplication(sys.argv) # Start in main thread
def capture_region_as_image(region_id):
collector_mutex.lock()
if region_id not in regions:
collector_mutex.unlock()
return None
x, y, w, h = regions[region_id]['bbox'][:]
collector_mutex.unlock()
screenshot = ImageGrab.grab(bbox=(x, y, x + w, y + h))
return screenshot
def create_ocr_region(region_id, x=250, y=50, w=DEFAULT_WIDTH, h=DEFAULT_HEIGHT, color=(255, 255, 0), thickness=2):
"""