Move request handling
This commit is contained in:
@@ -1,8 +1,3 @@
|
||||
import threading
|
||||
|
||||
import requests
|
||||
import _thread
|
||||
|
||||
from services.clock_service import ClockService
|
||||
from services.detection_service import DetectionService
|
||||
|
||||
@@ -24,28 +19,9 @@ class GameService:
|
||||
self.clock_service.stop()
|
||||
self.detection_service.stop()
|
||||
|
||||
def make_move(self) -> None:
|
||||
def make_move(self) -> tuple[bytes, str] | None:
|
||||
try :
|
||||
frame, fen = self.detection_service.analyze_single_frame()
|
||||
print(fen)
|
||||
url = "http://192.168.15.125:1880/party/image"
|
||||
"""threading.Thread(
|
||||
target=self.__send_detection_result,
|
||||
args=(url, frame, fen),
|
||||
daemon=True
|
||||
).start()"""
|
||||
return self.detection_service.analyze_single_frame()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def __send_detection_result(self, url, img, fen):
|
||||
try:
|
||||
headers = {'Content-Type': 'image/jpeg'}
|
||||
body = {'frame': img, 'fen': fen}
|
||||
response = requests.post(
|
||||
url,
|
||||
data=body,
|
||||
headers=headers,
|
||||
verify=False)
|
||||
print(response.status_code)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return None
|
||||
Reference in New Issue
Block a user