diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/ArFeatures.py | 164 |
1 files changed, 82 insertions, 82 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index def7675..0ed581d 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -167,11 +167,11 @@ class ArFrame(): gaze_movement_identifier_type, gaze_movement_identifier_parameters = gaze_movement_identifier_value.popitem() gaze_movement_identifier_module = importlib.import_module(f'argaze.GazeAnalysis.{gaze_movement_identifier_type}') - temp_gaze_movement_identifier = gaze_movement_identifier_module.GazeMovementIdentifier(**gaze_movement_identifier_parameters) + new_gaze_movement_identifier = gaze_movement_identifier_module.GazeMovementIdentifier(**gaze_movement_identifier_parameters) except KeyError: - temp_gaze_movement_identifier = None + new_gaze_movement_identifier = None # Current fixation matching try: @@ -328,7 +328,7 @@ class ArFrame(): new_frame_size, \ new_aoi_2d_scene, \ new_frame_background, \ - temp_gaze_movement_identifier, \ + new_gaze_movement_identifier, \ current_fixation_matching, \ looked_aoi_covering_threshold, \ new_scan_path, \ @@ -483,127 +483,127 @@ class ArFrame(): # Catch any error exception = None - #try: + try: - # Identify gaze movement - if self.gaze_movement_identifier: + # Identify gaze movement + if self.gaze_movement_identifier: - # Store movement identification start date - identification_start = time.time() + # Store movement identification start date + identification_start = time.time() - # Identify finished gaze movement - temp_gaze_movement = self.gaze_movement_identifier.identify(timestamp, self.__gaze_position) + # Identify finished gaze movement + temp_gaze_movement = self.gaze_movement_identifier.identify(timestamp, self.__gaze_position) - # Assess movement identification time in ms - times['gaze_movement_identifier'] = (time.time() - identification_start) * 1e3 + # Assess movement identification time in ms + times['gaze_movement_identifier'] = (time.time() - identification_start) * 1e3 - # Use given identified gaze movement - else: + # Use given identified gaze movement + else: - temp_gaze_movement = identified_gaze_movement + temp_gaze_movement = identified_gaze_movement - # Valid and finished gaze movement has been identified - if temp_gaze_movement.valid and temp_gaze_movement.finished: + # Valid and finished gaze movement has been identified + if temp_gaze_movement.valid and temp_gaze_movement.finished: - if GazeFeatures.is_fixation(temp_gaze_movement): + if GazeFeatures.is_fixation(temp_gaze_movement): - # Store aoi matching start date - matching_start = time.time() + # Store aoi matching start date + matching_start = time.time() - # Does the finished fixation match an aoi? - self.__update_looked_aoi_data(temp_gaze_movement) + # Does the finished fixation match an aoi? + self.__update_looked_aoi_data(temp_gaze_movement) - # Assess aoi matching time in ms - times['aoi_matcher'] = (time.time() - matching_start) * 1e3 + # Assess aoi matching time in ms + times['aoi_matcher'] = (time.time() - matching_start) * 1e3 - # Append fixation to scan path - if self.scan_path != None: + # Append fixation to scan path + if self.scan_path != None: - self.scan_path.append_fixation(timestamp, temp_gaze_movement) + self.scan_path.append_fixation(timestamp, temp_gaze_movement) - # 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 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: - aoi_scan_step = self.aoi_scan_path.append_fixation(timestamp, temp_gaze_movement, self.looked_aoi) + aoi_scan_step = self.aoi_scan_path.append_fixation(timestamp, temp_gaze_movement, self.looked_aoi) - # Is there a new step? - if aoi_scan_step and len(self.aoi_scan_path) > 1: + # Is there a new step? + if aoi_scan_step and len(self.aoi_scan_path) > 1: - for aoi_scan_path_analyzer_type, aoi_scan_path_analyzer in self.aoi_scan_path_analyzers.items(): + for aoi_scan_path_analyzer_type, aoi_scan_path_analyzer in self.aoi_scan_path_analyzers.items(): - # Store aoi scan step analysis start date - aoi_scan_step_analysis_start = time.time() + # Store aoi scan step analysis start date + aoi_scan_step_analysis_start = time.time() - # Analyze aoi scan path - aoi_scan_path_analyzer.analyze(self.aoi_scan_path) + # Analyze aoi scan path + aoi_scan_path_analyzer.analyze(self.aoi_scan_path) - # 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 + # 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 analysis - aoi_scan_step_analysis[aoi_scan_path_analyzer_type] = aoi_scan_path_analyzer.analysis + # Store analysis + aoi_scan_step_analysis[aoi_scan_path_analyzer_type] = aoi_scan_path_analyzer.analysis - elif GazeFeatures.is_saccade(temp_gaze_movement): + elif GazeFeatures.is_saccade(temp_gaze_movement): - # Reset looked aoi - self.__init_looked_aoi_data() + # Reset looked aoi + self.__init_looked_aoi_data() - # Append saccade to scan path - if self.scan_path != None: - - scan_step = self.scan_path.append_saccade(timestamp, temp_gaze_movement) + # Append saccade to scan path + if self.scan_path != None: + + scan_step = self.scan_path.append_saccade(timestamp, temp_gaze_movement) - # Is there a new step? - if scan_step and len(self.scan_path) > 1: + # Is there a new step? + if scan_step and len(self.scan_path) > 1: - for scan_path_analyzer_type, scan_path_analyzer in self.scan_path_analyzers.items(): + for scan_path_analyzer_type, scan_path_analyzer in self.scan_path_analyzers.items(): - # Store scan step analysis start date - scan_step_analysis_start = time.time() + # Store scan step analysis start date + scan_step_analysis_start = time.time() - # Analyze aoi scan path - scan_path_analyzer.analyze(self.scan_path) + # Analyze aoi scan path + scan_path_analyzer.analyze(self.scan_path) - # Assess scan step analysis time in ms - times['scan_step_analyzers'][scan_path_analyzer_type] = (time.time() - scan_step_analysis_start) * 1e3 + # Assess scan step analysis time in ms + 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 + # Store analysis + scan_step_analysis[scan_path_analyzer_type] = scan_path_analyzer.analysis - # Append saccade to aoi scan path - if self.aoi_scan_path != None: + # Append saccade to aoi scan path + if self.aoi_scan_path != None: - self.aoi_scan_path.append_saccade(timestamp, temp_gaze_movement) + self.aoi_scan_path.append_saccade(timestamp, temp_gaze_movement) - # No valid finished gaze movement: optionnaly check current fixation matching - elif self.gaze_movement_identifier and self.current_fixation_matching: + # No valid finished gaze movement: optionnaly check current fixation matching + elif self.gaze_movement_identifier and self.current_fixation_matching: - current_fixation = self.gaze_movement_identifier.current_fixation + current_fixation = self.gaze_movement_identifier.current_fixation - if current_fixation.valid: + if current_fixation.valid: - temp_gaze_movement = current_fixation + temp_gaze_movement = current_fixation - # Store aoi matching start date - matching_start = time.time() + # Store aoi matching start date + matching_start = time.time() - # Does the current fixation match an aoi? - self.__update_looked_aoi_data(current_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 + # Assess aoi matching time in ms + times['aoi_matcher'] = (time.time() - matching_start) * 1e3 - # Update heatmap - if self.heatmap: + # Update heatmap + if self.heatmap: - # Store heatmap start date - heatmap_start = time.time() + # Store heatmap start date + heatmap_start = time.time() - self.heatmap.update(self.__gaze_position.value, sigma=0.05) + self.heatmap.update(self.__gaze_position.value, sigma=0.05) - # Assess heatmap time in ms - times['heatmap'] = (time.time() - heatmap_start) * 1e3 - ''' + # Assess heatmap time in ms + times['heatmap'] = (time.time() - heatmap_start) * 1e3 + except Exception as e: print(e) @@ -612,7 +612,7 @@ class ArFrame(): scan_step_analysis = {} aoi_scan_step_analysis = {} exception = e - ''' + # Unlock frame exploitation self.__look_lock.release() |