From 7be9f538c393804cbd2f8f6c811c74caaa62406b Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Thu, 10 Aug 2023 15:14:19 +0200 Subject: Adding aoi_color attribute to ArLayer. --- src/argaze/ArFeatures.py | 20 ++++++++++++++++---- .../demo_environment/demo_gaze_features_setup.json | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 0022c80..ca46a64 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -72,6 +72,7 @@ class ArLayer(): Parameters: name: name of the layer + aoi_color: color to used in draw method aoi_scene: AOI scene description looked_aoi_covering_threshold: aoi_scan_path: AOI scan path object @@ -79,6 +80,7 @@ class ArLayer(): """ name: str + aoi_color: tuple = field(default=(0, 0, 0)) aoi_scene: AOIFeatures.AOIScene = field(default_factory=AOIFeatures.AOIScene) looked_aoi_covering_threshold: int = field(default=0) aoi_scan_path: GazeFeatures.AOIScanPath = field(default_factory=GazeFeatures.AOIScanPath) @@ -125,6 +127,15 @@ class ArLayer(): new_layer_name = None + # Load aoi color + try: + + new_aoi_color = layer_data.pop('aoi_color') + + except KeyError: + + new_aoi_color = (0, 0, 0) + # Load optional aoi filter try: @@ -244,6 +255,7 @@ class ArLayer(): # Create layer return ArLayer(new_layer_name, \ + new_aoi_color, \ new_aoi_scene, \ looked_aoi_covering_threshold, \ new_aoi_scan_path, \ @@ -468,7 +480,7 @@ class ArLayer(): # Return look data return looked_aoi, aoi_scan_path_analysis, execution_times, exception - def draw(self, image:numpy.array, aoi_color=(0, 0, 0)) -> Exception: + def draw(self, image:numpy.array) -> Exception: """ Draw layer into image. @@ -485,7 +497,7 @@ class ArLayer(): try: # Draw aoi - self.aoi_scene.draw(image, color=aoi_color) + self.aoi_scene.draw(image, color=self.aoi_color) # Draw current gaze movement if self.__gaze_movement.valid: @@ -953,7 +965,7 @@ class ArFrame(): # Return look data return identified_gaze_movement, scan_step_analysis, layer_analysis, execution_times, exception - def draw(self, image:numpy.array, aoi_color=(0, 0, 0)) -> Exception: + def draw(self, image:numpy.array) -> Exception: """ Draw frame into image. @@ -972,7 +984,7 @@ class ArFrame(): # Draw layers for layer_name, layer in self.layers.items(): - exception = layer.draw(image, aoi_color) + exception = layer.draw(image) # Draw current gaze position self.__gaze_position.draw(image, color=(255, 255, 255)) diff --git a/src/argaze/utils/demo_environment/demo_gaze_features_setup.json b/src/argaze/utils/demo_environment/demo_gaze_features_setup.json index f9947d6..90ae30f 100644 --- a/src/argaze/utils/demo_environment/demo_gaze_features_setup.json +++ b/src/argaze/utils/demo_environment/demo_gaze_features_setup.json @@ -26,6 +26,7 @@ }, "layers": { "GrayRectangle": { + "aoi_color": [0, 0, 0], "aoi_scene": "aoi_3d_scene.obj", "aoi_scan_path": { "duration_max": 10000 -- cgit v1.1