diff options
Diffstat (limited to 'src/argaze/ArFeatures.py')
-rw-r--r-- | src/argaze/ArFeatures.py | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index f90354a..e7b94c0 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -293,15 +293,7 @@ class ArLayer(DataFeatures.SharedObject): for logger_module_path, logger_parameters in new_loggers_value.items(): - # Prepend argaze.DataLog path when a single name is provided - if len(logger_module_path.split('.')) == 1: - logger_module_path = f'argaze.DataLog.{logger_module_path}' - - logger_module = importlib.import_module(logger_module_path) - - logger = logger_module.TimeStampedDataLogger(**logger_parameters) - - new_loggers[logger_module_path] = logger + new_loggers[logger_module_path] = DataFeatures.TimeStampedDataLogger.from_dict(logger_module_path, logger_parameters) except KeyError: @@ -365,7 +357,8 @@ class ArLayer(DataFeatures.SharedObject): gaze_movement: gaze movement to project Returns: - looked_aoi: most likely looked aoi name + looked_aoi_name: most likely looked aoi name + looked_aoi: most likely looked aoi shape aoi_scan_path_analysis: aoi scan path analysis at each new scan step if aoi_scan_path is instanciated exception: error catched during gaze movement processing """ @@ -446,6 +439,7 @@ class ArLayer(DataFeatures.SharedObject): print('Warning: the following error occurs in ArLayer.look method:', e) + looked_aoi_name = None looked_aoi = None aoi_scan_path_analysis = {} exception = e @@ -453,19 +447,25 @@ class ArLayer(DataFeatures.SharedObject): # Assess total execution time in ms execution_times['total'] = (time.perf_counter() - look_start) * 1e3 - # Edit look data - look_data = looked_aoi_name, aoi_scan_path_analysis, execution_times, exception + # Edit look data dictionary + look_data = { + "looked_aoi_name": looked_aoi_name, + "looked_aoi": looked_aoi, + "aoi_scan_path_analysis": DataFeatures.DataDictionary(aoi_scan_path_analysis), + "execution_times": DataFeatures.DataDictionary(execution_times), + "exception": exception + } # Log look data for logger_module_path, logger in self.loggers.items(): - logger.emit(timestamp, look_data) + logger.emit(timestamp, DataFeatures.DataDictionary(look_data)) # Unlock layer exploitation self.release() - # Return look data - return look_data + # Return look data values + return look_data.values() def draw(self, image: numpy.array, draw_aoi_scene: dict = None, draw_aoi_matching: dict = None): """ @@ -757,15 +757,6 @@ class ArFrame(DataFeatures.SharedObject): pass - # Load log status - try: - - new_frame_log = frame_data.pop('log') - - except KeyError: - - new_frame_log = False - # Load loggers new_loggers = {} @@ -775,15 +766,7 @@ class ArFrame(DataFeatures.SharedObject): for logger_module_path, logger_parameters in new_loggers_value.items(): - # Prepend argaze.DataLog path when a single name is provided - if len(logger_module_path.split('.')) == 1: - logger_module_path = f'argaze.DataLog.{logger_module_path}' - - logger_module = importlib.import_module(logger_module_path) - - logger = logger_module.TimeStampedDataLogger(**logger_parameters) - - new_loggers[logger_module_path] = logger + new_loggers[logger_module_path] = DataFeatures.TimeStampedDataLogger.from_dict(logger_module_path, logger_parameters) except KeyError: @@ -856,9 +839,9 @@ class ArFrame(DataFeatures.SharedObject): current_gaze_position: calibrated gaze position if gaze_position_calibrator is instanciated else, given gaze position. identified_gaze_movement: identified gaze movement from incoming consecutive timestamped gaze positions if gaze_movement_identifier is instanciated. Current gaze movement if filter_in_progress_identification is False. scan_path_analysis: scan path analysis at each new scan step if scan_path is instanciated. - layers_analysis: aoi scan path analysis at each new aoi scan step for each instanciated layers aoi scan path. execution_times: all pipeline steps execution times. exception: error catched during gaze position processing. + layers_look_data: dictionary with each layer's look data. """ # Lock frame exploitation @@ -983,19 +966,26 @@ class ArFrame(DataFeatures.SharedObject): # Assess total execution time in ms execution_times['total'] = (time.perf_counter() - look_start) * 1e3 - # Edit look data - look_data = self.__gaze_position, identified_gaze_movement, scan_step_analysis, execution_times, exception, layers_look_data + # Edit look data dictionary + look_data = { + "gaze_position": self.__gaze_position, + "identified_gaze_movement": identified_gaze_movement, + "scan_step_analysis": DataFeatures.DataDictionary(scan_step_analysis), + "execution_times": DataFeatures.DataDictionary(execution_times), + "exception": exception, + "layers_look_data": DataFeatures.DataDictionary(layers_look_data) + } # Log look data for logger_module_path, logger in self.loggers.items(): - logger.emit(timestamp, look_data) + logger.emit(timestamp, DataFeatures.DataDictionary(look_data)) # Unlock frame exploitation self.release() # Return look data - return look_data + return look_data.values() def __image(self, background_weight: float = None, heatmap_weight: float = None, draw_gaze_position_calibrator: dict = None, draw_scan_path: dict = None, draw_layers: dict = None, draw_gaze_positions: dict = None, draw_fixations: dict = None, draw_saccades: dict = None) -> numpy.array: """ |