support path in keras service

This commit is contained in:
nharris-lmg
2024-09-13 13:52:41 -07:00
parent b1f04b44a0
commit ad0b2cb1e9
2 changed files with 4 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
"""Allows accessing Keras Service if available."""
import json
import logging
import os
import time
import mss
import cv2
@@ -18,7 +19,7 @@ class KerasService():
self,
ip_addr: str,
port: int | str,
screenshot_path: str,
screenshot_path: str | os.PathLike,
timeout: float = DEFAULT_TIMEOUT) -> None:
self.ip_addr = ip_addr
self.port = str(port)
@@ -31,7 +32,7 @@ class KerasService():
monitor_1 = sct.monitors[1] # Identify the display to capture
screen = np.array(sct.grab(monitor_1))
screen = cv2.cvtColor(screen, cv2.COLOR_RGB2GRAY)
cv2.imwrite(self.screenshot_path, screen)
cv2.imwrite(str(self.screenshot_path), screen)
def _query_service(self, word: str, report_file: any) -> any:
try:

View File

@@ -3,7 +3,6 @@ import logging
import os
from pathlib import Path
import time
import pyautogui as gui
import pydirectinput as user
import sys
from shadow_of_the_tomb_raider_utils import get_resolution, get_args
@@ -53,7 +52,7 @@ def run_benchmark():
start_game()
args = get_args()
kerasService = KerasService(args.keras_host, args.keras_port, LOG_DIR.joinpath("screenshot.jpg"))
kerasService = KerasService(args.keras_host, args.keras_port, str(LOG_DIR.joinpath("screenshot.jpg")))
am = ArtifactManager(LOG_DIR)
if kerasService.wait_for_word(word="options", timeout=30, interval=1) is None: