aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/ArFeatures.py53
1 files changed, 37 insertions, 16 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index 3e381ef..8c29e0d 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -435,7 +435,7 @@ 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) -> Tuple[GazeFeatures.GazeMovement, dict, dict, dict]:
+ def look(self, timestamp: int|float, inner_gaze_position: GazeFeatures.GazePosition, current_fixation_matching: bool = False) -> Tuple[GazeFeatures.GazeMovement, dict, dict, dict]:
"""
GazeFeatures.AOIScanStepError
@@ -454,7 +454,7 @@ class ArFrame():
self.__gaze_position = inner_gaze_position
# No fixation is identified by default
- fixation = GazeFeatures.UnvalidGazeMovement()
+ returned_fixation = GazeFeatures.UnvalidGazeMovement()
# Init scan path analysis report
scan_step_analysis = {}
@@ -491,14 +491,14 @@ class ArFrame():
if GazeFeatures.is_fixation(finished_gaze_movement):
- # Update current fixation
- fixation = finished_gaze_movement
+ # Update returned fixation
+ returned_fixation = finished_gaze_movement
# Store aoi matching start date
matching_start = time.time()
- # Does the fixation match an aoi?
- self.__update_looked_aoi_data(fixation)
+ # Does the finished fixation match an aoi?
+ self.__update_looked_aoi_data(finished_gaze_movement)
# Assess aoi matching time in ms
times['aoi_matcher'] = (time.time() - matching_start) * 1e3
@@ -525,7 +525,7 @@ class ArFrame():
aoi_scan_path_analyzer.analyze(self.aoi_scan_path)
# Assess aoi scan step analysis time in ms
- times[aoi_scan_path_analyzer_type] = (time.time() - aoi_scan_step_analysis_start) * 1e3
+ times['aoi_scan_step_analyzers'][aoi_scan_path_analyzer_type] = (time.time() - aoi_scan_step_analysis_start) * 1e3
# Store analysis
aoi_scan_step_analysis[aoi_scan_path_analyzer_type] = aoi_scan_path_analyzer.analysis
@@ -552,7 +552,7 @@ class ArFrame():
scan_path_analyzer.analyze(self.scan_path)
# Assess scan step analysis time in ms
- times[scan_path_analyzer_type] = (time.time() - scan_step_analysis_start) * 1e3
+ times['scan_step_analyzers'][scan_path_analyzer_type] = (time.time() - scan_step_analysis_start) * 1e3
# Store analysis
scan_step_analysis[scan_path_analyzer_type] = scan_path_analyzer.analysis
@@ -562,21 +562,21 @@ class ArFrame():
self.aoi_scan_path.append_saccade(timestamp, finished_gaze_movement)
- # No valid finished gaze movement: check current fixation
- else:
+ # No valid finished gaze movement: optionnaly check current fixation matching
+ elif current_fixation_matching:
current_fixation = self.gaze_movement_identifier.current_fixation
if current_fixation.valid:
- # Update current fixation
- fixation = current_fixation
+ # Update returned fixation
+ returned_fixation = current_fixation
# Store aoi matching start date
matching_start = time.time()
- # Does the fixation match an aoi?
- self.__update_looked_aoi_data(fixation)
+ # Does the current fixation match an aoi?
+ self.__update_looked_aoi_data(current_fixation)
# Assess aoi matching time in ms
times['aoi_matcher'] = (time.time() - matching_start) * 1e3
@@ -596,7 +596,7 @@ class ArFrame():
print(e)
- fixation = GazeFeatures.UnvalidGazeMovement()
+ returned_fixation = GazeFeatures.UnvalidGazeMovement()
scan_step_analysis = {}
aoi_scan_step_analysis = {}
exception = e
@@ -604,8 +604,29 @@ class ArFrame():
# Unlock frame exploitation
self.__look_lock.release()
+ # Sum all times
+ total_time = 0
+
+ if times['gaze_movement_identifier']:
+
+ total_time += times['gaze_movement_identifier']
+
+ if times['aoi_matcher']:
+
+ total_time += times['aoi_matcher']
+
+ for _, scan_step_analysis_time in times['scan_step_analyzers'].items():
+
+ total_time += scan_step_analysis_time
+
+ for _, aoi_scan_step_analysis_time in times['aoi_scan_step_analyzers'].items():
+
+ total_time += aoi_scan_step_analysis_time
+
+ times['total'] = total_time
+
# Return look data
- return fixation, scan_step_analysis, aoi_scan_step_analysis, times, exception
+ return returned_fixation, scan_step_analysis, aoi_scan_step_analysis, times, exception
def draw(self, image:numpy.array, aoi_color=(0, 0, 0)) -> Exception:
"""