-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
36 lines (25 loc) · 999 Bytes
/
index.py
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
28
29
30
31
32
33
34
35
36
import time
import keyboard
from PIL import ImageGrab, Image
import geo
import timeit
def main():
print("Press Shift + I to capture a screenshot and identify the image.")
while True:
if keyboard.is_pressed("shift") and keyboard.is_pressed("i"):
print("Capturing...")
# Capture the screen.
screenshot = ImageGrab.grab(bbox=(114, 89, 1335, 957))
print("captured")
print("Identifying...")
# Call the geo.identify() function with the captured image.
result = geo.identify(screenshot, 5)
#execution_time = timeit.timeit(lambda: geo.identify(screenshot, 5), number=1)
#print(f"Execution time: {execution_time:.4f} seconds")
# Print the result.
geo.print_results(result)
print("Identified!")
# Add a delay to prevent continuous captures on a single keypress.
time.sleep(1)
if __name__ == "__main__":
main()