aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/utils/contexts/TobiiProGlasses2.py
diff options
context:
space:
mode:
authorThéo de la Hogue2024-04-23 11:21:33 +0200
committerThéo de la Hogue2024-04-23 11:21:33 +0200
commitf4914d604e8652b45fba4272ebabbeecce95595c (patch)
tree8d8269399d957d1c3b742d87bbff194cb59188f5 /src/argaze/utils/contexts/TobiiProGlasses2.py
parentc9a83f1447862429108ff2943bb1976b66df2b4e (diff)
downloadargaze-f4914d604e8652b45fba4272ebabbeecce95595c.zip
argaze-f4914d604e8652b45fba4272ebabbeecce95595c.tar.gz
argaze-f4914d604e8652b45fba4272ebabbeecce95595c.tar.bz2
argaze-f4914d604e8652b45fba4272ebabbeecce95595c.tar.xz
Defining new abstract contexts for live and post processing.
Diffstat (limited to 'src/argaze/utils/contexts/TobiiProGlasses2.py')
-rw-r--r--src/argaze/utils/contexts/TobiiProGlasses2.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/argaze/utils/contexts/TobiiProGlasses2.py b/src/argaze/utils/contexts/TobiiProGlasses2.py
index 57668c6..4491c34 100644
--- a/src/argaze/utils/contexts/TobiiProGlasses2.py
+++ b/src/argaze/utils/contexts/TobiiProGlasses2.py
@@ -1124,19 +1124,21 @@ class LiveStream(ArFeatures.ArContext):
json_data = self.__post_request('/api/system/conf/', data)
-class PostProcessing(ArFeatures.ArContext):
+class PostProcessing(ArFeatures.PostProcessingContext):
@DataFeatures.PipelineStepInit
def __init__(self, **kwargs):
- # Init ArContext class
+ # Init parent class
super().__init__()
# Init private attributes
self.__segment = None
- self.__start = math.nan
+ self.__start = 0.
self.__end = math.nan
self.__parser = TobiiJsonDataParser()
+ self.__duration = 0.
+ self.__progression = 0.
self.__data_counts_dict = {
'DirSig': 0,
@@ -1249,6 +1251,9 @@ class PostProcessing(ArFeatures.ArContext):
if self.start >= self.end:
raise ValueError('Start reading timestamp is equal or greater than end reading timestamp.')
+ self.__duration = self.end - self.start
+ self.__progression = 0.
+
# TODO: log various info
calibrated = bool(info["seg_calibrated"])
start_date = datetime.datetime.strptime(info["seg_t_start"], TOBII_DATETIME_FORMAT)
@@ -1351,7 +1356,7 @@ class PostProcessing(ArFeatures.ArContext):
# Catch inconstistent timestamps
if self.__last_data_ts is not None:
- if self.__data_ts - self.__last_data_ts <= 0:
+ if data_ts - self.__last_data_ts <= 0:
logging.error('! %i gaze position more recent than the previous one', data_ts)
@@ -1378,6 +1383,9 @@ class PostProcessing(ArFeatures.ArContext):
# Process empty gaze position
self._process_gaze_position(timestamp=data_ts)
+ # Update progression
+ self.__progression = (video_ts - self.start) / self.__duration
+
# Set stop event ourself
self._stop_event.set()
@@ -1484,3 +1492,14 @@ class PostProcessing(ArFeatures.ArContext):
# Return millisecond timestamp, data object and type
return ts * 1e-3, data_object, data_object_type
+ @property
+ def duration(self) -> int|float:
+ """Get data duration."""
+
+ return self.__duration
+
+ @property
+ def progression(self) -> float:
+ """Get data processing progression between 0 and 1."""
+
+ return self.__progression \ No newline at end of file