aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/utils/export_tobii_segment_aruco_visual_scan.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/argaze/utils/export_tobii_segment_aruco_visual_scan.py')
-rw-r--r--src/argaze/utils/export_tobii_segment_aruco_visual_scan.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/argaze/utils/export_tobii_segment_aruco_visual_scan.py b/src/argaze/utils/export_tobii_segment_aruco_visual_scan.py
index 1978b44..04e21d6 100644
--- a/src/argaze/utils/export_tobii_segment_aruco_visual_scan.py
+++ b/src/argaze/utils/export_tobii_segment_aruco_visual_scan.py
@@ -208,6 +208,9 @@ def main():
# Project 3D scene on each video frame and the visualisation frame
if aruco_tracker.get_markers_number():
+ # Store aoi 2D video for further scene merging
+ aoi2D_dict = {}
+
for (i, marker_id) in enumerate(aruco_tracker.get_markers_ids()):
# Select 3D scene related to detected marker
@@ -223,11 +226,13 @@ def main():
# This hack isn't realistic but as the gaze will mainly focus on centered AOI, where the distorsion is low, it is acceptable.
aoi2D_video_scene = aoi3D_scene.project(aruco_camera.get_K())
- # Draw 2D scene on video frame excluding 'Visualisation_Plan' aoi
- aoi2D_video_scene.draw(video_frame.matrix, video_gaze_pixel, ['Visualisation_Plan'])
+ # Store each 2D aoi for further scene merging
+ for name, aoi in aoi2D_video_scene.items():
+
+ if name not in aoi2D_dict.keys():
+ aoi2D_dict[name] = []
- # Store 2D scene at this time in millisecond
- ts_aois_scenes[round(video_ts_ms)] = aoi2D_video_scene
+ aoi2D_dict[name].append(aoi.clockwise())
# Select 2D visu scene if there is one for the detected marker
aoi2D_visu_scene = aoi2D_visu_scene_selector(marker_id)
@@ -240,7 +245,17 @@ def main():
visu_gaze_pixel = aoi2D_visu_scene['Visualisation_Plan'].looked_pixel(look_at)
cv.circle(aoi2D_visu_frame, visu_gaze_pixel, 4, (0, 0, 255), -1)
+
+ # Merge all 2D aoi into a single 2D scene
+ aoi2D_merged_scene = AOI2DScene.AOI2DScene()
+ for name, aoi_array in aoi2D_dict.items():
+ aoi2D_merged_scene[name] = numpy.sum(aoi_array, axis=0) / len(aoi_array)
+
+ aoi2D_merged_scene.draw(video_frame.matrix, video_gaze_pixel, exclude=['Visualisation_Plan'])
+ # Store 2D merged scene at this time in millisecond
+ ts_aois_scenes[round(video_ts_ms)] = aoi2D_merged_scene
+
if args.window:
# Close window using 'Esc' key