Script the pipeline =================== All gaze analysis pipeline objects are accessible from Python script. This could be particularly useful for realtime gaze interaction applications. ## Load ArFrame configuration from dictionary First of all, [ArFrame](../../../argaze.md/#argaze.ArFeatures.ArFrame) configuration can be loaded from a python dictionary. ```python from argaze import ArFeatures # Edit a dict with ArFrame configuration configuration = { "name": "My FullHD screen", "size": (1920, 1080), ... "gaze_movement_identifier": { ... }, "scan_path": { ... }, "scan_path_analyzers": { ... }, "heatmap": { ... }, "layers": { "MyLayer": { ... }, ... }, "image_parameters": { ... } } # Load ArFrame ar_frame = ArFeatures.ArFrame.from_dict(configuration) # Do something with ArFrame ... ``` ## Access to ArFrame and ArLayers attributes Then, once the configuration is loaded, it is possible to access to its attributes: [read ArFrame code reference](../../../argaze.md/#argaze.ArFeatures.ArFrame) to get a complete list of what is available. Thus, the [ArFrame.layers](../../../argaze.md/#argaze.ArFeatures.ArFrame) attribute allows to access each loaded layer and so, access to their attributes: [read ArLayer code reference](../../../argaze.md/#argaze.ArFeatures.ArLayer) to get a complete list of what is available. ```python from argaze import ArFeatures # Assuming the ArFrame is loaded ... # Iterate over each ArFrame layers for name, ar_layer in ar_frame.layers.items(): ... ``` ## Pipeline execution updates Calling [ArFrame.look](../../../argaze.md/#argaze.ArFeatures.ArFrame.look) method leads to update many data into the pipeline. ```python # Assuming that timestamped gaze positions are available ... try: # Look ArFrame at a timestamped gaze position ar_frame.look(timestamp, gaze_position): # Do something with last gaze position ... ar_frame.last_gaze_position # Check if a gaze movement has been identified if ar_frame.last_gaze_movement.valid and ar_frame.last_gaze_movement.finished: # Do something with identified fixation if GazeFeatures.is_fixation(ar_frame.last_gaze_movement): ... # Do something with identified saccade elif GazeFeatures.is_saccade(ar_frame.last_gaze_movement): ... # Do something with scan path analysis if ar_frame.analysis_available: for scan_path_analyzer_name, scan_path_analysis in ar_frame.analysis(): ... # Do something with layers aoi scan path analysis for layer_name, ar_layer in ar_frame.layers.items(): # Do something with last looked aoi name ... ar_frame.last_looked_aoi_name if ar_layer.analysis_available: for aoi_scan_path_analyzer_name, aoi_scan_path_analysis in ar_layer.analysis(): ... # Do something with pipeline exception except Exception as e: ... ``` Let's understand the meaning of each data. ### *ar_frame.last_gaze_position* This is the last calibrated [GazePosition](../../../argaze.md/#argaze.GazeFeatures.GazePosition) returned by [GazePositionCalibrator](../../../argaze.md/#argaze.GazeFeatures.GazePositionCalibrator) if one is instanciated else, it is the last given [GazePosition](../../../argaze.md/#argaze.GazeFeatures.GazePosition). ### *ar_frame.last_gaze_movement* Last [GazeMovement](../../../argaze.md/#argaze.GazeFeatures.GazeMovement) identified by [ArFrame.gaze_movement_identifier](../../../argaze.md/#argaze.ArFeatures.ArFrame) object from incoming consecutive timestamped gaze positions. If no gaze movement have been identified, it returns an empty [GazeMovement](../../../argaze.md/#argaze.GazeFeatures.GazeMovement). This could also be the current gaze movement if [ArFrame.filter_in_progress_identification](../../../argaze.md/#argaze.ArFeatures.ArFrame) attribute is false. In that case, the last gaze movement *finished* flag is false. Then, the last gaze movement type can be tested thanks to [GazeFeatures.is_fixation](../../../argaze.md/#argaze.GazeFeatures.is_fixation) and [GazeFeatures.is_saccade](../../../argaze.md/#argaze.GazeFeatures.is_saccade) functions. ### *ar_frame.analysis_available* This flag allows to know when new scan path analysis are available. ### *ar_frame.analysis()* This an iterator to access to all scan path analysis. ### *ar_layer.last_looked_aoi_name* The name of the last aoi matching done by [AoiMatcher](../../../argaze.md/#argaze.GazeFeatures.AoiMatcher) if one is instanciated else, it is a None value. ### *ar_layer.analysis_available* This flag allows to know when new aoi scan path analysis are available. ### *ar_layer.analysis()* This an iterator to access to all aoi scan path analysis. ## Setup ArFrame image parameters [ArFrame.image](../../../argaze.md/#argaze.ArFeatures.ArFrame.image) method parameters can be configured thanks to a python dictionary. ```python # Assuming ArFrame is loaded ... # Edit a dict with ArFrame image parameters image_parameters = { "draw_scan_path": { ... }, "draw_layers": { "MyLayer": { ... } }, ... } # Pass image parameters to ArFrame ar_frame_image = ar_frame.image(**image_parameters) # Do something with ArFrame image ... ```