diff options
author | Théo de la Hogue | 2023-01-24 16:54:05 +0100 |
---|---|---|
committer | Théo de la Hogue | 2023-01-24 16:54:05 +0100 |
commit | 768fce136c412e128ec5a527d5ec11c8fdd47d7f (patch) | |
tree | 75d426519d6dfa4ef2c2bf3b21720bd203b82c72 /src | |
parent | a4f6baf40f1d75a14d346b8a8c4029c3cfbd4607 (diff) | |
download | argaze-768fce136c412e128ec5a527d5ec11c8fdd47d7f.zip argaze-768fce136c412e128ec5a527d5ec11c8fdd47d7f.tar.gz argaze-768fce136c412e128ec5a527d5ec11c8fdd47d7f.tar.bz2 argaze-768fce136c412e128ec5a527d5ec11c8fdd47d7f.tar.xz |
Fixing gaze position data acquisition. Updating data stream subscription mecanism.
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/utils/tobii_stream_display.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/argaze/utils/tobii_stream_display.py b/src/argaze/utils/tobii_stream_display.py index 55051e5..b979e03 100644 --- a/src/argaze/utils/tobii_stream_display.py +++ b/src/argaze/utils/tobii_stream_display.py @@ -59,8 +59,9 @@ def main(): # Init head rotation speed head_rotation_speed = numpy.zeros(3).astype(int) - # Init gaze position - gaze_position_px = GazeFeatures.GazePosition((0, 0)) + # Init gaze position and precision + gaze_position_px = (0, 0) + gaze_precision_px = 0 # Init data timestamped in millisecond data_ts_ms = 0 @@ -78,6 +79,7 @@ def main(): nonlocal head_rotation_speed nonlocal gaze_position_px + nonlocal gaze_precision_px nonlocal data_ts_ms nonlocal gyroscope_chrono nonlocal gaze_chrono @@ -102,7 +104,7 @@ def main(): # Ignore frame when gaze position is not valid if data_object.validity == 0: - gaze_position_px = GazeFeatures.GazePosition( (int(data_object.value[0] * video_frame.width), int(data_object.value[1] * video_frame.height)) ) + gaze_position_px = (int(data_object.value[0] * video_frame.width), int(data_object.value[1] * video_frame.height)) case 'GazePosition3D': @@ -112,9 +114,10 @@ def main(): gaze_precision_mm = numpy.tan(numpy.deg2rad(TobiiSpecifications.PRECISION)) * data_object.value[2] tobii_camera_hfov_mm = numpy.tan(numpy.deg2rad(TobiiSpecifications.CAMERA_HFOV / 2)) * data_object.value[2] - gaze_position_px.precision = round(video_frame.width * float(gaze_precision_mm) / float(tobii_camera_hfov_mm)) - - tobii_data_stream.reading_callback = data_stream_callback + gaze_precision_px = round(video_frame.width * float(gaze_precision_mm) / float(tobii_camera_hfov_mm)) + + # Subscribe to tobii data stream + tobii_data_stream.subscribe(data_stream_callback) # Start streaming tobii_controller.start_streaming() @@ -151,7 +154,8 @@ def main(): cv.line(video_frame.matrix, (int(video_frame.width/2), int(video_frame.height/2)), (int(video_frame.width/2) + head_rotation_speed[1], int(video_frame.height/2) - head_rotation_speed[0]), (150, 150, 150), 3) # Draw gaze - gaze_position_px.draw(video_frame.matrix) + gaze_position = GazeFeatures.GazePosition(gaze_position_px, precision=gaze_precision_px) + gaze_position.draw(video_frame.matrix) # Draw center cv.line(video_frame.matrix, (int(video_frame.width/2) - 50, int(video_frame.height/2)), (int(video_frame.width/2) + 50, int(video_frame.height/2)), (255, 150, 150), 1) |