From b4e623c59f42cf43e9115df5e2c4737352f192b9 Mon Sep 17 00:00:00 2001 From: Nickiel12 <35903114+Nickiel12@users.noreply.github.com> Date: Sat, 13 Apr 2024 21:13:20 -0700 Subject: [PATCH] added position encoding (but not to a socket yet) --- Client/yolo_client.py | 11 ++++++++--- joystick-controller-client | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Client/yolo_client.py b/Client/yolo_client.py index 6ada792..b4463e3 100644 --- a/Client/yolo_client.py +++ b/Client/yolo_client.py @@ -30,7 +30,6 @@ def main(websocket_addr): cap.set(3, 640) cap.set(4, 480) - frame_count = 0 while cap.isOpened(): ret, frame = cap.read() if not ret: @@ -39,6 +38,8 @@ def main(websocket_addr): # Perform object detection results = model.predict(frame) + max_x1, max_y1, max_x2, max_y2 = 0 + for r in results: boxes = r.boxes for box in boxes: @@ -62,9 +63,13 @@ def main(websocket_addr): cv2.putText(frame, classNames[cls], org, font, fontScale, color, thickness) - print(f"{frame_count}, {x1}:{y1}, {x2}:{y2}") + if (x2-x1) * (y2 - y1): + max_x1 = x1 + max_x2 = x2 + max_y1 = y1 + max_y2 = y2 - frame_count += 1 + print(f"{max_x1}:{max_y1}, {max_x2}:{max_y2}") cv2.imshow('Webcam', frame) if cv2.waitKey(1) == ord('q'): diff --git a/joystick-controller-client b/joystick-controller-client index 4530cf4..2278b4c 160000 --- a/joystick-controller-client +++ b/joystick-controller-client @@ -1 +1 @@ -Subproject commit 4530cf45a81cbd605d3fae4a371847239b47cb6e +Subproject commit 2278b4cd79c9ec0267198eba9f92b4e4ad4aeb78