aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2023-07-28 18:24:48 +0200
committerThéo de la Hogue2023-07-28 18:24:48 +0200
commite6d977d43728daaa3330c9b6d2b51c8040bd102c (patch)
tree9e0abed337278e92b31d175b2433cbae6ed0ee16 /src
parent7cf38757911f0e791b8ea1d09b7e76af747c91d1 (diff)
downloadargaze-e6d977d43728daaa3330c9b6d2b51c8040bd102c.zip
argaze-e6d977d43728daaa3330c9b6d2b51c8040bd102c.tar.gz
argaze-e6d977d43728daaa3330c9b6d2b51c8040bd102c.tar.bz2
argaze-e6d977d43728daaa3330c9b6d2b51c8040bd102c.tar.xz
Allowing to pass already identified gaze movement to look method.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/ArFeatures.py167
1 files changed, 83 insertions, 84 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index 8c29e0d..456467f 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -435,13 +435,13 @@ class ArFrame():
# Update looked aoi covering mean
self.__looked_aoi_covering_mean = int(100 * max_covering / (len(fixation.positions) - 2)) / 100
- def look(self, timestamp: int|float, inner_gaze_position: GazeFeatures.GazePosition, current_fixation_matching: bool = False) -> Tuple[GazeFeatures.GazeMovement, dict, dict, dict]:
+ def look(self, timestamp: int|float, inner_gaze_position: GazeFeatures.GazePosition = GazeFeatures.UnvalidGazePosition(), identified_gaze_movement: GazeFeatures.GazeMovement = GazeFeatures.UnvalidGazeMovement(), current_fixation_matching: bool = False) -> Tuple[GazeFeatures.GazeMovement, dict, dict, dict]:
"""
GazeFeatures.AOIScanStepError
Returns:
- fixation: identified fixation (if gaze_movement_identifier is instanciated)
+ finished_gaze_movement: identified gaze movement (if gaze_movement_identifier is instanciated)
scan_step: new scan step (if scan_path is instanciated)
aoi_scan_step: new scan step (if aoi_scan_path is instanciated)
exception: error catched during gaze position processing
@@ -453,8 +453,8 @@ class ArFrame():
# Update current gaze position
self.__gaze_position = inner_gaze_position
- # No fixation is identified by default
- returned_fixation = GazeFeatures.UnvalidGazeMovement()
+ # No gaze movement identified by default
+ finished_gaze_movement = GazeFeatures.UnvalidGazeMovement()
# Init scan path analysis report
scan_step_analysis = {}
@@ -472,126 +472,125 @@ class ArFrame():
# Catch any error
exception = None
- try:
-
- # Identify gaze movement
- if self.gaze_movement_identifier:
+ #try:
- # Store movement identification start date
- identification_start = time.time()
+ # Identify gaze movement
+ if self.gaze_movement_identifier:
- # Identify finished gaze movement
- finished_gaze_movement = self.gaze_movement_identifier.identify(timestamp, self.__gaze_position)
+ # Store movement identification start date
+ identification_start = time.time()
- # Assess movement identification time in ms
- times['gaze_movement_identifier'] = (time.time() - identification_start) * 1e3
+ # Identify finished gaze movement
+ finished_gaze_movement = self.gaze_movement_identifier.identify(timestamp, self.__gaze_position)
- # Valid and finished gaze movement has been identified
- if finished_gaze_movement.valid:
+ # Assess movement identification time in ms
+ times['gaze_movement_identifier'] = (time.time() - identification_start) * 1e3
- if GazeFeatures.is_fixation(finished_gaze_movement):
+ # Use given identified gaze movement
+ else:
- # Update returned fixation
- returned_fixation = finished_gaze_movement
+ finished_gaze_movement = identified_gaze_movement
- # Store aoi matching start date
- matching_start = time.time()
+ # Valid and finished gaze movement has been identified
+ if finished_gaze_movement.valid:
- # Does the finished fixation match an aoi?
- self.__update_looked_aoi_data(finished_gaze_movement)
+ if GazeFeatures.is_fixation(finished_gaze_movement):
- # Assess aoi matching time in ms
- times['aoi_matcher'] = (time.time() - matching_start) * 1e3
+ # Store aoi matching start date
+ matching_start = time.time()
- # Append fixation to scan path
- if self.scan_path != None:
+ # Does the finished fixation match an aoi?
+ self.__update_looked_aoi_data(finished_gaze_movement)
- self.scan_path.append_fixation(timestamp, finished_gaze_movement)
+ # Assess aoi matching time in ms
+ times['aoi_matcher'] = (time.time() - matching_start) * 1e3
- # Append fixation to aoi scan path
- if self.aoi_scan_path != None and self.looked_aoi != None and self.looked_aoi_covering_mean > self.looked_aoi_covering_threshold:
+ # Append fixation to scan path
+ if self.scan_path != None:
- aoi_scan_step = self.aoi_scan_path.append_fixation(timestamp, finished_gaze_movement, self.looked_aoi)
+ self.scan_path.append_fixation(timestamp, finished_gaze_movement)
- # Is there a new step?
- if aoi_scan_step and len(self.aoi_scan_path) > 1:
+ # Append fixation to aoi scan path
+ if self.aoi_scan_path != None and self.looked_aoi != None and self.looked_aoi_covering_mean > self.looked_aoi_covering_threshold:
- for aoi_scan_path_analyzer_type, aoi_scan_path_analyzer in self.aoi_scan_path_analyzers.items():
+ aoi_scan_step = self.aoi_scan_path.append_fixation(timestamp, finished_gaze_movement, self.looked_aoi)
- # Store aoi scan step analysis start date
- aoi_scan_step_analysis_start = time.time()
+ # Is there a new step?
+ if aoi_scan_step and len(self.aoi_scan_path) > 1:
- # Analyze aoi scan path
- aoi_scan_path_analyzer.analyze(self.aoi_scan_path)
+ for aoi_scan_path_analyzer_type, aoi_scan_path_analyzer in self.aoi_scan_path_analyzers.items():
- # Assess aoi scan step analysis time in ms
- times['aoi_scan_step_analyzers'][aoi_scan_path_analyzer_type] = (time.time() - aoi_scan_step_analysis_start) * 1e3
+ # Store aoi scan step analysis start date
+ aoi_scan_step_analysis_start = time.time()
- # Store analysis
- aoi_scan_step_analysis[aoi_scan_path_analyzer_type] = aoi_scan_path_analyzer.analysis
+ # Analyze aoi scan path
+ aoi_scan_path_analyzer.analyze(self.aoi_scan_path)
- elif GazeFeatures.is_saccade(finished_gaze_movement):
+ # Assess aoi scan step analysis time in ms
+ times['aoi_scan_step_analyzers'][aoi_scan_path_analyzer_type] = (time.time() - aoi_scan_step_analysis_start) * 1e3
- # Reset looked aoi
- self.__init_looked_aoi_data()
+ # Store analysis
+ aoi_scan_step_analysis[aoi_scan_path_analyzer_type] = aoi_scan_path_analyzer.analysis
- # Append saccade to scan path
- if self.scan_path != None:
-
- scan_step = self.scan_path.append_saccade(timestamp, finished_gaze_movement)
+ elif GazeFeatures.is_saccade(finished_gaze_movement):
- # Is there a new step?
- if scan_step and len(self.scan_path) > 1:
+ # Reset looked aoi
+ self.__init_looked_aoi_data()
- for scan_path_analyzer_type, scan_path_analyzer in self.scan_path_analyzers.items():
+ # Append saccade to scan path
+ if self.scan_path != None:
+
+ scan_step = self.scan_path.append_saccade(timestamp, finished_gaze_movement)
- # Store scan step analysis start date
- scan_step_analysis_start = time.time()
+ # Is there a new step?
+ if scan_step and len(self.scan_path) > 1:
- # Analyze aoi scan path
- scan_path_analyzer.analyze(self.scan_path)
+ for scan_path_analyzer_type, scan_path_analyzer in self.scan_path_analyzers.items():
- # Assess scan step analysis time in ms
- times['scan_step_analyzers'][scan_path_analyzer_type] = (time.time() - scan_step_analysis_start) * 1e3
+ # Store scan step analysis start date
+ scan_step_analysis_start = time.time()
- # Store analysis
- scan_step_analysis[scan_path_analyzer_type] = scan_path_analyzer.analysis
+ # Analyze aoi scan path
+ scan_path_analyzer.analyze(self.scan_path)
- # Append saccade to aoi scan path
- if self.aoi_scan_path != None:
+ # Assess scan step analysis time in ms
+ times['scan_step_analyzers'][scan_path_analyzer_type] = (time.time() - scan_step_analysis_start) * 1e3
- self.aoi_scan_path.append_saccade(timestamp, finished_gaze_movement)
+ # Store analysis
+ scan_step_analysis[scan_path_analyzer_type] = scan_path_analyzer.analysis
- # No valid finished gaze movement: optionnaly check current fixation matching
- elif current_fixation_matching:
+ # Append saccade to aoi scan path
+ if self.aoi_scan_path != None:
- current_fixation = self.gaze_movement_identifier.current_fixation
+ self.aoi_scan_path.append_saccade(timestamp, finished_gaze_movement)
- if current_fixation.valid:
+ # No valid finished gaze movement: optionnaly check current fixation matching
+ elif self.gaze_movement_identifier and current_fixation_matching:
- # Update returned fixation
- returned_fixation = current_fixation
+ current_fixation = self.gaze_movement_identifier.current_fixation
- # Store aoi matching start date
- matching_start = time.time()
+ if current_fixation.valid:
- # Does the current fixation match an aoi?
- self.__update_looked_aoi_data(current_fixation)
+ # Store aoi matching start date
+ matching_start = time.time()
- # Assess aoi matching time in ms
- times['aoi_matcher'] = (time.time() - matching_start) * 1e3
+ # Does the current fixation match an aoi?
+ self.__update_looked_aoi_data(current_fixation)
- # Update heatmap
- if self.heatmap:
+ # Assess aoi matching time in ms
+ times['aoi_matcher'] = (time.time() - matching_start) * 1e3
- # Store heatmap start date
- heatmap_start = time.time()
+ # Update heatmap
+ if self.heatmap:
- self.heatmap.update(self.__gaze_position.value, sigma=0.05)
+ # Store heatmap start date
+ heatmap_start = time.time()
- # Assess heatmap time in ms
- times['heatmap'] = (time.time() - heatmap_start) * 1e3
+ self.heatmap.update(self.__gaze_position.value, sigma=0.05)
+ # Assess heatmap time in ms
+ times['heatmap'] = (time.time() - heatmap_start) * 1e3
+ '''
except Exception as e:
print(e)
@@ -600,7 +599,7 @@ class ArFrame():
scan_step_analysis = {}
aoi_scan_step_analysis = {}
exception = e
-
+ '''
# Unlock frame exploitation
self.__look_lock.release()
@@ -626,7 +625,7 @@ class ArFrame():
times['total'] = total_time
# Return look data
- return returned_fixation, scan_step_analysis, aoi_scan_step_analysis, times, exception
+ return finished_gaze_movement, scan_step_analysis, aoi_scan_step_analysis, times, exception
def draw(self, image:numpy.array, aoi_color=(0, 0, 0)) -> Exception:
"""