4 Commits e4dd05b210 ... a4b84fcf59

Autor SHA1 Mensagem Data
  Richard Köhl a4b84fcf59 visualize sleeps 1 ano atrás
  Richard Köhl cdd6fcb7fd actually take screenshot 1 ano atrás
  Richard Köhl 519ba1e389 get configuration from .env file 1 ano atrás
  Richard Köhl 864bc2a957 simplify 1 ano atrás
3 arquivos alterados com 13 adições e 24 exclusões
  1. 4 19
      capture.py
  2. 1 1
      helper.py
  3. 8 4
      screenshot.py

+ 4 - 19
capture.py

@@ -1,20 +1,5 @@
-import datetime
-import io
-from PIL import Image
-from ppadb.client import Client as AdbClient
+import os
+from helper import save_screenshot
 
-client = AdbClient(host="127.0.0.1", port=5037)
-device = client.device("192.168.178.32:5555")
-
-def save_screenshot():
-  result = device.screencap()
-
-  timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
-  image = Image.open(io.BytesIO(result))
-  jpeg_filename = f"/mnt/t/nextcloud/InstantUpload/Herowars/{timestamp}.jpg"
-
-  image = image.convert('RGB')  # Convert to RGB mode for JPEG
-  with open(jpeg_filename, "wb") as fp:
-    image.save(fp, format='JPEG', quality=85)  # Adjust quality as needed
-
-save_screenshot()
+screenshot_address = os.getenv("SCREENSHOT_PATH")
+save_screenshot(screenshot_address)

+ 1 - 1
helper.py

@@ -262,7 +262,7 @@ def non_max_suppression(boxes, overlapThresh):
 
 def save_screenshot(path="test"):
     # Take a screenshot
-    result = get_current_screen()
+    result = capture_current_screen()
 
     timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
     image = Image.open(io.BytesIO(result))

+ 8 - 4
screenshot.py

@@ -79,14 +79,19 @@ def non_max_suppression(boxes, overlapThresh):
     return boxes[pick].astype("int")
 
 
+def sleep(t=1):
+    print(f"sleep {t}s")
+    time.sleep(t)
+
+
 def tap(location):
     tap_helper(location)
-    time.sleep(1)
+    sleep(1)
 
 
 def swipe(start, end, duration=1000):
     swipe_helper(start, end, duration)
-    time.sleep(0.5)
+    sleep(0.5)
 
 
 def tap_button(template):
@@ -118,7 +123,7 @@ def find_max_y_pair(coordinates):
 
 def snap():
     save_screenshot(screenshot_address)
-    time.sleep(0.5)
+    sleep(0.5)
 
 
 def take_fight_screenshots():
@@ -129,7 +134,6 @@ def take_fight_screenshots():
     # snap()
 
     tap_button(close_fight)
-    time.sleep(1)
 
 
 def find_templates(template):