aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2022-09-07 22:32:07 +0200
committerThéo de la Hogue2022-09-07 22:32:07 +0200
commit548b37e639aaa3dd04ea570bfa0de32fd6bbc21f (patch)
tree24360a53af40dadf1ba5cf089b5a1e1d626daa23 /src
parent17878bf1ce1e6db238af8f2e170a8eeaa6870e55 (diff)
downloadargaze-548b37e639aaa3dd04ea570bfa0de32fd6bbc21f.zip
argaze-548b37e639aaa3dd04ea570bfa0de32fd6bbc21f.tar.gz
argaze-548b37e639aaa3dd04ea570bfa0de32fd6bbc21f.tar.bz2
argaze-548b37e639aaa3dd04ea570bfa0de32fd6bbc21f.tar.xz
Adding get frame method.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/TobiiGlassesPro2/TobiiVideo.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/argaze/TobiiGlassesPro2/TobiiVideo.py b/src/argaze/TobiiGlassesPro2/TobiiVideo.py
index fb84c04..7625c3c 100644
--- a/src/argaze/TobiiGlassesPro2/TobiiVideo.py
+++ b/src/argaze/TobiiGlassesPro2/TobiiVideo.py
@@ -63,6 +63,31 @@ class TobiiVideoSegment():
def get_vts_offset(self):
return self.__vts_offset
+ def get_frame(self, i):
+ """Acces to a frame."""
+
+ if i < 0:
+ ValueError('Frame index must be a positive integer.')
+
+ counter = 0
+ frame = None
+ video_ts = 0
+
+ # position at the given start time
+ self.__container.seek(self.__start_timestamp)
+
+ # start decoding
+ self.__container.decode(self.__stream)
+
+ while counter <= i:
+
+ frame = self.__container.decode(self.__stream).__next__()
+ video_ts = int(frame.time * 1e6)
+ counter += 1
+
+ # return micro second timestamp and frame data
+ return video_ts, TobiiVideoFrame(frame.to_ndarray(format='bgr24'), frame.width, frame.height)
+
def frames(self):
"""Access to frame iterator."""