aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2023-08-23 15:54:58 +0200
committerThéo de la Hogue2023-08-23 15:54:58 +0200
commite8009b32ab280abc87490d8f6d88007848abcde7 (patch)
treefc8a9ebef21ce6e905b54bac9210d25cb0a75564
parente88fe8f8c2b0bffee3d67b73200381cde2351dab (diff)
downloadargaze-e8009b32ab280abc87490d8f6d88007848abcde7.zip
argaze-e8009b32ab280abc87490d8f6d88007848abcde7.tar.gz
argaze-e8009b32ab280abc87490d8f6d88007848abcde7.tar.bz2
argaze-e8009b32ab280abc87490d8f6d88007848abcde7.tar.xz
Adding new FocusPointInside AOI matching algorithm.
-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