1
0

2 Ревизии d66f3739c7 ... 814a64d8c1

Автор SHA1 Съобщение Дата
  Richard Köhl 814a64d8c1 Merge branch 'main' of ssh://git.koehls.de:10022/ric/hero-wars-capturer преди 1 година
  Richard Köhl 98e0ab1cbe fallback to screenshot path if ram drive is not available преди 1 година
променени са 1 файла, в които са добавени 21 реда и са изтрити 0 реда
  1. 21 0
      helper.py

+ 21 - 0
helper.py

@@ -29,6 +29,7 @@ if (
     or not os.path.ismount(ram_drive_path)
 ):
     print("no ram drive ({ram_drive_path})")
+    ram_drive_path = os.getenv("SCREENSHOT_PATH")
 
 android_address = os.getenv("ANDROID_ADDRESS")
 client = AdbClient(host="127.0.0.1", port=5037)
@@ -87,6 +88,23 @@ def capture_current_screen(timeout=10):
     return current_screen
 
 
+# def capture_current_screen(timeout=5):  # Timeout in seconds
+#     def target():
+#         global current_screen
+#         current_screen = device.screencap()
+
+#     capture_thread = threading.Thread(target=target)
+#     capture_thread.start()
+#     capture_thread.join(timeout)
+
+#     if capture_thread.is_alive():
+#         print("Screen capture timed out")
+#         # Handle the timeout situation, e.g., by retrying or aborting
+#         capture_thread.join()
+
+#     return current_screen
+
+
 def find_center(x1, y1, x2, y2):
     centerX = round(x1 + (x2 - x1) / 2)
     centerY = round(y1 + (y2 - y1) / 2)
@@ -181,6 +199,9 @@ def find_template(template_image):
         target_image = np.array(target_image)
         target_image = cv2.cvtColor(target_image, cv2.COLOR_RGB2BGR)
 
+        # target_image = target_image.astype(np.uint8)
+        # template_image = template_image.astype(np.uint8)
+
         h, w = template_image.shape[:-1]
 
         # Template matching