From 9c42e9f1ee8208e14dadcb73cf030a9baef236ed Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Wed, 28 Feb 2024 18:48:40 +0100 Subject: Updating the use of with statement in documentation. --- .../configuration_and_execution.md | 5 ++++- .../advanced_topics/gaze_position_calibration.md | 20 ++++++++++---------- .../advanced_topics/module_loading.md | 8 ++++---- .../advanced_topics/scripting.md | 12 ++++++------ .../configuration_and_execution.md | 5 ++++- docs/user_guide/gaze_analysis_pipeline/logging.md | 8 ++++---- .../gaze_analysis_pipeline/visualisation.md | 16 ++++++++-------- 7 files changed, 40 insertions(+), 34 deletions(-) (limited to 'docs') diff --git a/docs/user_guide/aruco_markers_pipeline/configuration_and_execution.md b/docs/user_guide/aruco_markers_pipeline/configuration_and_execution.md index 4f3ce5b..4f05beb 100644 --- a/docs/user_guide/aruco_markers_pipeline/configuration_and_execution.md +++ b/docs/user_guide/aruco_markers_pipeline/configuration_and_execution.md @@ -56,7 +56,10 @@ Then, here is how to load the JSON file: from argaze.ArUcoMarkers import ArUcoCamera # Load ArUcoCamera -aruco_camera = ArUcoCamera.ArUcoCamera.from_json('./configuration.json') +with ArUcoCamera.ArUcoCamera.from_json('./configuration.json') as aruco_camera: + + # Do something with ArUcoCamera + ... ``` Now, let's understand the meaning of each JSON entry. diff --git a/docs/user_guide/gaze_analysis_pipeline/advanced_topics/gaze_position_calibration.md b/docs/user_guide/gaze_analysis_pipeline/advanced_topics/gaze_position_calibration.md index c413e84..9e0ec4c 100644 --- a/docs/user_guide/gaze_analysis_pipeline/advanced_topics/gaze_position_calibration.md +++ b/docs/user_guide/gaze_analysis_pipeline/advanced_topics/gaze_position_calibration.md @@ -30,20 +30,20 @@ Here is an extract from the JSON ArFrame configuration file where a [Linear Regr # Assuming the ArFrame is loaded ... -# Start calibration process -ar_frame.gaze_position_calibrator.reset() + # Start calibration process + ar_frame.gaze_position_calibrator.reset() -# Assuming that expected and observed gaze positions are available -... + # Assuming that expected and observed gaze positions are available + ... - # If calibration process started - if ar_frame.gaze_position_calibrator.calibrating: + # If calibration process started + if ar_frame.gaze_position_calibrator.calibrating: - # Store calibration data - ar_frame.gaze_position_calibrator.store(timestamp, observed_gaze_position, expected_gaze_position) + # Store calibration data + ar_frame.gaze_position_calibrator.store(timestamp, observed_gaze_position, expected_gaze_position) -# End calibration process -score = ar_frame.gaze_position_calibrator.calibrate() + # End calibration process + score = ar_frame.gaze_position_calibrator.calibrate() ``` ## Save calibration parameters as JSON file diff --git a/docs/user_guide/gaze_analysis_pipeline/advanced_topics/module_loading.md b/docs/user_guide/gaze_analysis_pipeline/advanced_topics/module_loading.md index 6d37ea6..fb717b6 100644 --- a/docs/user_guide/gaze_analysis_pipeline/advanced_topics/module_loading.md +++ b/docs/user_guide/gaze_analysis_pipeline/advanced_topics/module_loading.md @@ -43,9 +43,9 @@ from argaze import ArFeatures import my_package # Load ArFrame -ar_frame = ArFeatures.ArFrame.from_json('./configuration.json') +with ArFeatures.ArFrame.from_json('./configuration.json') as ar_frame: -# Print ArFrame attributes -for module, scan_path_analyzer in ar_frame.scan_path_analyzers.items(): - print('scan path analyzer type:', type(scan_path_analyzer)) + # Print ArFrame attributes + for module, scan_path_analyzer in ar_frame.scan_path_analyzers.items(): + print('scan path analyzer type:', type(scan_path_analyzer)) ``` diff --git a/docs/user_guide/gaze_analysis_pipeline/advanced_topics/scripting.md b/docs/user_guide/gaze_analysis_pipeline/advanced_topics/scripting.md index 7952e9f..c3c0266 100644 --- a/docs/user_guide/gaze_analysis_pipeline/advanced_topics/scripting.md +++ b/docs/user_guide/gaze_analysis_pipeline/advanced_topics/scripting.md @@ -40,10 +40,10 @@ configuration = { } # Load ArFrame -ar_frame = ArFeatures.ArFrame.from_dict(configuration) +with ArFeatures.ArFrame.from_dict(configuration) as ar_frame: -# Do something with ArFrame -... + # Do something with ArFrame + ... ``` ## Access to ArFrame and ArLayers attributes @@ -58,9 +58,9 @@ from argaze import ArFeatures # Assuming the ArFrame is loaded ... -# Iterate over each ArFrame layers -for name, ar_layer in ar_frame.layers.items(): - ... + # Iterate over each ArFrame layers + for name, ar_layer in ar_frame.layers.items(): + ... ``` ## Pipeline execution updates diff --git a/docs/user_guide/gaze_analysis_pipeline/configuration_and_execution.md b/docs/user_guide/gaze_analysis_pipeline/configuration_and_execution.md index c53cfda..de23713 100644 --- a/docs/user_guide/gaze_analysis_pipeline/configuration_and_execution.md +++ b/docs/user_guide/gaze_analysis_pipeline/configuration_and_execution.md @@ -39,7 +39,10 @@ Then, here is how to load the JSON file: from argaze import ArFeatures # Load ArFrame -ar_frame = ArFeatures.ArFrame.from_json('./configuration.json') +with ArFeatures.ArFrame.from_json('./configuration.json') as ar_frame: + + # Do something with ArFrame + ... ``` Now, let's understand the meaning of each JSON entry. diff --git a/docs/user_guide/gaze_analysis_pipeline/logging.md b/docs/user_guide/gaze_analysis_pipeline/logging.md index fae10a6..48808cc 100644 --- a/docs/user_guide/gaze_analysis_pipeline/logging.md +++ b/docs/user_guide/gaze_analysis_pipeline/logging.md @@ -36,7 +36,7 @@ from argaze.utils import UtilsFeatures class ScanPathAnalysisLogger(DataFeatures.PipelineStepObserver, UtilsFeatures.FileWriter): def on_look(self, timestamp, ar_frame, exception): - """Log scan path metrics.ar_frame""" + """Log scan path metrics""" if ar_frame.analysis_available: @@ -116,10 +116,10 @@ from argaze.utils import UtilsFeatures class VideoRecorder(DataFeatures.PipelineStepObserver, UtilsFeatures.VideoWriter): - def on_look(self, timestamp, ar_frame, exception): - """Record frame image into video file.""" + def on_look(self, timestamp, ar_frame, exception): + """Record frame image into video file.""" - self.write(ar_frame.image()) + self.write(ar_frame.image()) # Export recorder as observer __observers__ = { diff --git a/docs/user_guide/gaze_analysis_pipeline/visualisation.md b/docs/user_guide/gaze_analysis_pipeline/visualisation.md index e046ddf..b8156a5 100644 --- a/docs/user_guide/gaze_analysis_pipeline/visualisation.md +++ b/docs/user_guide/gaze_analysis_pipeline/visualisation.md @@ -94,17 +94,17 @@ def main(): # Assuming ArFrame is loaded ... - # Create a window to display ArFrame - cv2.namedWindow(ar_frame.name, cv2.WINDOW_AUTOSIZE) + # Create a window to display ArFrame + cv2.namedWindow(ar_frame.name, cv2.WINDOW_AUTOSIZE) - # Assuming that timestamped gaze positions are being processed by ArFrame.look method - ... + # Assuming that timestamped gaze positions are being processed by ArFrame.look method + ... - # Update ArFrame image display - cv2.imshow(ar_frame.name, ar_frame.image()) + # Update ArFrame image display + cv2.imshow(ar_frame.name, ar_frame.image()) - # Wait 10 ms - cv2.waitKey(10) + # Wait 10 ms + cv2.waitKey(10) if __name__ == '__main__': -- cgit v1.1