|
@@ -2,9 +2,11 @@ import cv2
|
|
|
import time
|
|
import time
|
|
|
import datetime
|
|
import datetime
|
|
|
import numpy as np
|
|
import numpy as np
|
|
|
|
|
+import io
|
|
|
from PIL import Image
|
|
from PIL import Image
|
|
|
from io import BytesIO
|
|
from io import BytesIO
|
|
|
from ppadb.client import Client as AdbClient
|
|
from ppadb.client import Client as AdbClient
|
|
|
|
|
+from PIL import Image
|
|
|
|
|
|
|
|
client = AdbClient(host="127.0.0.1", port=5037)
|
|
client = AdbClient(host="127.0.0.1", port=5037)
|
|
|
device = client.device("192.168.178.32:5555")
|
|
device = client.device("192.168.178.32:5555")
|
|
@@ -95,11 +97,13 @@ def save_screenshot():
|
|
|
result = device.screencap()
|
|
result = device.screencap()
|
|
|
|
|
|
|
|
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
|
- filename = f"fights/{timestamp}.png"
|
|
|
|
|
|
|
+ image = Image.open(io.BytesIO(result))
|
|
|
|
|
+ # TODO: write screenshots to network folder /mnt/t/nextcloud/InstantUpload/Herowars/
|
|
|
|
|
+ jpeg_filename = f"fights/{timestamp}.jpg"
|
|
|
|
|
|
|
|
- # Save the screenshot to a file
|
|
|
|
|
- with open(filename, "wb") as fp:
|
|
|
|
|
- fp.write(result)
|
|
|
|
|
|
|
+ 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
|
|
|
|
|
|
|
|
time.sleep(0.5)
|
|
time.sleep(0.5)
|
|
|
|
|
|