aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/utils/UtilsFeatures.py55
-rw-r--r--src/argaze/utils/demo/aruco_markers_pipeline.json4
-rw-r--r--src/argaze/utils/demo/gaze_analysis_pipeline.json2
-rw-r--r--src/argaze/utils/demo/recorders.py50
4 files changed, 58 insertions, 53 deletions
diff --git a/src/argaze/utils/UtilsFeatures.py b/src/argaze/utils/UtilsFeatures.py
index 23d6b24..ce92e35 100644
--- a/src/argaze/utils/UtilsFeatures.py
+++ b/src/argaze/utils/UtilsFeatures.py
@@ -23,6 +23,7 @@ import time
import csv
import types
import traceback
+import logging
from argaze import DataFeatures
@@ -433,3 +434,57 @@ class VideoWriter(DataFeatures.PipelineStepObject, DataFeatures.SharedObject):
output = cv2.resize(image, dsize=(self.__width, self.__height), interpolation=cv2.INTER_LINEAR)
self.__process.stdin.write(output.tobytes())
+
+
+class LookPerformanceRecorder(FileWriter):
+ """Record look method performance into a CSV file."""
+
+ def __init__(self, **kwargs):
+
+ super().__init__(**kwargs)
+
+ self.header = "Timestamp (ms)", "Time (ms)", "Frequency (Hz)"
+
+ self.__start_time = time.perf_counter()
+
+ 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."""
+
+ t, f = frame.execution_info('look')
+
+ log = (
+ (time.perf_counter() - self.__start_time) * 1e3,
+ t * 1e3,
+ f
+ )
+
+ self.write(log)
+
+
+class WatchPerformanceRecorder(FileWriter):
+ """Record watch method performance into a CSV file."""
+
+ def __init__(self, **kwargs):
+
+ super().__init__(**kwargs)
+
+ self.header = "Timestamp (ms)", "Time (ms)", "Frequency (Hz)"
+
+ self.__start_time = time.perf_counter()
+
+ 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."""
+
+ t, f = camera.execution_info('watch')
+
+ log = (
+ (time.perf_counter() - self.__start_time) * 1e3,
+ t * 1e3,
+ f
+ )
+
+ self.write(log) \ No newline at end of file
diff --git a/src/argaze/utils/demo/aruco_markers_pipeline.json b/src/argaze/utils/demo/aruco_markers_pipeline.json
index 86da9bc..f29111b 100644
--- a/src/argaze/utils/demo/aruco_markers_pipeline.json
+++ b/src/argaze/utils/demo/aruco_markers_pipeline.json
@@ -122,10 +122,10 @@
}
},
"observers": {
- "recorders.LookPerformanceRecorder": {
+ "argaze.utils.UtilsFeatures.LookPerformanceRecorder": {
"path": "_export/records/look_performance.csv"
},
- "recorders.WatchPerformanceRecorder": {
+ "argaze.utils.UtilsFeatures.WatchPerformanceRecorder": {
"path": "_export/records/watch_performance.csv"
}
}
diff --git a/src/argaze/utils/demo/gaze_analysis_pipeline.json b/src/argaze/utils/demo/gaze_analysis_pipeline.json
index 768e2c1..8b8212e 100644
--- a/src/argaze/utils/demo/gaze_analysis_pipeline.json
+++ b/src/argaze/utils/demo/gaze_analysis_pipeline.json
@@ -115,7 +115,7 @@
}
},
"observers": {
- "recorders.LookPerformanceRecorder": {
+ "argaze.utils.UtilsFeatures.LookPerformanceRecorder": {
"path": "_export/records/look_performance.csv"
},
"recorders.FixationRecorder": {
diff --git a/src/argaze/utils/demo/recorders.py b/src/argaze/utils/demo/recorders.py
index 6295c8f..82022ce 100644
--- a/src/argaze/utils/demo/recorders.py
+++ b/src/argaze/utils/demo/recorders.py
@@ -25,56 +25,6 @@ from argaze import DataFeatures, GazeFeatures
from argaze.ArUcoMarker import ArUcoMarkerGroup
from argaze.utils import UtilsFeatures
-class LookPerformanceRecorder(UtilsFeatures.FileWriter):
-
- def __init__(self, **kwargs):
-
- super().__init__(**kwargs)
-
- self.header = "Timestamp (ms)", "Time (ms)", "Frequency (Hz)"
-
- self.__start_time = time.perf_counter()
-
- 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."""
-
- t, f = frame.execution_info('look')
-
- log = (
- (time.perf_counter() - self.__start_time) * 1e3,
- t * 1e3,
- f
- )
-
- self.write(log)
-
-class WatchPerformanceRecorder(UtilsFeatures.FileWriter):
-
- def __init__(self, **kwargs):
-
- super().__init__(**kwargs)
-
- self.header = "Timestamp (ms)", "Time (ms)", "Frequency (Hz)"
-
- self.__start_time = time.perf_counter()
-
- 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."""
-
- t, f = camera.execution_info('watch')
-
- log = (
- (time.perf_counter() - self.__start_time) * 1e3,
- t * 1e3,
- f
- )
-
- self.write(log)
-
class FixationRecorder(UtilsFeatures.FileWriter):
def __init__(self, **kwargs):