diff options
author | Théo de la Hogue | 2024-04-02 13:10:22 +0200 |
---|---|---|
committer | Théo de la Hogue | 2024-04-02 13:10:22 +0200 |
commit | 5fa525837d885d815074064da5736ef7f8638de0 (patch) | |
tree | 896cd57e1c579e5d715483ca056664a12839c820 /src | |
parent | cd48c4857834c2bef0d42475de12eb906ef7d82c (diff) | |
download | argaze-5fa525837d885d815074064da5736ef7f8638de0.zip argaze-5fa525837d885d815074064da5736ef7f8638de0.tar.gz argaze-5fa525837d885d815074064da5736ef7f8638de0.tar.bz2 argaze-5fa525837d885d815074064da5736ef7f8638de0.tar.xz |
Adding debug property to ArContext. Logging image function.
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/ArFeatures.py | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 91b63ac..56ea41d 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -843,14 +843,20 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): # Use frame lock feature with self._lock: + logging.debug('ArFrame.__image %s', self.name) + # Draw background only if background_weight is not None and (heatmap_weight is None or self.__heatmap is None): + logging.debug('\t> drawing background only') + image = self.__background.copy() # Draw mix background and heatmap if required elif background_weight is not None and heatmap_weight is not None and self.__heatmap: + logging.debug('\t> drawing background and heatmap') + background_image = self.__background.copy() heatmap_image = cv2.resize(self.__heatmap.image, dsize=self.__size, interpolation=cv2.INTER_LINEAR) image = cv2.addWeighted(heatmap_image, heatmap_weight, background_image, background_weight, 0) @@ -858,21 +864,29 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): # Draw heatmap only elif background_weight is None and heatmap_weight is not None and self.__heatmap: + logging.debug('\t> drawing heatmap only') + image = cv2.resize(self.__heatmap.image, dsize=self.__size, interpolation=cv2.INTER_LINEAR) # Draw black image else: + logging.debug('\t> drawing black image') + image = numpy.full((self.__size[1], self.__size[0], 3), 0).astype(numpy.uint8) # Draw gaze position calibrator if draw_gaze_position_calibrator is not None: + logging.debug('\t> drawing gaze position calibrator') + self.__gaze_position_calibrator.draw(image, size=self.__size, **draw_gaze_position_calibrator) # Draw scan path if required if draw_scan_path is not None and self.__scan_path is not None: + logging.debug('\t> drawing scan path') + self.__scan_path.draw(image, **draw_scan_path) # Draw current fixation if required @@ -880,6 +894,8 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): if self.__gaze_movement_identifier.current_fixation(): + logging.debug('\t> drawing current fixation') + self.__gaze_movement_identifier.current_fixation().draw(image, **draw_fixations) # Draw current saccade if required @@ -887,6 +903,8 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): if self.__gaze_movement_identifier.current_saccade(): + logging.debug('\t> drawing current saccade') + self.__gaze_movement_identifier.current_saccade().draw(image, **draw_saccades) # Draw layers if required @@ -894,7 +912,9 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): for layer_name, draw_layer in draw_layers.items(): - try : + try: + + logging.debug('\t> drawing %s layer', layer_name) self._layers[layer_name].draw(image, **draw_layer) @@ -905,8 +925,12 @@ class ArFrame(DataFeatures.SharedObject, DataFeatures.PipelineStepObject): # Draw current gaze position if required if draw_gaze_positions is not None: + logging.debug('\t> drawing current gaze position') + self.__calibrated_gaze_position.draw(image, **draw_gaze_positions) + logging.debug('\t> returning image (%i x %i)', *image.shape[:2]) + return DataFeatures.TimestampedImage(image, timestamp = self.__background.timestamp) def image(self, **kwargs: dict) -> numpy.array: @@ -1417,6 +1441,7 @@ class ArContext(DataFeatures.PipelineStepObject): # Init private attributes self.__pipeline = None + self.__debug = False self.__exceptions = DataFeatures.TimestampedExceptions() # Init gaze position processing assement @@ -1440,6 +1465,16 @@ class ArContext(DataFeatures.PipelineStepObject): self.__pipeline = pipeline @property + def debug(self) -> bool: + """Disable pipeline exception catching to make it crash instead.""" + return self.__debug + + @debug.setter + def debug(self, debug: bool): + + self.__debug = debug + + @property def image_parameters(self) -> dict: """Default image method parameters dictionary.""" return self._image_parameters @@ -1496,12 +1531,12 @@ class ArContext(DataFeatures.PipelineStepObject): if x is None and y is None: # Edit empty gaze position - self.__pipeline.look( GazeFeatures.GazePosition( timestamp = timestamp) ) + self.__pipeline.look( GazeFeatures.GazePosition( timestamp = timestamp), debug = self.__debug ) else: # Edit gaze position - self.__pipeline.look( GazeFeatures.GazePosition( (x, y), precision = precision, timestamp = timestamp)) + self.__pipeline.look( GazeFeatures.GazePosition( (x, y), precision = precision, timestamp = timestamp), debug = self.__debug) except DataFeatures.TimestampedException as e: @@ -1530,7 +1565,7 @@ class ArContext(DataFeatures.PipelineStepObject): logging.debug('\t> watch image (%i x %i)', width, height) - self.__pipeline.watch( DataFeatures.TimestampedImage(image, timestamp = timestamp)) + self.__pipeline.watch( DataFeatures.TimestampedImage(image, timestamp = timestamp), debug = self.__debug ) except DataFeatures.TimestampedException as e: |