aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/ArFeatures.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index 6727928..03082e6 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -99,11 +99,6 @@ class ArFrame():
# Init looked aoi data
self.__init_looked_aoi_data()
- # Init heatmap if required
- if self.heatmap:
-
- self.heatmap.init()
-
# Init lock to share looked data wit hmultiples threads
self.__look_lock = threading.Lock()
@@ -316,11 +311,19 @@ class ArFrame():
# Load heatmap
try:
- new_heatmap_value = frame_data.pop('heatmap')
+ new_heatmap_data = frame_data.pop('heatmap')
+
+ # Default heatmap size equals frame size
+ if 'size' not in new_heatmap_data.keys():
+
+ new_heatmap_data['size'] = new_frame_size
+
+ new_heatmap = AOIFeatures.Heatmap(**new_heatmap_data)
except KeyError:
- new_heatmap_value = False
+ new_heatmap_data = {}
+ new_heatmap = None
# Create frame
return ArFrame(new_frame_name, \
@@ -334,7 +337,7 @@ class ArFrame():
new_scan_path_analyzers, \
new_aoi_scan_path, \
new_aoi_scan_path_analyzers, \
- AOIFeatures.Heatmap(new_frame_size) if new_heatmap_value else None \
+ new_heatmap \
)
@classmethod
@@ -379,7 +382,8 @@ class ArFrame():
# Draw heatmap
if self.heatmap:
- image = cv2.addWeighted(self.heatmap.image, 0.5, image, 1., 0)
+ heatmap_image = cv2.resize(self.heatmap.image, dsize=(image.shape[1], image.shape[0]), interpolation=cv2.INTER_LINEAR)
+ image = cv2.addWeighted(heatmap_image, 0.5, image, 1., 0)
# Unlock frame exploitation
self.__look_lock.release()
@@ -601,7 +605,11 @@ class ArFrame():
# Store heatmap start date
heatmap_start = time.time()
- self.heatmap.update(self.__gaze_position.value, sigma=0.05)
+ # Scale gaze position value
+ scale = numpy.array([self.heatmap.size[0] / self.size[0], self.heatmap.size[1] / self.size[1]])
+
+ # Update heatmap image
+ self.heatmap.update(self.__gaze_position.value * scale)
# Assess heatmap time in ms
times['heatmap'] = (time.time() - heatmap_start) * 1e3