From bd2060272a25a24b46cfbb628091bffd4b939688 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Wed, 26 Apr 2023 10:06:22 +0200 Subject: Allowing to change z grid with up and down arrow. --- src/argaze/utils/environment_edit.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/argaze/utils/environment_edit.py b/src/argaze/utils/environment_edit.py index 6b0063d..dd53df2 100644 --- a/src/argaze/utils/environment_edit.py +++ b/src/argaze/utils/environment_edit.py @@ -51,6 +51,7 @@ def main(): draw_grid = False draw_cover = False pose_mode = 0 + z_grid = 100. # Update pointer position def on_mouse_event(event, x, y, flags, param): @@ -132,10 +133,14 @@ def main(): current_frame_index = video_capture.get(cv2.CAP_PROP_POS_FRAMES) - 1 current_frame_time = video_capture.get(cv2.CAP_PROP_POS_MSEC) + # Draw gray panel on top + cv2.rectangle(video_frame, (0, 0), (frame_width, 50), (63, 63, 63), -1) + # Draw camera calibration if draw_grid: - ar_environment.aruco_detector.camera.draw(video_frame, frame_width/10, frame_height/10, 100., color=(127, 127, 127)) + cv2.putText(video_frame, f'Grid at {z_grid} cm', (500, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA) + ar_environment.aruco_detector.camera.draw(video_frame, frame_width/10, frame_height/10, z_grid, color=(127, 127, 127)) # Hide zone if draw_cover: @@ -157,7 +162,7 @@ def main(): cv2.circle(video_frame, m.center.astype(int), 5, m.color, -1) # Write timing - cv2.rectangle(video_frame, (0, 0), (frame_width, 50), (63, 63, 63), -1) + cv2.putText(video_frame, f'Time: {int(current_frame_time)} ms', (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA) # Copy frame @@ -326,6 +331,7 @@ def main(): # Project AOI scene into frame according estimated pose aoi_scene_projection = ar_scene.project(tvec, rmat, visual_hfov=TobiiSpecifications.VISUAL_HFOV) + # Draw AOI scene aoi_scene_projection.draw(video_frame, color=m.color) # ArUco marker axis scene pose estimation @@ -347,6 +353,7 @@ def main(): # Project AOI scene into frame according estimated pose aoi_scene_projection = ar_scene.project(tvec, rmat, visual_hfov=TobiiSpecifications.VISUAL_HFOV) + # Draw AOI scene aoi_scene_projection.draw(video_frame, color=(255, 255, 255)) break @@ -365,6 +372,9 @@ def main(): # Try to build AOI scene from detected ArUco marker corners aoi_scene_projection = ar_scene.build_aruco_aoi_scene(ar_environment.aruco_detector.detected_markers) + # Draw AOI scene + aoi_scene_projection.draw(video_frame, color=(255, 255, 255)) + except: pass @@ -455,6 +465,16 @@ def main(): draw_grid = not draw_grid refresh = True + # Raise z grid with down arrow + if key_pressed == 0: + z_grid += 10. + refresh = True + + # Unraise z grid with up arrow + if key_pressed == 1: + z_grid -= 10. + refresh = True + # Switch draw_cover mode with c key if key_pressed == 99: draw_cover = not draw_cover -- cgit v1.1