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.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index 8e9e63e..d78d80a 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -29,6 +29,7 @@ import math
from argaze import DataFeatures, GazeFeatures
from argaze.AreaOfInterest import *
from argaze.GazeAnalysis import *
+from argaze.utils import UtilsFeatures
import numpy
import cv2
@@ -1365,14 +1366,14 @@ class ArContext(DataFeatures.PipelineStepObject):
@DataFeatures.PipelineStepInit
def __init__(self, **kwargs):
- logging.debug('ArContext.__init__')
-
DataFeatures.PipelineStepObject.__init__(self)
# Init private attributes
self.__pipeline = None
self.__exceptions = DataFeatures.TimestampedExceptions()
+ self.__process_gaze_position_chrono = UtilsFeatures.TimeProbe()
+
# Init protected attributes
self._image_parameters = DEFAULT_ARCONTEXT_IMAGE_PARAMETERS
@@ -1413,22 +1414,17 @@ class ArContext(DataFeatures.PipelineStepObject):
"image_parameters": self._image_parameters
}
+ @DataFeatures.PipelineStepEnter
def __enter__(self):
- """
- Define abstract __enter__ method to use device as a context.
+ """Enter into ArContext."""
+
+ self.__process_gaze_position_chrono.start()
- !!! warning
- This method is called provided that the ArContext is created using a with statement.
- """
return self
+ @DataFeatures.PipelineStepEnter
def __exit__(self, type, value, traceback):
- """
- Define abstract __exit__ method to use device as a context.
-
- !!! warning
- This method is called provided that the ArContext is created using a with statement.
- """
+ """Exit from ArContext."""
pass
def _process_gaze_position(self, timestamp: int|float, x: int|float = None, y: int|float = None, precision: int|float = None):
@@ -1436,6 +1432,13 @@ class ArContext(DataFeatures.PipelineStepObject):
logging.debug('%s._process_gaze_position', type(self).__name__)
+ lap_time, nb_laps, elapsed_time = gaze_position_processing_chrono.lap()
+
+ if elapsed_time > 1e3:
+
+ gaze_positions_frequency = nb_laps
+ gaze_position_processing_chrono.restart()
+
if issubclass(type(self.__pipeline), ArFrame):
try:
@@ -1508,7 +1511,7 @@ class ArContext(DataFeatures.PipelineStepObject):
if draw_times:
info_stack += 1
- cv2.putText(image, f'{image.timestamp}ms', (20, info_stack * 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
+ cv2.putText(image, f'Frame at {image.timestamp}ms', (20, info_stack * 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
if issubclass(type(self.__pipeline), ArCamera):