aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/ArFeatures.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/argaze/ArFeatures.py')
-rw-r--r--src/argaze/ArFeatures.py50
1 files changed, 42 insertions, 8 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index 6b4b182..b70cc40 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -24,6 +24,7 @@ import sys
import importlib
import threading
import time
+import math
from argaze import DataFeatures, GazeFeatures
from argaze.AreaOfInterest import *
@@ -1344,6 +1345,7 @@ class ArCamera(ArFrame):
# Define default ArContext image parameters
DEFAULT_ARCONTEXT_IMAGE_PARAMETERS = {
+ "draw_times": True,
"draw_exceptions": True
}
@@ -1408,7 +1410,7 @@ class ArContext(DataFeatures.PipelineStepObject):
Define abstract __enter__ method to use device as a context.
!!! warning
- This method is called provided that the PipelineInput is created as a context using a with statement.
+ This method is called provided that the ArContext is created using a with statement.
"""
return self
@@ -1417,14 +1419,14 @@ class ArContext(DataFeatures.PipelineStepObject):
Define abstract __exit__ method to use device as a context.
!!! warning
- This method is called provided that the PipelineInput is created as a context using a with statement.
+ This method is called provided that the ArContext is created using a with statement.
"""
pass
def _process_gaze_position(self, timestamp: int|float, x: int|float = None, y: int|float = None, precision: int|float = None):
"""Request pipeline to process new gaze position at a timestamp."""
- logging.debug('%s._process_gaze_position timestamp: %f', type(self).__name__, timestamp)
+ logging.debug('%s._process_gaze_position', type(self).__name__)
if issubclass(type(self.__pipeline), ArFrame):
@@ -1451,7 +1453,7 @@ class ArContext(DataFeatures.PipelineStepObject):
def _process_camera_image(self, timestamp: int|float, image: numpy.ndarray):
"""Request pipeline to process new camera image at a timestamp."""
- logging.debug('%s._process_camera_image timestamp: %f', type(self).__name__, timestamp)
+ logging.debug('%s._process_camera_image', type(self).__name__)
if issubclass(type(self.__pipeline), ArCamera):
@@ -1460,7 +1462,7 @@ class ArContext(DataFeatures.PipelineStepObject):
# Compare image size with ArCamera frame size
if width != self.__pipeline.size[0] or height != self.__pipeline.size[1]:
- logging.warning('image size (%i x %i) is different of ArCamera frame size (%i x %i)', width, height, self.__pipeline.size[0], self.__pipeline.size[1])
+ logging.warning('%s._process_camera_image: image size (%i x %i) is different of ArCamera frame size (%i x %i)', type(self).__name__ , width, height, self.__pipeline.size[0], self.__pipeline.size[1])
return
try:
@@ -1471,7 +1473,7 @@ class ArContext(DataFeatures.PipelineStepObject):
except DataFeatures.TimestampedException as e:
- logging.warning('%s', e)
+ logging.warning('%s._process_camera_image: %s', type(self).__name__, e)
self.__exceptions.append(e)
@@ -1479,7 +1481,7 @@ class ArContext(DataFeatures.PipelineStepObject):
raise(TypeError('Pipeline is not ArCamera instance.'))
- def __image(self, draw_exceptions: bool):
+ def __image(self, draw_times: bool, draw_exceptions: bool):
"""
Get pipeline image with execution informations.
@@ -1493,6 +1495,38 @@ class ArContext(DataFeatures.PipelineStepObject):
logging.debug('\t> get image (%i x %i)', width, height)
+ info_stack = 0
+
+ if draw_times:
+
+
+
+ if issubclass(type(self.__pipeline), ArCamera):
+
+ try:
+
+ watch_time = int(self.__pipeline.execution_times['watch'])
+
+ except KeyError:
+
+ watch_time = math.nan
+
+ info_stack += 1
+ cv2.putText(image, f'Watch {watch_time}ms', (20, info_stack * 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
+
+ if issubclass(type(self.__pipeline), ArFrame):
+
+ try:
+
+ look_time = self.__pipeline.execution_times['look']
+
+ except KeyError:
+
+ look_time = math.nan
+
+ info_stack += 1
+ cv2.putText(image, f'Look {look_time:.2f}ms', (20, info_stack * 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
+
if draw_exceptions:
# Write exceptions
@@ -1511,7 +1545,7 @@ class ArContext(DataFeatures.PipelineStepObject):
Get pipeline image.
Parameters:
- kwargs: PipelineInput.__image parameters
+ kwargs: ArContext.__image parameters
"""
# Use image_parameters attribute if no kwargs
if kwargs: