-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
27 lines (23 loc) · 773 Bytes
/
main.py
File metadata and controls
27 lines (23 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import keyboard
import time
from smart_ocr.region_selector import select_region
from smart_ocr.ocr_engine import extract_text, initialize_ocr
from smart_ocr.gui import show_popup
def main():
print("SmartOCR+ running... Press Windows+O to start.")
initialize_ocr()
def handle_hotkey():
time.sleep(0.2)
bbox = select_region()
if not bbox:
return
x1, y1, x2, y2 = bbox
if x2 - x1 < 5 or y2 - y1 < 5: # You can adjust the minimum size
print("[SmartOCR+] Ignored too-small region.")
return
text = extract_text(bbox)
show_popup(text)
keyboard.add_hotkey("windows+o", handle_hotkey)
keyboard.wait("esc") # Exit with ESC
if __name__ == "__main__":
main()