diff options
author | Théo de la Hogue | 2023-04-25 11:07:00 +0200 |
---|---|---|
committer | Théo de la Hogue | 2023-04-25 11:07:00 +0200 |
commit | 2163b03eb42af05f6cb9ffc167385ac05e67142b (patch) | |
tree | 262778a96b2282e4333f4c74f978ad3fe483587b | |
parent | f0f23defdb074050efc42688c0c0f326b7dffa0e (diff) | |
download | argaze-2163b03eb42af05f6cb9ffc167385ac05e67142b.zip argaze-2163b03eb42af05f6cb9ffc167385ac05e67142b.tar.gz argaze-2163b03eb42af05f6cb9ffc167385ac05e67142b.tar.bz2 argaze-2163b03eb42af05f6cb9ffc167385ac05e67142b.tar.xz |
Adding help mode to not display it by default.
-rw-r--r-- | src/argaze/utils/environment_edit.py | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/argaze/utils/environment_edit.py b/src/argaze/utils/environment_edit.py index 038c569..7a7587f 100644 --- a/src/argaze/utils/environment_edit.py +++ b/src/argaze/utils/environment_edit.py @@ -46,7 +46,8 @@ def main(): right_button = False edit_trans = False # translate edit_z = False - hide = False + cover = False + draw_help = False # Update pointer position def on_mouse_event(event, x, y, flags, param): @@ -111,7 +112,7 @@ def main(): gaze_position = GazeFeatures.GazePosition(pointer, precision=2) # Select a new frame and detect markers once - if next_frame_index != current_frame_index or refresh_detection or hide: + if next_frame_index != current_frame_index or refresh_detection or cover: video_capture.set(cv2.CAP_PROP_POS_FRAMES, next_frame_index) @@ -123,7 +124,7 @@ def main(): current_frame_time = video_capture.get(cv2.CAP_PROP_POS_MSEC) # Hide zone - if hide: + if cover: # Draw black circle under pointer cv2.circle(video_frame, pointer, 50, (0, 0, 0), -1) @@ -140,6 +141,7 @@ def main(): # 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) + cv2.putText(video_frame, f'Press \'h\' for help', (950, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) # Copy frame current_frame = video_frame.copy() @@ -297,8 +299,19 @@ def main(): # Draw pointer gaze_position.draw(video_frame) + # Write documentation + if draw_help: + + cv2.rectangle(video_frame, (0, 130), (700, 380), (127, 127, 127), -1) + cv2.putText(video_frame, f'> Left click on marker: select marker', (20, 160), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) + cv2.putText(video_frame, f'> Backspace: unselect marker', (20, 200), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) + cv2.putText(video_frame, f'> T: translate, R: rotate', (20, 240), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) + cv2.putText(video_frame, f'> Z: switch Z axis edition', (20, 280), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) + cv2.putText(video_frame, f'> Right click and drag: edit XY axis', (20, 320), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) + cv2.putText(video_frame, f'> Ctrl + S: save scene', (20, 360), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) + # Write selected marker id - if selected_marker_id >= 0: + elif selected_marker_id >= 0: cv2.rectangle(video_frame, (0, 50), (700, 90), (127, 127, 127), -1) @@ -315,16 +328,6 @@ def main(): else: cv2.putText(video_frame, f'Translate marker {selected_marker_id} along axis {str_axis}', (20, 80), cv2.FONT_HERSHEY_SIMPLEX, 1, color_axis, 1, cv2.LINE_AA) - # Write documentation - else: - cv2.rectangle(video_frame, (0, 130), (700, 380), (127, 127, 127), -1) - cv2.putText(video_frame, f'> Left click on marker: select marker', (20, 160), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) - cv2.putText(video_frame, f'> Backspace: unselect marker', (20, 200), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) - cv2.putText(video_frame, f'> T: translate, R: rotate', (20, 240), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) - cv2.putText(video_frame, f'> Z: switch Z axis edition', (20, 280), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) - cv2.putText(video_frame, f'> Right click and drag: edit XY axis', (20, 320), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) - cv2.putText(video_frame, f'> Ctrl + S: save scene', (20, 360), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv2.LINE_AA) - # Reset left_click left_click = (0, 0) @@ -361,9 +364,13 @@ def main(): if key_pressed == 122: edit_z = not edit_z - # Switch hide mode + # Switch help mode with h key if key_pressed == 104: - hide = not hide + draw_help = not draw_help + + # Switch cover mode with c key + if key_pressed == 99: + cover = not cover # Save selected marker edition using 'Ctrl + s' if key_pressed == 19: |