From 15cacb17bd0ce27e5e8c90b8f29fd2affe301d8d Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 28 May 2024 17:31:04 +0200 Subject: Clearing frame background. Calling map method inside its own try block. --- src/argaze/ArFeatures.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 79af23c..ba602de 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -1435,6 +1435,9 @@ class ArCamera(ArFrame): # Project camera frame background into each scene frame if possible for frame in self.scene_frames(): + # Clear frame background + frame.background = DataFeatures.TimestampedImage(numpy.full((frame.size[1], frame.size[0], 3), 0).astype(numpy.uint8), timestamp=self.background.timestamp) + # Is there an AOI inside camera frame layers projection which its name equals to a scene frame name? for camera_layer_name, camera_layer in self.layers.items(): @@ -1448,14 +1451,13 @@ class ArCamera(ArFrame): mapping = cv2.getPerspectiveTransform(aoi_2d.astype(numpy.float32), destination) frame.background = DataFeatures.TimestampedImage(cv2.warpPerspective(self.background, mapping, (width, height)), timestamp=self.background.timestamp) - # Notify frame 'on_map' signal observers - frame.send_signal('map', timestamp=self.background.timestamp) - # Ignore missing frame projection except KeyError: pass + # Notify frame's 'on_map' signal observers + frame.send_signal('map', timestamp=self.background.timestamp) # Define default ArContext image parameters DEFAULT_ARCONTEXT_IMAGE_PARAMETERS = { @@ -1616,7 +1618,20 @@ class ArContext(DataFeatures.PipelineStepObject): self.__pipeline.watch(DataFeatures.TimestampedImage(image, timestamp=timestamp)) - # TODO: make this step optional + + self.__pipeline.map(timestamp=timestamp) + + except DataFeatures.TimestampedException as e: + + logging.warning('%s._process_camera_image: %s', DataFeatures.get_class_path(self), e) + + self.__exceptions.append(e) + + # TODO: make map step optional + try: + + logging.debug('\t> map image (%i x %i)', width, height) + self.__pipeline.map(timestamp=timestamp) except DataFeatures.TimestampedException as e: -- cgit v1.1