Handle starting command
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
import threading
|
||||
|
||||
import requests
|
||||
import _thread
|
||||
|
||||
from services.clock_service import ClockService
|
||||
from services.detection_service import DetectionService
|
||||
@@ -15,7 +16,7 @@ class GameService:
|
||||
self.detection_service = DetectionService()
|
||||
self.clock_service = ClockService()
|
||||
|
||||
def start(self, time_control : int, increment : int ) -> None:
|
||||
def start(self, white_name, back_name, time_control : int, increment : int ) -> None:
|
||||
self.clock_service.start(time_control, increment)
|
||||
self.clock_service.set_on_terminated(self.stop)
|
||||
|
||||
@@ -27,10 +28,21 @@ class GameService:
|
||||
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()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def __send_detection_result(self, url, img, fen):
|
||||
try:
|
||||
headers = {'Content-Type': 'image/jpeg'}
|
||||
body = {'frame': frame, 'fen': fen}
|
||||
body = {'frame': img, 'fen': fen}
|
||||
response = requests.post(
|
||||
"https://192.168.15.125:1880/party/image",
|
||||
url,
|
||||
data=body,
|
||||
headers=headers,
|
||||
verify=False)
|
||||
|
||||
Reference in New Issue
Block a user