aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2022-09-14 15:41:43 +0200
committerThéo de la Hogue2022-09-14 15:41:43 +0200
commitf0346f70bf2badb46bed882402a38762e3bcdc4a (patch)
treea5cf9bf930afabe4c0c79b7d50281b532a9c8b51
parent6765e2d39002f3c30a95ac5bace4da9ceb15e918 (diff)
downloadargaze-f0346f70bf2badb46bed882402a38762e3bcdc4a.zip
argaze-f0346f70bf2badb46bed882402a38762e3bcdc4a.tar.gz
argaze-f0346f70bf2badb46bed882402a38762e3bcdc4a.tar.bz2
argaze-f0346f70bf2badb46bed882402a38762e3bcdc4a.tar.xz
Allowing to select translation or rotation trnaformation. Editing relatively to the marker center.
-rw-r--r--src/argaze/utils/edit_tobii_segment_aruco_pose.py58
1 files changed, 44 insertions, 14 deletions
diff --git a/src/argaze/utils/edit_tobii_segment_aruco_pose.py b/src/argaze/utils/edit_tobii_segment_aruco_pose.py
index fd8f45b..238a0b7 100644
--- a/src/argaze/utils/edit_tobii_segment_aruco_pose.py
+++ b/src/argaze/utils/edit_tobii_segment_aruco_pose.py
@@ -57,7 +57,10 @@ def main():
destination_path = args.segment_path
# Export into a dedicated time range folder
- timerange_path = f'[{int(args.time_range[0])}s - {int(args.time_range[1])}s]'
+ if args.time_range[1] != None:
+ timerange_path = f'[{int(args.time_range[0])}s - {int(args.time_range[1])}s]'
+ else:
+ timerange_path = f'[all]'
destination_path = f'{destination_path}/{timerange_path}'
@@ -137,6 +140,7 @@ def main():
left_click = (0, 0)
right_click = (0, 0)
right_button = False
+ edit_trans = False # translate
edit_coord = 0 # x
# On mouse left left_click : update pointer position
@@ -215,14 +219,18 @@ def main():
# Write selected marker id
if selected_marker_id >= 0:
- cv.putText(video_frame.matrix, f'Marker {selected_marker_id} : Axis {edit_coord + 1} selected', (20, 80), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 1, cv.LINE_AA)
+ if edit_trans:
+ cv.putText(video_frame.matrix, f'Marker {selected_marker_id} R Axis {edit_coord + 1} selected', (20, 80), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 1, cv.LINE_AA)
+ else:
+ cv.putText(video_frame.matrix, f'Marker {selected_marker_id} T Axis {edit_coord + 1} selected', (20, 80), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 1, cv.LINE_AA)
# Write documentation
else:
cv.putText(video_frame.matrix, f'Left click on marker to select scene', (20, 80), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv.LINE_AA)
- cv.putText(video_frame.matrix, f'Shift+num to select axis', (20, 120), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv.LINE_AA)
- cv.putText(video_frame.matrix, f'Right click and drag to edit axis', (20, 160), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv.LINE_AA)
- cv.putText(video_frame.matrix, f'Ctrl+s to save scene', (20, 200), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv.LINE_AA)
+ cv.putText(video_frame.matrix, f'T to translate, R to rotate', (20, 120), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv.LINE_AA)
+ cv.putText(video_frame.matrix, f'Shift+num to select axis', (20, 160), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv.LINE_AA)
+ cv.putText(video_frame.matrix, f'Right click and drag to edit axis', (20, 200), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv.LINE_AA)
+ cv.putText(video_frame.matrix, f'Ctrl+s to save scene', (20, 240), cv.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255), 1, cv.LINE_AA)
# Project 3D scene on each video frame and the visualisation frame
if aruco_tracker.get_markers_number():
@@ -268,17 +276,31 @@ def main():
if right_button:
- pointer_delta_x, pointer_delta_y = (right_click[0] - video_frame.width/2) / (video_frame.width/3), (video_frame.height/2 - right_click[1]) / (video_frame.width/3)
+ pointer_delta_x, pointer_delta_y = (right_click[0] - marker_x) / (video_frame.width/3), (marker_y - right_click[1]) / (video_frame.width/3)
+
+ if edit_trans:
- # Edit scene rotation
- if edit_coord == 0:
- aoi3D_scene_edit['rotation'] = numpy.array([pointer_delta_y, aoi3D_scene_edit['rotation'][1], aoi3D_scene_edit['rotation'][2]])
+ # Edit scene rotation
+ if edit_coord == 0:
+ aoi3D_scene_edit['rotation'] = numpy.array([pointer_delta_y, aoi3D_scene_edit['rotation'][1], aoi3D_scene_edit['rotation'][2]])
+
+ elif edit_coord == 1:
+ aoi3D_scene_edit['rotation'] = numpy.array([aoi3D_scene_edit['rotation'][0], pointer_delta_x, aoi3D_scene_edit['rotation'][2]])
+
+ elif edit_coord == 2:
+ aoi3D_scene_edit['rotation'] = numpy.array([aoi3D_scene_edit['rotation'][0], aoi3D_scene_edit['rotation'][1], -1*pointer_delta_y])
+
+ else:
- elif edit_coord == 1:
- aoi3D_scene_edit['rotation'] = numpy.array([aoi3D_scene_edit['rotation'][0], pointer_delta_x, aoi3D_scene_edit['rotation'][2]])
+ # Edit scene translation
+ if edit_coord == 0:
+ aoi3D_scene_edit['translation'] = numpy.array([pointer_delta_x, aoi3D_scene_edit['translation'][1], aoi3D_scene_edit['translation'][2]])
- elif edit_coord == 2:
- aoi3D_scene_edit['rotation'] = numpy.array([aoi3D_scene_edit['rotation'][0], aoi3D_scene_edit['rotation'][1], pointer_delta_x])
+ elif edit_coord == 1:
+ aoi3D_scene_edit['translation'] = numpy.array([aoi3D_scene_edit['translation'][0], pointer_delta_y, aoi3D_scene_edit['translation'][2]])
+
+ elif edit_coord == 2:
+ aoi3D_scene_edit['translation'] = numpy.array([aoi3D_scene_edit['translation'][0], aoi3D_scene_edit['translation'][1], 2*pointer_delta_y])
# Apply transformation
aoi3D_scene_edited = aoi3D_scene.transform(aoi3D_scene_edit['translation'], aoi3D_scene_edit['rotation'])
@@ -337,7 +359,15 @@ def main():
if frame_index < 0:
frame_index = 0
- # Select coordinate to edit
+ # Edit rotation with r key
+ if key_pressed == 114:
+ edit_trans = True
+
+ # Edit translation with t key
+ if key_pressed == 116:
+ edit_trans = False
+
+ # Select coordinate to edit with Shift + 0, 1 or 2
if key_pressed == 49 or key_pressed == 50 or key_pressed == 51:
edit_coord = key_pressed - 49