aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoTracker.py19
-rw-r--r--src/argaze/utils/export_tobii_segment_aruco_visual_scan.py16
2 files changed, 32 insertions, 3 deletions
diff --git a/src/argaze/ArUcoMarkers/ArUcoTracker.py b/src/argaze/ArUcoMarkers/ArUcoTracker.py
index 363a5bb..6a71e86 100644
--- a/src/argaze/ArUcoMarkers/ArUcoTracker.py
+++ b/src/argaze/ArUcoMarkers/ArUcoTracker.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import json
+from collections import Counter
from argaze.ArUcoMarkers import ArUcoMarkersDictionary, ArUcoCamera
@@ -74,6 +75,10 @@ class ArUcoTracker():
self.__board_corners = []
self.__board_corners_ids = []
+ # define track metrics data
+ self.__track_count = 0
+ self.__tracked_markers = []
+
def load_configuration_file(self, configuration_filepath):
"""Load aruco detection parameters from .json file."""
@@ -108,6 +113,11 @@ class ArUcoTracker():
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
self.__markers_corners, self.__markers_ids, rejectedPoints = aruco.detectMarkers(gray, self.__aruco_dict.get_markers(), parameters = self.__detector_parameters)
+ # update track metrics
+ self.__track_count += 1
+ for marker_id in self.get_markers_ids():
+ self.__tracked_markers.append(marker_id)
+
if len(self.__markers_corners) > 0 and estimate_pose:
# markers pose estimation
@@ -163,6 +173,15 @@ class ArUcoTracker():
cv.drawChessboardCorners(frame, ((self.__board.get_size()[0] - 1 ), (self.__board.get_size()[1] - 1)), self.__board_corners, True)
+ def reset_track_metrics(self):
+ """Enable marker tracking metrics."""
+ self.__track_count = 0
+ self.__tracked_markers = []
+
+ def get_track_metrics(self):
+ """Get marker tracking metrics."""
+ return self.__track_count, Counter(self.__tracked_markers)
+
def get_markers_dictionay(self):
"""Get tracked aruco markers dictionary."""
return self.__aruco_dict
diff --git a/src/argaze/utils/export_tobii_segment_aruco_visual_scan.py b/src/argaze/utils/export_tobii_segment_aruco_visual_scan.py
index 7a270f3..6c34ba9 100644
--- a/src/argaze/utils/export_tobii_segment_aruco_visual_scan.py
+++ b/src/argaze/utils/export_tobii_segment_aruco_visual_scan.py
@@ -161,7 +161,7 @@ def main():
try:
# Initialise progress bar
- MiscFeatures.printProgressBar(0, tobii_segment_video.get_duration(), prefix = 'Progress:', suffix = 'Complete', length = 100)
+ MiscFeatures.printProgressBar(0, tobii_segment_video.get_duration()/1000, prefix = 'Progress:', suffix = 'Complete', length = 100)
# Iterate on video frames
for video_ts, video_frame in tobii_segment_video.frames():
@@ -239,7 +239,7 @@ def main():
# Update Progress Bar
progress = video_ts_ms - int(args.time_range[0] * 1000)
- MiscFeatures.printProgressBar(progress, tobii_segment_video.get_duration(), prefix = 'Progress:', suffix = 'Complete', length = 100)
+ MiscFeatures.printProgressBar(progress, tobii_segment_video.get_duration()/1000, prefix = 'Progress:', suffix = 'Complete', length = 100)
# Exit on 'ctrl+C' interruption
except KeyboardInterrupt:
@@ -250,7 +250,13 @@ def main():
# End output video file
output_video.close()
- print(f'\nVisual scan video saved into {vs_video_filepath}')
+
+ # Print aruco tracking metrics
+ print('\nAruco marker tracking metrics')
+ try_count, tracked_counts = aruco_tracker.get_track_metrics()
+
+ for marker_id, tracked_count in tracked_counts.items():
+ print(f'Markers {marker_id} has been detected in {tracked_count} / {try_count} frames ({round(100 * tracked_count / try_count, 2)} %)')
# Build visual scan based on a pointer position
visual_scan = GazeFeatures.PointerBasedVisualScan(ts_aois_scenes, ts_gaze_positions)
@@ -264,6 +270,10 @@ def main():
cv.imwrite(vs_visu_filepath, visu_frame)
print(f'Visual scan image saved into {vs_visu_filepath}')
+ # Notify where the visual scan video has been exported
+ print(f'Visual scan video saved into {vs_video_filepath}')
+
+
if __name__ == '__main__':
main() \ No newline at end of file