aboutsummaryrefslogtreecommitdiff
path: root/src/argaze/GazeAnalysis/FocusPointInside.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/argaze/GazeAnalysis/FocusPointInside.py')
-rw-r--r--src/argaze/GazeAnalysis/FocusPointInside.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/argaze/GazeAnalysis/FocusPointInside.py b/src/argaze/GazeAnalysis/FocusPointInside.py
index d3073b5..2ac4411 100644
--- a/src/argaze/GazeAnalysis/FocusPointInside.py
+++ b/src/argaze/GazeAnalysis/FocusPointInside.py
@@ -29,6 +29,7 @@ class AOIMatcher(GazeFeatures.AOIMatcher):
"""Init looked aoi data."""
self.__looked_aoi_data = (None, None)
+ self.__matched_gaze_movement = None
def match(self, aoi_scene, gaze_movement, exclude=[]) -> Tuple[str, AOIFeatures.AreaOfInterest]:
"""Returns AOI containing fixation focus point."""
@@ -42,12 +43,54 @@ class AOIMatcher(GazeFeatures.AOIMatcher):
# Update looked aoi data
self.__looked_aoi_data = (name, aoi)
+ # Update matched gaze movement
+ self.__matched_gaze_movement = gaze_movement
+
return self.__looked_aoi_data
elif GazeFeatures.is_saccade(gaze_movement):
self.__post_init__()
+ def draw(self, image: numpy.array, draw_matched_fixation: dict = None, draw_matched_fixation_positions: dict = None, draw_looked_aoi: dict = None, looked_aoi_name_color: tuple = None, looked_aoi_name_offset: tuple = (0, 0)):
+ """Draw matching into image.
+
+ Parameters:
+ draw_matched_fixation: Fixation.draw parameters (which depends of the loaded gaze movement identifier module, if None, no fixation is drawn)
+ draw_matched_fixation_positions: GazeMovement.draw_positions parameters (if None, no fixation is drawn)
+ draw_looked_aoi: AOIFeatures.AOI.draw parameters (if None, no looked aoi is drawn)
+ looked_aoi_name_color: color of text (if None, no looked aoi name is drawn)
+ looked_aoi_name_offset: ofset of text from the upper left aoi bounding box corner
+ """
+
+ if self.__matched_gaze_movement:
+
+ if GazeFeatures.is_fixation(self.__matched_gaze_movement):
+
+ # Draw matched fixation if required
+ if draw_matched_fixation:
+
+ self.__matched_gaze_movement.draw(image, **draw_matched_fixation)
+
+ # Draw matched fixation positions if required
+ if draw_matched_fixation_positions:
+
+ self.__matched_gaze_movement.draw_positions(image, **draw_matched_fixation_positions)
+
+ # Draw matched aoi
+ if self.looked_aoi.all() != None:
+
+ # Draw looked aoi if required
+ if draw_looked_aoi:
+
+ self.looked_aoi.draw(image, **draw_looked_aoi)
+
+ # Draw looked aoi name if required
+ if looked_aoi_name_color:
+
+ top_left_corner_pixel = numpy.rint(self.looked_aoi.bounding_box[0]).astype(int) + looked_aoi_name_offset
+ cv2.putText(image, self.looked_aoi_name, top_left_corner_pixel, cv2.FONT_HERSHEY_SIMPLEX, 1, looked_aoi_name_color, 1, cv2.LINE_AA)
+
@property
def looked_aoi(self) -> AOIFeatures.AreaOfInterest:
"""Get most likely looked aoi for current fixation (e.g. the aoi with the highest coverage mean value)"""