aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/argaze/utils/MiscFeatures.py24
-rw-r--r--src/argaze/utils/__init__.py3
-rw-r--r--src/argaze/utils/export_tobii_segment_aruco_rois.py9
3 files changed, 35 insertions, 1 deletions
diff --git a/src/argaze/utils/MiscFeatures.py b/src/argaze/utils/MiscFeatures.py
new file mode 100644
index 0000000..24f1791
--- /dev/null
+++ b/src/argaze/utils/MiscFeatures.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+# Print iterations progress
+def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = "\r"):
+ """Print iterations progress.
+ Call in a loop to create terminal progress bar
+ @params:
+ iteration - Required : current iteration (Int)
+ total - Required : total iterations (Int)
+ prefix - Optional : prefix string (Str)
+ suffix - Optional : suffix string (Str)
+ decimals - Optional : positive number of decimals in percent complete (Int)
+ length - Optional : character length of bar (Int)
+ fill - Optional : bar fill character (Str)
+ printEnd - Optional : end character (e.g. "\r", "\r\n") (Str)
+ """
+ percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total)))
+ filledLength = int(length * iteration // total)
+ bar = fill * filledLength + '-' * (length - filledLength)
+ print(f'\r{prefix} |{bar}| {percent}% {suffix}', end = printEnd)
+
+ # Print New Line on Complete
+ if iteration == total:
+ print()
diff --git a/src/argaze/utils/__init__.py b/src/argaze/utils/__init__.py
index 1448ed6..262a0e2 100644
--- a/src/argaze/utils/__init__.py
+++ b/src/argaze/utils/__init__.py
@@ -1,4 +1,5 @@
"""
.. include:: README.md
"""
-__docformat__ = "restructuredtext" \ No newline at end of file
+__docformat__ = "restructuredtext"
+__all__ = ['MiscFeatures'] \ No newline at end of file
diff --git a/src/argaze/utils/export_tobii_segment_aruco_rois.py b/src/argaze/utils/export_tobii_segment_aruco_rois.py
index a192cf1..d28f887 100644
--- a/src/argaze/utils/export_tobii_segment_aruco_rois.py
+++ b/src/argaze/utils/export_tobii_segment_aruco_rois.py
@@ -9,6 +9,7 @@ from argaze import GazeFeatures
from argaze.TobiiGlassesPro2 import TobiiEntities, TobiiVideo
from argaze.ArUcoMarkers import *
from argaze.RegionOfInterest import *
+from argaze.utils import MiscFeatures
import numpy
@@ -86,6 +87,10 @@ def main():
# Video and data replay loop
try:
+ # print 0% progress
+ frame_count = 0
+ MiscFeatures.printProgressBar(frame_count, tobii_segment_video.get_frame_number(), prefix = 'Progress:', suffix = 'Complete', length = 100)
+
# Iterate on video frames activating video / data synchronisation through vts data buffer
for video_ts, video_frame in tobii_segment_video.frames(tobii_segment_data.vts):
@@ -147,6 +152,10 @@ def main():
# Write video
output_video.write(video_frame.matrix)
+ # Update Progress Bar
+ frame_count += 1
+ MiscFeatures.printProgressBar(frame_count, tobii_segment_video.get_frame_number(), prefix = 'Progress:', suffix = 'Complete', length = 100)
+
# Exit on 'ctrl+C' interruption
except KeyboardInterrupt:
pass