|
@@ -29,6 +29,7 @@ if (
|
|
|
or not os.path.ismount(ram_drive_path)
|
|
or not os.path.ismount(ram_drive_path)
|
|
|
):
|
|
):
|
|
|
print("no ram drive ({ram_drive_path})")
|
|
print("no ram drive ({ram_drive_path})")
|
|
|
|
|
+ ram_drive_path = os.getenv("SCREENSHOT_PATH")
|
|
|
|
|
|
|
|
android_address = os.getenv("ANDROID_ADDRESS")
|
|
android_address = os.getenv("ANDROID_ADDRESS")
|
|
|
client = AdbClient(host="127.0.0.1", port=5037)
|
|
client = AdbClient(host="127.0.0.1", port=5037)
|
|
@@ -87,6 +88,23 @@ def capture_current_screen(timeout=10):
|
|
|
return current_screen
|
|
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):
|
|
def find_center(x1, y1, x2, y2):
|
|
|
centerX = round(x1 + (x2 - x1) / 2)
|
|
centerX = round(x1 + (x2 - x1) / 2)
|
|
|
centerY = round(y1 + (y2 - y1) / 2)
|
|
centerY = round(y1 + (y2 - y1) / 2)
|
|
@@ -181,6 +199,9 @@ def find_template(template_image):
|
|
|
target_image = np.array(target_image)
|
|
target_image = np.array(target_image)
|
|
|
target_image = cv2.cvtColor(target_image, cv2.COLOR_RGB2BGR)
|
|
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]
|
|
h, w = template_image.shape[:-1]
|
|
|
|
|
|
|
|
# Template matching
|
|
# Template matching
|