diff options
author | Théo de la Hogue | 2024-03-22 12:04:39 +0100 |
---|---|---|
committer | Théo de la Hogue | 2024-03-22 12:04:39 +0100 |
commit | 44372df36795c79ff851ba2daba2b72492e308da (patch) | |
tree | 3551b101f8135e226f5e07334ddc670e17a009a9 /src | |
parent | 04b9b79bb6a4a1378ae4c22b261b8670b6f547be (diff) | |
download | argaze-44372df36795c79ff851ba2daba2b72492e308da.zip argaze-44372df36795c79ff851ba2daba2b72492e308da.tar.gz argaze-44372df36795c79ff851ba2daba2b72492e308da.tar.bz2 argaze-44372df36795c79ff851ba2daba2b72492e308da.tar.xz |
Setting image_parameters and scenes as protected attributes.
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/ArFeatures.py | 44 | ||||
-rw-r--r-- | src/argaze/ArUcoMarkers/ArUcoCamera.py | 26 |
2 files changed, 35 insertions, 35 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 87293ee..0133308 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -120,12 +120,13 @@ class ArLayer(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): self.__aoi_matcher = None self.__aoi_scan_path = None self.__aoi_scan_path_analyzers = [] - self.__draw_parameters = DEFAULT_ARLAYER_DRAW_PARAMETERS - self.__gaze_movement = GazeFeatures.GazeMovement() self.__looked_aoi_name = None self.__aoi_scan_path_analyzed = False + # Init protected attributes + self._draw_parameters = DEFAULT_ARLAYER_DRAW_PARAMETERS + @property def aoi_scene(self) -> AOIFeatures.AOIScene: """AOI scene description.""" @@ -273,13 +274,13 @@ class ArLayer(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): @property def draw_parameters(self) -> dict: """Default draw method parameters dictionary.""" - return self.__draw_parameters + return self._draw_parameters @draw_parameters.setter @DataFeatures.PipelineStepAttributeSetter def draw_parameters(self, draw_parameters: dict): - self.__draw_parameters = draw_parameters + self._draw_parameters = draw_parameters def last_looked_aoi_name(self) -> str: """Get last looked aoi name.""" @@ -308,7 +309,7 @@ class ArLayer(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): "aoi_matcher": self.__aoi_matcher, "aoi_scan_path": self.__aoi_scan_path, "aoi_scan_path_analyzers": self.__aoi_scan_path_analyzers, - "draw_parameters": self.__draw_parameters + "draw_parameters": self._draw_parameters } def __update_expected_aoi(self): @@ -395,7 +396,7 @@ class ArLayer(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): # Use draw_parameters attribute if no parameters if draw_aoi_scene is None and draw_aoi_matching is None: - return self.draw(image, **self.__draw_parameters) + return self.draw(image, **self._draw_parameters) # Use layer lock feature with self._lock: @@ -458,12 +459,13 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): self.__background = numpy.full((1, 1, 3), 127).astype(numpy.uint8) self.__heatmap = None self.__layers = {} - self.__image_parameters = DEFAULT_ARFRAME_IMAGE_PARAMETERS - self.__calibrated_gaze_position = GazeFeatures.GazePosition() self.__identified_gaze_movement = GazeFeatures.GazeMovement() self.__scan_path_analyzed = False + # Init protected attributes + self._image_parameters = DEFAULT_ARFRAME_IMAGE_PARAMETERS + @property def size(self) -> tuple[int]: """Defines the dimension of the rectangular area where gaze positions are projected.""" @@ -658,13 +660,13 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): @property def image_parameters(self) -> dict: """Default image method parameters dictionary.""" - return self.__image_parameters + return self._image_parameters @image_parameters.setter @DataFeatures.PipelineStepAttributeSetter def image_parameters(self, image_parameters: dict): - self.__image_parameters = image_parameters + self._image_parameters = image_parameters def last_gaze_position(self) -> object: """Get last calibrated gaze position""" @@ -706,7 +708,7 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): "background": self.__background, "heatmap": self.__heatmap, "layers": self.__layers, - "image_parameters": self.__image_parameters + "image_parameters": self._image_parameters } return d @@ -892,7 +894,7 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): return self.__image(**kwargs) - return self.__image(**self.__image_parameters) + return self.__image(**self._image_parameters) class ArScene(DataFeatures.PipelineStepObject): """ @@ -1083,10 +1085,12 @@ class ArCamera(ArFrame): super().__init__() # Init private attributes - self.__scenes = {} self.__visual_hfov = 0. self.__visual_vfov = 0. + # Init protected attributes + self._scenes = {} + # Setup expected aoi of each layer aoi scan path with the aoi of corresponding scene layer # Edit aoi matcher exclude attribute to ignore frame aoi for layer_name, layer in self.layers.items(): @@ -1094,7 +1098,7 @@ class ArCamera(ArFrame): expected_aoi_list = [] exclude_aoi_list = [] - for scene_name, scene in self.__scenes.items(): + for scene_name, scene in self._scenes.items(): # Append scene layer aoi to corresponding expected camera layer aoi try: @@ -1131,20 +1135,20 @@ class ArCamera(ArFrame): @property def scenes(self) -> dict: """All scenes to project into camera frame.""" - return self.__scenes + return self._scenes @scenes.setter @DataFeatures.PipelineStepAttributeSetter def scenes(self, scenes: dict): - self.__scenes = {} + self._scenes = {} for scene_name, scene_data in scenes.items(): - self.__scenes[scene_name] = ArScene(working_directory = self.working_directory, name = scene_name, **scene_data) + self._scenes[scene_name] = ArScene(working_directory = self.working_directory, name = scene_name, **scene_data) # Edit parent - for name, scene in self.__scenes.items(): + for name, scene in self._scenes.items(): scene.parent = self @@ -1172,7 +1176,7 @@ class ArCamera(ArFrame): """Iterate over all scenes frames""" # For each scene - for scene_name, scene in self.__scenes.items(): + for scene_name, scene in self._scenes.items(): # For each scene frame for name, scene_frame in scene.frames.items(): @@ -1184,7 +1188,7 @@ class ArCamera(ArFrame): return { **ArFrame.as_dict(self), - "scenes": self.__scenes, + "scenes": self._scenes, "visual_hfov": self.__visual_hfov, "visual_vfov": self.__visual_vfov } diff --git a/src/argaze/ArUcoMarkers/ArUcoCamera.py b/src/argaze/ArUcoMarkers/ArUcoCamera.py index 6d13c10..5fd1499 100644 --- a/src/argaze/ArUcoMarkers/ArUcoCamera.py +++ b/src/argaze/ArUcoMarkers/ArUcoCamera.py @@ -52,7 +52,7 @@ class ArUcoCamera(ArFeatures.ArCamera): # Init private attribute self.__aruco_detector = None - self.__image_parameters = {**ArFeatures.DEFAULT_ARFRAME_IMAGE_PARAMETERS, **DEFAULT_ARUCOCAMERA_IMAGE_PARAMETERS} + self._image_parameters = {**ArFeatures.DEFAULT_ARFRAME_IMAGE_PARAMETERS, **DEFAULT_ARUCOCAMERA_IMAGE_PARAMETERS} @property def aruco_detector(self) -> ArUcoDetector.ArUcoDetector: @@ -85,38 +85,34 @@ class ArUcoCamera(ArFeatures.ArCamera): self.__aruco_detector.parent = self - @property - def scenes(self) -> dict: - """All scenes to project into camera frame.""" - return self.__scenes - - @scenes.setter + @ArFeatures.ArCamera.scenes.setter @DataFeatures.PipelineStepAttributeSetter def scenes(self, scenes: dict): - self.__scenes = {} + self._scenes = {} for scene_name, scene_data in scenes.items(): - self.__scenes[scene_name] = ArUcoScene.ArUcoScene(working_directory = self.working_directory, name = scene_name, **scene_data) + self._scenes[scene_name] = ArUcoScene.ArUcoScene(working_directory = self.working_directory, name = scene_name, **scene_data) # Edit parent - for name, scene in self.__scenes.items(): + for name, scene in self._scenes.items(): scene.parent = self - @ArFeatures.ArFrame.image_parameters.setter + @ArFeatures.ArCamera.image_parameters.setter + @DataFeatures.PipelineStepAttributeSetter def image_parameters(self, image_parameters: dict): - self.__image_parameters = image_parameters + self._image_parameters = image_parameters - if 'draw_layers' not in self.__image_parameters: + if 'draw_layers' not in self._image_parameters: - self.__image_parameters['draw_layers'] = {} + self._image_parameters['draw_layers'] = {} for layer_name in self.layers.keys(): - self.__image_parameters['draw_layers'][layer_name] = ArFeatures.DEFAULT_ARLAYER_DRAW_PARAMETERS + self._image_parameters['draw_layers'][layer_name] = ArFeatures.DEFAULT_ARLAYER_DRAW_PARAMETERS @DataFeatures.PipelineStepMethod def watch(self, image: numpy.array): |