From 60ac4dca5aae946cc7a8e9bb09cd7577712ecc28 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 29 Aug 2023 13:45:24 +0200 Subject: Moving ArFrame background attribute. --- src/argaze/ArFeatures.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index c9a6faa..b187869 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -505,24 +505,24 @@ class ArFrame(): Parameters: name: name of the frame size: defines the dimension of the rectangular area where gaze positions are projected. - background: image to draw behind gaze_movement_identifier: gaze movement identification algorithm filter_in_progress_fixation: ignore in progress fixation scan_path: scan path object scan_path_analyzers: dictionary of scan path analyzers heatmap: heatmap object + background: image to draw behind layers: dictionary of AOI layers log: enable scan path analysis logging """ name: str size: tuple[int] = field(default=(1, 1)) - background: numpy.array = field(default_factory=numpy.array) gaze_movement_identifier: GazeFeatures.GazeMovementIdentifier = field(default_factory=GazeFeatures.GazeMovementIdentifier) filter_in_progress_fixation: bool = field(default=True) scan_path: GazeFeatures.ScanPath = field(default_factory=GazeFeatures.ScanPath) scan_path_analyzers: dict = field(default_factory=dict) heatmap: AOIFeatures.Heatmap = field(default_factory=AOIFeatures.Heatmap) + background: numpy.array = field(default_factory=numpy.array) layers: dict = field(default_factory=dict) log: bool = field(default=False) @@ -579,17 +579,6 @@ class ArFrame(): new_frame_size = (0, 0) - # Load background image - try: - - new_frame_background_value = frame_data.pop('background') - new_frame_background = cv2.imread(os.path.join(working_directory, new_frame_background_value)) - new_frame_background = cv2.resize(new_frame_background, dsize=(new_frame_size[0], new_frame_size[1]), interpolation=cv2.INTER_CUBIC) - - except KeyError: - - new_frame_background = numpy.full((new_frame_size[1], new_frame_size[0], 3), 127).astype(numpy.uint8) - # Load gaze movement identifier try: @@ -694,6 +683,17 @@ class ArFrame(): new_heatmap_data = {} new_heatmap = None + # Load background image + try: + + new_frame_background_value = frame_data.pop('background') + new_frame_background = cv2.imread(os.path.join(working_directory, new_frame_background_value)) + new_frame_background = cv2.resize(new_frame_background, dsize=(new_frame_size[0], new_frame_size[1]), interpolation=cv2.INTER_CUBIC) + + except KeyError: + + new_frame_background = numpy.full((new_frame_size[1], new_frame_size[0], 3), 127).astype(numpy.uint8) + # Load layers new_layers = {} @@ -731,12 +731,12 @@ class ArFrame(): # Create frame return ArFrame(new_frame_name, \ new_frame_size, \ - new_frame_background, \ new_gaze_movement_identifier, \ filter_in_progress_fixation, \ new_scan_path, \ new_scan_path_analyzers, \ new_heatmap, \ + new_frame_background, \ new_layers, \ new_frame_log \ ) -- cgit v1.1