Test for sending taken photo to nodered
This commit is contained in:
Binary file not shown.
@@ -88,10 +88,12 @@ if __name__ == "__main__":
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("Keyboard interrupt. Stopping app...")
|
||||
game_service.stop()
|
||||
forward_service.stop_all()
|
||||
exit()
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
game_service.stop()
|
||||
forward_service.stop_all()
|
||||
exit()
|
||||
@@ -1,6 +1,7 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
|
||||
from ultralytics.engine.results import Results
|
||||
|
||||
from hardware.camera.camera import Camera
|
||||
@@ -39,10 +40,10 @@ class DetectionService:
|
||||
def stop(self):
|
||||
self.camera.close()
|
||||
|
||||
def analyze_single_frame(self) -> str | None:
|
||||
def analyze_single_frame(self) -> tuple[np.ndarray, str | None]:
|
||||
frame = self.camera.take_photo()
|
||||
fen = self.__get_fen(frame)
|
||||
return fen
|
||||
return frame, fen
|
||||
|
||||
|
||||
def __run_complete_detection(self, frame : np.ndarray, display=False) -> dict[str, list[Results]] :
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import cv2
|
||||
import requests
|
||||
|
||||
from services.clock_service import ClockService
|
||||
from services.detection_service import DetectionService
|
||||
|
||||
@@ -17,7 +20,14 @@ class GameService:
|
||||
|
||||
def stop(self):
|
||||
self.clock_service.stop()
|
||||
self.detection_service.stop()
|
||||
|
||||
def make_move(self) -> None:
|
||||
fen = self.detection_service.analyze_single_frame()
|
||||
img, fen = self.detection_service.analyze_single_frame()
|
||||
print(fen)
|
||||
|
||||
encoded_frame = cv2.imencode('.jpg', img)
|
||||
image_bytes = encoded_frame[1].tobytes()
|
||||
headers = {'Content-Type': 'image/jpeg'}
|
||||
response = requests.post("https://192.168.15.125/party/image", data=image_bytes, headers=headers)
|
||||
print(response.status_code)
|
||||
Reference in New Issue
Block a user