diff options
author | Théo de la Hogue | 2024-06-21 08:08:17 +0200 |
---|---|---|
committer | Théo de la Hogue | 2024-06-21 08:08:17 +0200 |
commit | 9ff33a028da3417505f3ef91a9d29b6f43738e05 (patch) | |
tree | b8a5b8f3379bc4528ac375bcff2fdbe611685137 | |
parent | 92494552b0a5a11c41611ddee887175fea62d188 (diff) | |
download | argaze-9ff33a028da3417505f3ef91a9d29b6f43738e05.zip argaze-9ff33a028da3417505f3ef91a9d29b6f43738e05.tar.gz argaze-9ff33a028da3417505f3ef91a9d29b6f43738e05.tar.bz2 argaze-9ff33a028da3417505f3ef91a9d29b6f43738e05.tar.xz |
Adding logging
-rw-r--r-- | src/argaze/DataFeatures.py | 5 | ||||
-rw-r--r-- | src/argaze/utils/demo/aruco_markers_pipeline.json | 8 | ||||
-rw-r--r-- | src/argaze/utils/demo/recorders.py | 50 |
3 files changed, 63 insertions, 0 deletions
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): |