From d904b99cc969c977f911d36cfeb2279544c528e5 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 23 Jan 2024 14:54:30 +0100 Subject: Defing PipelineStepObject and PipelineStepMethod to assess time execution. Removing exception managment to let the user catch them into the script. --- .../advanced_topics/scripting.md | 26 ++++----- .../configuration_and_execution.md | 30 ++++++++-- .../advanced_topics/scripting.md | 67 +++++++++++----------- .../configuration_and_execution.md | 17 +++++- 4 files changed, 84 insertions(+), 56 deletions(-) (limited to 'docs/user_guide') diff --git a/docs/user_guide/aruco_markers_pipeline/advanced_topics/scripting.md b/docs/user_guide/aruco_markers_pipeline/advanced_topics/scripting.md index c79c8b5..99f52ee 100644 --- a/docs/user_guide/aruco_markers_pipeline/advanced_topics/scripting.md +++ b/docs/user_guide/aruco_markers_pipeline/advanced_topics/scripting.md @@ -78,30 +78,26 @@ for name, aruco_scene in aruco_camera.scenes.items(): # Assuming that timestamped images are available ...: - # Watch image with ArUco camera - detection_time, projection_time, exception = aruco_camera.watch(timestamp, image) + try: - # Do something with pipeline times - ... + # Watch image with ArUco camera + aruco_camera.watch(timestamp, image) # Do something with pipeline exception - if exception: + except Exception as e: + ... + + # Do something with detected_markers + ... aruco_camera.aruco_detector.detected_markers + ``` Let's understand the meaning of each returned data. -### *detection_time* - -ArUco marker detection time in ms. - -### *projection_time* - -Scenes projection time in ms. - -### *exception* +### *aruco_camera.aruco_detector.detected_markers* -A [python Exception](https://docs.python.org/3/tutorial/errors.html#exceptions) object raised during pipeline execution. +A dictionary containing all detected markers provided by [ArUcoDetector](../../../argaze.md/#argaze.ArUcoMarkers.ArUcoDetector) class. ## Setup ArUcoCamera image parameters 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 43bb64e..5b740dc 100644 --- a/docs/user_guide/aruco_markers_pipeline/configuration_and_execution.md +++ b/docs/user_guide/aruco_markers_pipeline/configuration_and_execution.md @@ -97,12 +97,23 @@ The usual [ArFrame visualisation parameters](../gaze_analysis_pipeline/visualisa Pass each camera image to [ArUcoCamera.watch](../../argaze.md/#argaze.ArFeatures.ArCamera.watch) method to execute the whole pipeline dedicated to ArUco markers detection, scene pose estimation and 3D AOI projection. +!!! warning "Mandatory" + + [ArUcoCamera.watch](../../argaze.md/#argaze.ArFeatures.ArCamera.watch) method must be called from a *try* block to catch pipeline exceptions. + ```python # Assuming that Full HD (1920x1080) timestamped images are available ...: - # Detect ArUco markers, estimate scene pose then, project 3D AOI into camera frame - aruco_camera.watch(timestamp, image) + try: + + # Detect ArUco markers, estimate scene pose then, project 3D AOI into camera frame + aruco_camera.watch(timestamp, image) + + # Do something with pipeline exception + except Exception as e: + + ... # Display ArUcoCamera frame image to display detected ArUco markers, scene pose, 2D AOI projection and ArFrame visualisation. ... aruco_camera.image() @@ -114,12 +125,23 @@ As mentioned above, [ArUcoCamera](../../argaze.md/#argaze.ArUcoMarkers.ArUcoCame Particularly, timestamped gaze positions can be passed one by one to [ArUcoCamera.look](../../argaze.md/#argaze.ArFeatures.ArFrame.look) method to execute the whole pipeline dedicated to gaze analysis. +!!! warning "Mandatory" + + [ArUcoCamera.look](../../argaze.md/#argaze.ArFeatures.ArFrame.look) method must be called from a *try* block to catch pipeline exceptions. + ```python # Assuming that timestamped gaze positions are available ... - # Look ArUcoCamera frame at a timestamped gaze position - aruco_camera.look(timestamp, gaze_position) + try: + + # Look ArUcoCamera frame at a timestamped gaze position + aruco_camera.look(timestamp, gaze_position) + + # Do something with pipeline exception + except Exception as e: + + ... ``` !!! note "" 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 837c8ff..9e65c08 100644 --- a/docs/user_guide/gaze_analysis_pipeline/advanced_topics/scripting.md +++ b/docs/user_guide/gaze_analysis_pipeline/advanced_topics/scripting.md @@ -71,54 +71,53 @@ Calling [ArFrame.look](../../../argaze.md/#argaze.ArFeatures.ArFrame.look) metho # Assuming that timestamped gaze positions are available ... - # Look ArFrame at a timestamped gaze position - execution_time, exception = ar_frame.look(timestamp, gaze_position).values() + try: - # Do something with calibrated gaze position - ... ar_frame.gaze_position + # Look ArFrame at a timestamped gaze position + ar_frame.look(timestamp, gaze_position).values() - # Check if a gaze movement has been identified - if ar_frame.gaze_movement.valid and ar_frame.gaze_movement.finished: + # Do something with calibrated gaze position + ... ar_frame.gaze_position - # Do something with identified fixation - if GazeFeatures.is_fixation(ar_frame.gaze_movement): - ... - - # Do something with identified saccade - elif GazeFeatures.is_saccade(ar_frame.gaze_movement): - ... + # Check if a gaze movement has been identified + if ar_frame.gaze_movement.valid and ar_frame.gaze_movement.finished: - # Check if new scan path analysis are available - if ar_frame.new_analysis_available: + # Do something with identified fixation + if GazeFeatures.is_fixation(ar_frame.gaze_movement): + ... - # Access to each scan path analyzer - for analyzer_name, analyzer in ar_frame.scan_path_analyzers.items(): + # Do something with identified saccade + elif GazeFeatures.is_saccade(ar_frame.gaze_movement): + ... - # Do something with analysis results - ... analyzer.analysis + # Check if new scan path analysis are available + if ar_frame.new_analysis_available: - # Iterate over each ArFrame layers - for name, ar_layer in ar_frame.layers.items(): - - # Check if new aoi scan path analysis are available - if ar_layer.new_analysis_available: - - # Access to each aoi scan path analyzer - for analyzer_name, analyzer in ar_layer.aoi_scan_path_analyzers.items(): + # Access to each scan path analyzer + for analyzer_name, analyzer in ar_frame.scan_path_analyzers.items(): # Do something with analysis results ... analyzer.analysis -``` -Let's understand the meaning of each data. + # Iterate over each ArFrame layers + for name, ar_layer in ar_frame.layers.items(): + + # Check if new aoi scan path analysis are available + if ar_layer.new_analysis_available: -### *execution_times* + # Access to each aoi scan path analyzer + for analyzer_name, analyzer in ar_layer.aoi_scan_path_analyzers.items(): -A dictionary with each pipeline step execution time. + # Do something with analysis results + ... analyzer.analysis -### *exception* + # Do something with pipeline exception + except Exception as e: + + ... +``` -A [python Exception](https://docs.python.org/3/tutorial/errors.html#exceptions) object raised during pipeline execution. +Let's understand the meaning of each data. ### *ar_frame.gaze_position* @@ -139,7 +138,7 @@ This flag allows to now when new scan path and aoi scan path analysis are availa ### *analyzer.analysis* -A dict containing all data produced by an analyzer. +A dictionary containing all data produced by an analyzer. ## Setup ArFrame image parameters 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 0edbef3..c53cfda 100644 --- a/docs/user_guide/gaze_analysis_pipeline/configuration_and_execution.md +++ b/docs/user_guide/gaze_analysis_pipeline/configuration_and_execution.md @@ -94,14 +94,25 @@ In the example file, the choosen analysis algorithms are the [Basic](../../argaz ## Pipeline execution -Timestamped gaze positions have to be passed one by one to [ArFrame.look](../../argaze.md/#argaze.ArFeatures.ArFrame.look) method to execute the whole instantiated pipeline. +Timestamped gaze positions have to be passed one by one to [ArFrame.look](../../argaze.md/#argaze.ArFeatures.ArFrame.look) method to execute the whole instantiated pipeline. + +!!! warning "Mandatory" + + [ArFrame.look](../../argaze.md/#argaze.ArFeatures.ArFrame.look) method must be called from a *try* block to catch pipeline exceptions. ```python # Assuming that timestamped gaze positions are available ... - # Look ArFrame at a timestamped gaze position - ar_frame.look(timestamp, gaze_position) + try: + + # Look ArFrame at a timestamped gaze position + ar_frame.look(timestamp, gaze_position) + + # Do something with pipeline exception + except Exception as e: + + ... ``` !!! note "" -- cgit v1.1