aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2023-03-22 16:54:01 +0100
committerThéo de la Hogue2023-03-22 16:54:01 +0100
commiteff96fd34b0dec1f069fafde56fe82e5d584a3a3 (patch)
treef4a7008c958a3f273f8142d1d90eeb3082b115ee /src
parent506b7019f4931097f4c87158a6787c56a79ee4bb (diff)
downloadargaze-eff96fd34b0dec1f069fafde56fe82e5d584a3a3.zip
argaze-eff96fd34b0dec1f069fafde56fe82e5d584a3a3.tar.gz
argaze-eff96fd34b0dec1f069fafde56fe82e5d584a3a3.tar.bz2
argaze-eff96fd34b0dec1f069fafde56fe82e5d584a3a3.tar.xz
Removing VisualScan features for now.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/GazeFeatures.py168
1 files changed, 5 insertions, 163 deletions
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py
index dd4fc20..5c8039a 100644
--- a/src/argaze/GazeFeatures.py
+++ b/src/argaze/GazeFeatures.py
@@ -237,6 +237,11 @@ class GazeMovementIdentifier():
"""Abstract class to define what should provide a gaze movement identifier."""
def identify(self, ts, gaze_position, terminate=False) -> GazeMovementType:
+ """Identify gaze movement from successive timestamped gaze positions.
+
+ The optional *terminate* argument allows to notify identification algorithm that given gaze position will be the last one.
+ """
+
raise NotImplementedError('identify() method not implemented')
def browse(self, ts_gaze_positions: TimeStampedGazePositions) -> Tuple[TimeStampedGazeMovementsType, TimeStampedGazeMovementsType, TimeStampedGazeStatusType]:
@@ -281,166 +286,3 @@ class GazeMovementIdentifier():
continue
return ts_fixations, ts_saccades, ts_status
-
-@dataclass
-class VisualScanStep():
- """Define a visual scan step as a start timestamp, duration, the name of the area of interest and where gaze looked at in each frame during the step."""
-
- timestamp: int
- duration: float
- area: str
- look_at: DataStructures.TimeStampedBuffer
-
-class VisualScanGenerator():
- """Abstract class to define when an aoi starts to be looked and when it stops."""
-
- visual_scan_steps: list
-
- def __init__(self, ts_aoi_scenes: AOIFeatures.TimeStampedAOIScenes):
-
- if type(ts_aoi_scenes) != AOIFeatures.TimeStampedAOIScenes:
- raise ValueError('argument must be a TimeStampedAOIScenes')
-
- self.visual_scan_steps = []
-
- for step in self:
-
- if step == None:
- continue
-
- self.visual_scan_steps.append(step)
-
- def __iter__(self):
- raise NotImplementedError('__iter__() method not implemented')
-
- def steps(self) -> list:
- """Get visual scan steps."""
-
- return self.visual_scan_steps
-
- def as_dataframe(self) -> pandas.DataFrame:
- """Convert buffer as pandas dataframe."""
-
- df = pandas.DataFrame.from_dict(self.visual_scan_steps)
- df.set_index('timestamp', inplace=True)
- df.sort_values(by=['timestamp'], inplace=True)
-
- return df
-
- def save_as_csv(self, filepath):
- """Write buffer content into a csv file."""
-
- try:
-
- self.as_dataframe().to_csv(filepath, index=True)
-
- except:
- raise RuntimeError(f'Can\' write {filepath}')
-
-class PointerBasedVisualScan(VisualScanGenerator):
- """Build visual scan on the basis of which AOI are looked."""
-
- def __init__(self, ts_aoi_scenes: AOIFeatures.TimeStampedAOIScenes, ts_gaze_positions: TimeStampedGazePositions):
-
- # process identification on a copy
- self.__ts_aoi_scenes = ts_aoi_scenes.copy()
- self.__ts_gaze_positions = ts_gaze_positions.copy()
-
- # a dictionary to store when an aoi starts to be looked
- self.__step_dict = {}
-
- # build visual scan
- super().__init__(ts_aoi_scenes)
-
- def __iter__(self):
- """Visual scan generator function."""
-
- # while there is aoi scene to process
- while len(self.__ts_aoi_scenes) > 0:
-
- (ts_current, aoi_scene_current) = self.__ts_aoi_scenes.pop_first()
-
- # is aoi scene a missing exception ?
- try:
-
- raise aoi_scene_current
-
- # when aoi scene is missing
- except AOIFeatures.AOISceneMissing as e:
- pass
-
- # when aoi scene is not missing
- except:
-
- try:
-
- gaze_position = self.__ts_gaze_positions[ts_current]
-
- # is aoi scene a missing exception ?
- raise gaze_position
-
- # when gaze position is missing
- except GazePositionMissing as e:
- pass
-
- # when there is no gaze position at current time
- except KeyError as e:
- pass
-
- # when gaze position is not missing
- except:
-
- for name, aoi in aoi_scene_current.items():
-
- looked = aoi.contains_point(gaze_position)
-
- if looked:
-
- if not name in self.__step_dict.keys():
-
- # aoi starts to be looked
- self.__step_dict[name] = {
- 'start': ts_current,
- 'look_at': DataStructures.TimeStampedBuffer()
- }
-
- # store where the aoi is looked for 4 corners aoi
- if len(aoi) == 4:
- self.__step_dict[name]['look_at'][round(ts_current)] = aoi.inner_axis(gaze_position)
-
- elif name in self.__step_dict.keys():
-
- 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]
-
- # close started steps
- for name, step in self.__step_dict.items():
-
- ts_start = step['start']
-
- # aoi stops to be looked
- yield VisualScanStep(round(ts_start), round(ts_current - ts_start), name, step['look_at'])
-
-class FixationBasedVisualScan(VisualScanGenerator):
- """Build visual scan on the basis of timestamped fixations."""
-
- def __init__(self, ts_aoi_scenes: AOIFeatures.TimeStampedAOIScenes, ts_fixations: TimeStampedGazeMovements):
-
- super().__init__(ts_aoi_scenes)
-
- if type(ts_fixations) != TimeStampedGazeMovements:
- raise ValueError('second argument must be a GazeFeatures.TimeStampedGazeMovements')
-
- # process identification on a copy
- self.__ts_aoi_scenes = ts_aoi_scenes.copy()
- self.__ts_fixations = ts_fixations.copy()
-
- def __iter__(self):
- """Visual scan generator function."""
-
- yield -1, None