aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze/GazeFeatures.py65
1 files changed, 40 insertions, 25 deletions
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py
index acdbec8..4d7103b 100644
--- a/src/argaze/GazeFeatures.py
+++ b/src/argaze/GazeFeatures.py
@@ -27,10 +27,13 @@ class TimeStampedGazeAccuracies(DataStructures.TimeStampedBuffer):
def __setitem__(self, key, value: GazeAccuracy):
super().__setitem__(key, value)
-class InvalidGazeData(Exception):
- """Exception to raise when gaze position or accuracy can't be processed."""
+class GazeDataMissing(Exception):
+ """Exception to raise when gaze position or accuracy is missing."""
pass
+GazePositionMissingItem = GazePosition
+GazeAccuracyMissingItem = GazeAccuracy
+
@dataclass
class Movement():
"""Define abstract movement class."""
@@ -308,41 +311,53 @@ class PointerBasedVisualScan(VisualScanGenerator):
(ts_current, aoi_scene_current) = self.__ts_aoi_scenes.pop_first()
- try:
+ # is aoi scene a missing exception ?
+ try: raise aoi_scene_current
+
+ # when aoi scene is missing
+ except AOIFeatures.AOISceneMissing as e:
- gaze_position = self.__ts_gaze_positions[ts_current]
+ #print(ts_current, e)
+ pass
- for name, aoi in aoi_scene_current.items():
+ # when aoi scene is not missing
+ except:
- looked = aoi.looked(gaze_position)
+ try:
- if looked:
+ gaze_position = self.__ts_gaze_positions[ts_current]
- if not name in self.__step_dict.keys():
+ for name, aoi in aoi_scene_current.items():
- # aoi starts to be looked
- self.__step_dict[name] = {
- 'start': ts_current,
- 'look_at': DataStructures.TimeStampedBuffer()
- }
+ looked = aoi.looked(gaze_position)
- # store where the aoi is looked for 4 corners aoi
- if len(aoi) == 4:
- self.__step_dict[name]['look_at'][round(ts_current)] = aoi.look_at(gaze_position)
+ if looked:
- elif name in self.__step_dict.keys():
+ if not name in self.__step_dict.keys():
- ts_start = self.__step_dict[name]['start']
+ # aoi starts to be looked
+ self.__step_dict[name] = {
+ 'start': ts_current,
+ 'look_at': DataStructures.TimeStampedBuffer()
+ }
- # aoi stops to be looked
- yield VisualScanStep(round(ts_start), round(ts_current - ts_start), name, self.__step_dict[name]['look_at'])
+ # store where the aoi is looked for 4 corners aoi
+ if len(aoi) == 4:
+ self.__step_dict[name]['look_at'][round(ts_current)] = aoi.look_at(gaze_position)
- # forget the aoi
- del self.__step_dict[name]
+ elif name in self.__step_dict.keys():
- # ignore missing gaze position
- except KeyError:
- pass
+ ts_start = self.__step_dict[name]['start']
+
+ # aoi stops to be looked
+ yield VisualScanStep(round(ts_start), round(ts_current - ts_start), name, self.__step_dict[name]['look_at'])
+
+ # forget the aoi
+ del self.__step_dict[name]
+
+ # ignore missing gaze position
+ except KeyError:
+ pass
# close started steps
for name, step in self.__step_dict.items():