From 64df8beaf90d9f0bbaf0b1b51dae225f86c6a4c4 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Thu, 5 Oct 2023 13:48:33 +0200 Subject: Working on gaze processing time assessment. --- src/argaze/ArFeatures.py | 68 +++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) (limited to 'src') 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() -- cgit v1.1