Richard Köhl 1 anno fa
parent
commit
f25a31fb4c
4 ha cambiato i file con 10 aggiunte e 1 eliminazioni
  1. 1 0
      .env.example
  2. 2 0
      .gitignore
  3. 6 1
      helper.py
  4. 1 0
      requirements.txt

+ 1 - 0
.env.example

@@ -0,0 +1 @@
+ANDROID_ADDRESS=192.168.178.32:5555

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+test/
+.env

+ 6 - 1
helper.py

@@ -1,8 +1,10 @@
 import cv2
 import numpy as np
+import os
 from io import BytesIO
 from PIL import Image
 from ppadb.client import Client as AdbClient
+from dotenv import load_dotenv
 
 with_cuda = 0
 if cv2.cuda.getCudaEnabledDeviceCount() > 0:
@@ -12,6 +14,9 @@ else:
     print("CUDA is not available")
     with_cuda = 0
 
+load_dotenv()
+android_address = os.getenv("ANDROID_ADDRESS")
+
 
 def get_current_screen():
     return current_screen
@@ -186,6 +191,6 @@ def non_max_suppression(boxes, overlapThresh):
 
 
 client = AdbClient(host="127.0.0.1", port=5037)
-device = client.device("192.168.178.32:5555")
+device = client.device(android_address)
 
 current_screen = capture_current_screen()

+ 1 - 0
requirements.txt

@@ -2,3 +2,4 @@ opencv-python==4.9.0.80
 numpy==1.26.1
 Pillow==9.0.1
 pure-python-adb==0.3.0.dev0
+python-dotenv==1.0.0