aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThéo de la Hogue2023-10-05 13:48:33 +0200
committerThéo de la Hogue2023-10-05 13:48:33 +0200
commit64df8beaf90d9f0bbaf0b1b51dae225f86c6a4c4 (patch)
tree7b8b78f0dc2312e791f7cf3f21a18e523f31e536
parentcdf4e23d2876b7a43b5a3712467d503723fa7a52 (diff)
downloadargaze-64df8beaf90d9f0bbaf0b1b51dae225f86c6a4c4.zip
argaze-64df8beaf90d9f0bbaf0b1b51dae225f86c6a4c4.tar.gz
argaze-64df8beaf90d9f0bbaf0b1b51dae225f86c6a4c4.tar.bz2
argaze-64df8beaf90d9f0bbaf0b1b51dae225f86c6a4c4.tar.xz
Working on gaze processing time assessment.
-rw-r--r--src/argaze/ArFeatures.py68
1 files changed, 32 insertions, 36 deletions
diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py
index b9b51d0..02da0fe 100644
--- a/src/argaze/ArFeatures.py
+++ b/src/argaze/ArFeatures.py
@@ -374,6 +374,9 @@ class ArLayer():
# Lock layer exploitation
self.__look_lock.acquire()
+ # Store look execution start date
+ look_start = time.perf_counter()
+
# Update current gaze movement
self.__gaze_movement = gaze_movement
@@ -452,23 +455,13 @@ class ArLayer():
looked_aoi = None
aoi_scan_path_analysis = {}
exception = e
+
+ # Assess total execution time in ms
+ execution_times['total'] = (time.perf_counter() - look_start) * 1e3
# Unlock layer exploitation
self.__look_lock.release()
- # Sum all execution times
- total_execution_time = 0
-
- if execution_times['aoi_matcher']:
-
- total_execution_time += execution_times['aoi_matcher']
-
- for _, aoi_scan_path_analysis_time in execution_times['aoi_scan_step_analyzers'].items():
-
- total_execution_time += aoi_scan_path_analysis_time
-
- execution_times['total'] = total_execution_time
-
# Return look data
return looked_aoi, aoi_scan_path_analysis, execution_times, exception
@@ -832,6 +825,9 @@ class ArFrame():
# Lock frame exploitation
self.__look_lock.acquire()
+ # Store look execution start date
+ look_start = time.perf_counter()
+
# Update current gaze position
self.__gaze_position = gaze_position
@@ -950,30 +946,12 @@ class ArFrame():
scan_step_analysis = {}
layer_analysis = {}
exception = e
-
- # Unlock frame exploitation
- self.__look_lock.release()
-
- # Sum all execution times
- total_execution_time = 0
-
- if execution_times['gaze_movement_identifier']:
- total_execution_time += execution_times['gaze_movement_identifier']
+ # Assess total execution time in ms
+ execution_times['total'] = (time.perf_counter() - look_start) * 1e3
- for _, scan_step_analysis_time in execution_times['scan_step_analyzers'].items():
-
- total_execution_time += scan_step_analysis_time
-
- if execution_times['heatmap']:
-
- total_execution_time += execution_times['heatmap']
-
- for _, layer_execution_times in execution_times['layers'].items():
-
- total_execution_time += layer_execution_times['total']
-
- execution_times['total'] = total_execution_time
+ # Unlock frame exploitation
+ self.__look_lock.release()
# Return look data
return identified_gaze_movement, scan_step_analysis, layer_analysis, execution_times, exception
@@ -1431,15 +1409,33 @@ class ArCamera(ArFrame):
def look(self, timestamp: int|float, gaze_position: GazeFeatures.GazePosition):
"""Project timestamped gaze position into each scene frames.
+ Parameters:
+ timestamp: gaze position time stamp (unit does'nt matter)
+ gaze_position: GazePosition object
+ timeout: maximal waiting time in ms
+
!!! warning
watch method needs to be called first.
"""
# Can't use camera frame while it is locked
- # TODO? Do we need a timeout parameter here?
+ wait_start = time.perf_counter()
+ waiting_time = 0
+
while self._frame_lock.locked():
time.sleep(1e-6)
+ waiting_time = (time.perf_counter() - wait_start) * 1e3
+
+ # TODO? return waiting time?
+
+ # TODO? add timeout parameter?
+ #if waiting_time > timeout:
+ # return None, None
+
+ # DEBUG
+ if waiting_time > 0:
+ print(f'ArCamera: waiting {waiting_time:.3f} ms before to process gaze position at {timestamp} time.')
# Lock camera frame exploitation
self._frame_lock.acquire()