aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2023-05-16 19:21:17 +0200
committerThéo de la Hogue2023-05-16 19:21:17 +0200
commit861d427355b7c086f73fd14661dac880abfdf05a (patch)
tree2e146ad5c4640bb24c48bf6f553b7727ca7e9ea7
parentcea1b65d8e3ba9827ffb4ed1fc4e89a8a3b57dd6 (diff)
downloadargaze-861d427355b7c086f73fd14661dac880abfdf05a.zip
argaze-861d427355b7c086f73fd14661dac880abfdf05a.tar.gz
argaze-861d427355b7c086f73fd14661dac880abfdf05a.tar.bz2
argaze-861d427355b7c086f73fd14661dac880abfdf05a.tar.xz
Using new AOIFrame class and point_spread method to draw heatmap.
-rw-r--r--src/argaze/utils/demo_gaze_features_run.py29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/argaze/utils/demo_gaze_features_run.py b/src/argaze/utils/demo_gaze_features_run.py
index 6294527..3fb664c 100644
--- a/src/argaze/utils/demo_gaze_features_run.py
+++ b/src/argaze/utils/demo_gaze_features_run.py
@@ -6,6 +6,7 @@ import time
import threading
from argaze import ArFeatures, GazeFeatures
+from argaze.AreaOfInterest import AOIFeatures
from argaze.GazeAnalysis import *
import cv2
@@ -48,6 +49,11 @@ def main():
# Init gaze processing
gaze_position = GazeFeatures.GazePosition()
+
+ screen_frame = AOIFeatures.AOIFrame(aoi_scene_projection['Screen'], window_size)
+ gaze_spread_sum = numpy.zeros((aoi_scene_image.shape[0], aoi_scene_image.shape[1]))
+ heatmap_matrix = numpy.zeros(aoi_scene_image.shape, dtype=numpy.uint8)
+
gaze_movement_identifier = {
'I-DT': DispersionThresholdIdentification.GazeMovementIdentifier(args.deviation_max_threshold, args.duration_min_threshold),
'I-VT': VelocityThresholdIdentification.GazeMovementIdentifier(args.velocity_max_threshold, args.duration_min_threshold)
@@ -77,6 +83,8 @@ def main():
def on_mouse_event(event, x, y, flags, param):
nonlocal gaze_position
+ nonlocal gaze_spread_sum
+ nonlocal heatmap_matrix
nonlocal tpm_analysis
nonlocal raw_cK_analysis
nonlocal aoi_cK_analysis
@@ -94,6 +102,11 @@ def main():
# Lock gaze movement exploitation
gaze_movement_lock.acquire()
+ # Edit heatmap
+ gaze_spread_sum += screen_frame.point_spread(gaze_position.value, sigma=0.05)
+ heatmap_gray = (255 * gaze_spread_sum / numpy.max(gaze_spread_sum)).astype(numpy.uint8)
+ heatmap_matrix = cv2.applyColorMap(heatmap_gray, cv2.COLORMAP_JET)
+
# Identify gaze movement accordding select identification mode
gaze_movement = gaze_movement_identifier[identification_mode].identify(data_ts, gaze_position)
@@ -112,8 +125,6 @@ def main():
look_at = name
break
-
-
# Append fixation to raw scan path
raw_scan_path.append_fixation(data_ts, gaze_movement)
@@ -162,12 +173,16 @@ def main():
aoi_matrix = aoi_scene_image.copy()
+ # Lock gaze movement identification
+ gaze_movement_lock.acquire()
+
+ # Draw gaze spread heatmap
+ aoi_matrix = cv2.addWeighted(heatmap_matrix, 0.5, aoi_matrix, 1., 0)
+ #aoi_matrix = numpy.maximum(aoi_matrix, heatmap_matrix)
+
# Write identification mode
cv2.putText(aoi_matrix, f'Gaze movement identification mode: {identification_mode} (Press \'m\' key to switch)', (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1, cv2.LINE_AA)
- # Lock gaze movement identification
- gaze_movement_lock.acquire()
-
# Check fixation identification
if gaze_movement_identifier[identification_mode].current_fixation != None:
@@ -260,6 +275,10 @@ def main():
cv2.putText(aoi_matrix, f'AOI: Focal attention', (20, window_size[1]-80), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 0), 1, cv2.LINE_AA)
+ ### TEST: GazePosition Heatmap
+
+ ##############################
+
# Unlock gaze movement identification
gaze_movement_lock.release()