aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2022-04-06 17:51:29 +0200
committerThéo de la Hogue2022-04-06 17:51:29 +0200
commitf012c3e8630f9f274c7eb0600480ab35cd56a2e1 (patch)
tree31ac3d993203753522b7ce0a98cb33501e87e275 /src
parent3dd08c5f7e5422e7aa133a672b412a7d30acc0d5 (diff)
downloadargaze-f012c3e8630f9f274c7eb0600480ab35cd56a2e1.zip
argaze-f012c3e8630f9f274c7eb0600480ab35cd56a2e1.tar.gz
argaze-f012c3e8630f9f274c7eb0600480ab35cd56a2e1.tar.bz2
argaze-f012c3e8630f9f274c7eb0600480ab35cd56a2e1.tar.xz
Simplifying synchronisation code
Diffstat (limited to 'src')
-rw-r--r--src/argaze/utils/live_tobii_session.py16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/argaze/utils/live_tobii_session.py b/src/argaze/utils/live_tobii_session.py
index d4a89b8..7226860 100644
--- a/src/argaze/utils/live_tobii_session.py
+++ b/src/argaze/utils/live_tobii_session.py
@@ -3,7 +3,7 @@
import argparse
import os, time
-from argaze import GazeFeatures, DataStructures
+from argaze import DataStructures
from argaze.TobiiGlassesPro2 import *
import cv2 as cv
@@ -50,18 +50,10 @@ def main():
data_stream = tobii_data_stream.read()
# Store received gaze positions
- for ts in list(data_stream.gidx_l_gp.keys()):
- past_gaze_positions[ts] = data_stream.gidx_l_gp.pop(ts)
+ past_gaze_positions.append(data_stream.gidx_l_gp)
- # Get last gaze position timestamp before video timestamp
- earliest_ts = past_gaze_positions.get_last_before(video_ts)
-
- # When no timestamped gaze position have been found
- if earliest_ts == None:
- raise ValueError
-
- # Get last gaze position value and remove all former gaze positions
- earliest_ts, earliest_gaze_position = past_gaze_positions.pop_first_until(earliest_ts)
+ # Get last gaze position before video timestamp and remove all former gaze positions
+ earliest_ts, earliest_gaze_position = past_gaze_positions.pop_first_until(video_ts)
# Draw video synchronized gaze pointer
pointer = (int(earliest_gaze_position.gp[0] * video_frame.width), int(earliest_gaze_position.gp[1] * video_frame.height))