diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/GazeFeatures.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py index d4307a2..218858a 100644 --- a/src/argaze/GazeFeatures.py +++ b/src/argaze/GazeFeatures.py @@ -26,6 +26,9 @@ import numpy import pandas import cv2 +GazePositionType = TypeVar('GazePosition', bound="GazePosition") +# Type definition for type annotation convenience + @dataclass(frozen=True) class GazePosition(): """Define gaze position as a tuple of coordinates with precision.""" @@ -57,6 +60,11 @@ class GazePosition(): return json.dumps(self, ensure_ascii = False, default=vars) + def __mul__(self, value) -> GazePositionType: + """Multiply gaze position.""" + + return GazePosition(numpy.array(self.value) * value, precision= self.precision * numpy.linalg.norm(value)) + def __array__(self): """Cast as numpy array.""" |