aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2024-04-24 11:41:27 +0200
committerThéo de la Hogue2024-04-24 11:41:27 +0200
commit23dfd7a70bd1ddc2c03aa465557235c6430a482e (patch)
tree70709c4a177c775331ba7d8948def07279bbea60
parent61ff3086313b5e6c321adb14969938b429549260 (diff)
downloadargaze-23dfd7a70bd1ddc2c03aa465557235c6430a482e.zip
argaze-23dfd7a70bd1ddc2c03aa465557235c6430a482e.tar.gz
argaze-23dfd7a70bd1ddc2c03aa465557235c6430a482e.tar.bz2
argaze-23dfd7a70bd1ddc2c03aa465557235c6430a482e.tar.xz
Resizing background after setting size.
-rw-r--r--src/argaze/ArFeatures.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index cabac94..e1edfdb 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -467,8 +467,14 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject):
@size.setter
def size(self, size: tuple[int, int]):
+
self.__size = size
+ if self.background.size != self.__size:
+
+ # Resize background to current size
+ self.background = self.background
+
@property
def gaze_position_calibrator(self) -> GazeFeatures.GazePositionCalibrator:
"""Select gaze position calibration algorithm."""
@@ -599,8 +605,7 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject):
if background.size != self.size:
# Resize image to frame size
- self.__background = DataFeatures.TimestampedImage(
- cv2.resize(background, dsize=self.size, interpolation=cv2.INTER_CUBIC), background.timestamp)
+ self.__background = DataFeatures.TimestampedImage(cv2.resize(background, dsize=self.size, interpolation=cv2.INTER_CUBIC), background.timestamp)
else:
@@ -955,16 +960,25 @@ class ArScene(DataFeatures.PipelineStepObject):
frame_3d = scene_layer.aoi_scene[frame_name]
- # Check that the frame have a layer named like this scene layer
- aoi_2d_scene = new_frame.layers[scene_layer_name].aoi_scene
+ try:
+
+ # Check that the frame have a layer named like this scene layer
+ aoi_2d_scene = new_frame.layers[scene_layer_name].aoi_scene
+
+ # Transform 2D frame layer AOI into 3D scene layer AOI
+ # Then, add them to scene layer
+ scene_layer.aoi_scene |= aoi_2d_scene.dimensionalize(frame_3d, new_frame.size)
- # Transform 2D frame layer AOI into 3D scene layer AOI
- # Then, add them to scene layer
- scene_layer.aoi_scene |= aoi_2d_scene.dimensionalize(frame_3d, new_frame.size)
+ except KeyError as e:
+
+ # Warn user about missing layer even if it is possible
+ logging.warning('ArScene.frames: %s layer doesn\'t exist in %s frame', e, new_frame.name)
except KeyError as e:
- print('ArScene.from_dict: KeyError', e)
+ # Warn user about missing AOI even if it is possible
+ logging.warning('ArScene.frames: %s AOI doesn\'t exist in %s layer of %s scene', e, scene_layer_name, self.name)
+
# Append new frame
self.__frames[frame_name] = new_frame