From 9ff33a028da3417505f3ef91a9d29b6f43738e05 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Fri, 21 Jun 2024 08:08:17 +0200 Subject: Adding logging --- src/argaze/DataFeatures.py | 5 +++ src/argaze/utils/demo/aruco_markers_pipeline.json | 8 ++++ src/argaze/utils/demo/recorders.py | 50 +++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/src/argaze/DataFeatures.py b/src/argaze/DataFeatures.py index 0d1e351..66eaba1 100644 --- a/src/argaze/DataFeatures.py +++ b/src/argaze/DataFeatures.py @@ -856,6 +856,8 @@ def PipelineStepAttributeSetter(method): def PipelineStepMethod(method): """Define a decorator use into PipelineStepObject class to declare pipeline method.""" + logging.debug("@PipelineStepMethod: %s method notify observers and timestamped exceptions", method.__name__) + def wrapper(self, *args, timestamp: int | float = None, unwrap: bool = False, **kwargs): """Wrap pipeline step method to notify observers and timestamped exceptions. @@ -865,6 +867,7 @@ def PipelineStepMethod(method): timestamp: optional method call timestamp (unit doesn't matter) if first args parameter is not a TimestampedObject instance. unwrap: extra arguments used in wrapper function to call wrapped method directly. """ + if timestamp is None and len(args) > 0: try: @@ -1289,6 +1292,8 @@ class PipelineStepObject(): subscription_name = f'on_{signal}' + logging.debug('%s.send_signal %s', get_class_path(self), subscription_name) + for observer in self.observers: # Does the observer cares about this method? diff --git a/src/argaze/utils/demo/aruco_markers_pipeline.json b/src/argaze/utils/demo/aruco_markers_pipeline.json index 48071ab..05e6d1f 100644 --- a/src/argaze/utils/demo/aruco_markers_pipeline.json +++ b/src/argaze/utils/demo/aruco_markers_pipeline.json @@ -119,6 +119,14 @@ "angle_tolerance": 15.0, "distance_tolerance": 2.54 } + }, + "observers": { + "recorders.LookPerformanceRecorder": { + "path": "_export/records/look_performance.csv" + }, + "recorders.WatchPerformanceRecorder": { + "path": "_export/records/watch_performance.csv" + } } } } \ No newline at end of file diff --git a/src/argaze/utils/demo/recorders.py b/src/argaze/utils/demo/recorders.py index b958cd3..82af7e5 100644 --- a/src/argaze/utils/demo/recorders.py +++ b/src/argaze/utils/demo/recorders.py @@ -22,6 +22,56 @@ import logging from argaze import DataFeatures, GazeFeatures from argaze.utils import UtilsFeatures +class LookPerformanceRecorder(UtilsFeatures.FileWriter): + + def __init__(self, **kwargs): + + super().__init__(**kwargs) + + self.header = "Timestamp (ms)", "Time (ms)", "Frequency (Hz)" + + logging.info('%s writes into %s', DataFeatures.get_class_path(self), self.path) + + def on_look(self, timestamp, frame, exception): + """Log frame look execution performance.""" + + time, frequency = frame.execution_info('look') + + print('LookPerformanceRecorder', time, frequency) + + log = ( + timestamp, + time * 1e3, + frequency + ) + + self.write(log) + +class WatchPerformanceRecorder(UtilsFeatures.FileWriter): + + def __init__(self, **kwargs): + + super().__init__(**kwargs) + + self.header = "Timestamp (ms)", "Time (ms)", "Frequency (Hz)" + + logging.info('%s writes into %s', DataFeatures.get_class_path(self), self.path) + + def on_watch(self, timestamp, camera, exception): + """Log camera watch execution performance.""" + + time, frequency = camera.execution_info('watch') + + print('WatchPerformanceRecorder', time, frequency) + + log = ( + timestamp, + time * 1e3, + frequency + ) + + self.write(log) + class FixationRecorder(UtilsFeatures.FileWriter): def __init__(self, **kwargs): -- cgit v1.1