From 0e8ca119eea54e464450946c01d6b63e4e4ec1d1 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 8 Aug 2023 17:02:47 +0200 Subject: Replacing time.time() by time.perf_counter() as the old one was not enough precise under windows plateform. --- src/argaze/ArFeatures.py | 24 ++++++++++++------------ src/argaze/ArUcoMarkers/ArUcoDetector.py | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/argaze/ArFeatures.py b/src/argaze/ArFeatures.py index 6c9eab1..b4b1e39 100644 --- a/src/argaze/ArFeatures.py +++ b/src/argaze/ArFeatures.py @@ -495,13 +495,13 @@ class ArFrame(): if self.gaze_movement_identifier: # Store movement identification start date - identification_start = time.time() + identification_start = time.perf_counter() # Identify finished gaze movement temp_gaze_movement = self.gaze_movement_identifier.identify(timestamp, self.__gaze_position) # Assess movement identification time in ms - times['gaze_movement_identifier'] = (time.time() - identification_start) * 1e3 + times['gaze_movement_identifier'] = (time.perf_counter() - identification_start) * 1e3 # Use given identified gaze movement else: @@ -514,13 +514,13 @@ class ArFrame(): if GazeFeatures.is_fixation(temp_gaze_movement): # Store aoi matching start date - matching_start = time.time() + matching_start = time.perf_counter() # Does the finished fixation match an aoi? self.__update_looked_aoi_data(temp_gaze_movement) # Assess aoi matching time in ms - times['aoi_matcher'] = (time.time() - matching_start) * 1e3 + times['aoi_matcher'] = (time.perf_counter() - matching_start) * 1e3 # Append fixation to scan path if self.scan_path != None: @@ -538,13 +538,13 @@ class ArFrame(): for aoi_scan_path_analyzer_type, aoi_scan_path_analyzer in self.aoi_scan_path_analyzers.items(): # Store aoi scan step analysis start date - aoi_scan_step_analysis_start = time.time() + aoi_scan_step_analysis_start = time.perf_counter() # Analyze aoi scan path aoi_scan_path_analyzer.analyze(self.aoi_scan_path) # Assess aoi scan step analysis time in ms - times['aoi_scan_step_analyzers'][aoi_scan_path_analyzer_type] = (time.time() - aoi_scan_step_analysis_start) * 1e3 + times['aoi_scan_step_analyzers'][aoi_scan_path_analyzer_type] = (time.perf_counter() - aoi_scan_step_analysis_start) * 1e3 # Store analysis aoi_scan_step_analysis[aoi_scan_path_analyzer_type] = aoi_scan_path_analyzer.analysis @@ -565,13 +565,13 @@ class ArFrame(): for scan_path_analyzer_type, scan_path_analyzer in self.scan_path_analyzers.items(): # Store scan step analysis start date - scan_step_analysis_start = time.time() + scan_step_analysis_start = time.perf_counter() # Analyze aoi scan path scan_path_analyzer.analyze(self.scan_path) # Assess scan step analysis time in ms - times['scan_step_analyzers'][scan_path_analyzer_type] = (time.time() - scan_step_analysis_start) * 1e3 + times['scan_step_analyzers'][scan_path_analyzer_type] = (time.perf_counter() - scan_step_analysis_start) * 1e3 # Store analysis scan_step_analysis[scan_path_analyzer_type] = scan_path_analyzer.analysis @@ -591,19 +591,19 @@ class ArFrame(): temp_gaze_movement = current_fixation # Store aoi matching start date - matching_start = time.time() + matching_start = time.perf_counter() # Does the current fixation match an aoi? self.__update_looked_aoi_data(current_fixation) # Assess aoi matching time in ms - times['aoi_matcher'] = (time.time() - matching_start) * 1e3 + times['aoi_matcher'] = (time.perf_counter() - matching_start) * 1e3 # Update heatmap if self.heatmap: # Store heatmap start date - heatmap_start = time.time() + heatmap_start = time.perf_counter() # Scale gaze position value scale = numpy.array([self.heatmap.size[0] / self.size[0], self.heatmap.size[1] / self.size[1]]) @@ -612,7 +612,7 @@ class ArFrame(): self.heatmap.update(self.__gaze_position.value * scale) # Assess heatmap time in ms - times['heatmap'] = (time.time() - heatmap_start) * 1e3 + times['heatmap'] = (time.perf_counter() - heatmap_start) * 1e3 except Exception as e: diff --git a/src/argaze/ArUcoMarkers/ArUcoDetector.py b/src/argaze/ArUcoMarkers/ArUcoDetector.py index c750e1b..5076f3d 100644 --- a/src/argaze/ArUcoMarkers/ArUcoDetector.py +++ b/src/argaze/ArUcoMarkers/ArUcoDetector.py @@ -190,13 +190,13 @@ class ArUcoDetector(): self.__detected_markers, self.__detected_markers_corners, self.__detected_markers_ids = {}, [], [] # Store marker detection start date - detection_start = time.time() + detection_start = time.perf_counter() # Detect markers into gray picture self.__detected_markers_corners, self.__detected_markers_ids, _ = aruco.detectMarkers(cv.cvtColor(image, cv.COLOR_BGR2GRAY), self.dictionary.markers, parameters = self.parameters.internal) # Assess marker detection time in ms - detection_time = (time.time() - detection_start) * 1e3 + detection_time = (time.perf_counter() - detection_start) * 1e3 # Is there detected markers ? if len(self.__detected_markers_corners) > 0: -- cgit v1.1