aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/GazeAnalysis/FocusPointInside.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/argaze/GazeAnalysis/FocusPointInside.py b/src/argaze/GazeAnalysis/FocusPointInside.py
new file mode 100644
index 0000000..bcb77b1
--- /dev/null
+++ b/src/argaze/GazeAnalysis/FocusPointInside.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+"""Matching algorithm based on fixation's focus point
+"""
+
+__author__ = "Théo de la Hogue"
+__credits__ = []
+__copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)"
+__license__ = "BSD"
+
+from typing import TypeVar, Tuple
+from dataclasses import dataclass, field
+import math
+
+from argaze import GazeFeatures
+
+import numpy
+import cv2
+
+GazeMovementType = TypeVar('GazeMovement', bound="GazeMovement")
+# Type definition for type annotation convenience
+
+@dataclass
+class AOIMatcher(GazeFeatures.AOIMatcher):
+
+ def __post_init__(self):
+ """Init looked aoi data."""
+
+ self.__looked_aoi = None
+
+ def match(self, aoi_scene, gaze_movement, exclude=[]) -> str:
+ """Returns AOI containing fixation focus point."""
+
+ if GazeFeatures.is_fixation(gaze_movement):
+
+ for name, aoi in aoi_scene.items():
+
+ if name not in exclude and aoi.contains_point(gaze_movement.focus):
+
+ # Update looked aoi
+ self.__looked_aoi = name
+
+ return self.__looked_aoi
+
+ elif GazeFeatures.is_saccade(gaze_movement):
+
+ self.__post_init__()
+
+ @property
+ def looked_aoi(self) -> str:
+ """Get most likely looked aoi name for current fixation (e.g. the aoi with the highest coverage mean value)"""
+
+ return self.__looked_aoi