diff options
author | Théo de la Hogue | 2023-06-27 14:57:27 +0200 |
---|---|---|
committer | Théo de la Hogue | 2023-06-27 14:57:27 +0200 |
commit | 05a4b79570d91db468abea44259e4a7f825906ca (patch) | |
tree | 742f695883dbd6b935d7709c0ba8fe061e7645da | |
parent | df0af798124b14ccc7188d8d7bbd3c9fd6f49ff0 (diff) | |
download | argaze-05a4b79570d91db468abea44259e4a7f825906ca.zip argaze-05a4b79570d91db468abea44259e4a7f825906ca.tar.gz argaze-05a4b79570d91db468abea44259e4a7f825906ca.tar.bz2 argaze-05a4b79570d91db468abea44259e4a7f825906ca.tar.xz |
Addin a multiply operator for GazePosition.
-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.""" |