diff options
author | Théo de la Hogue | 2022-10-17 11:20:52 +0200 |
---|---|---|
committer | Théo de la Hogue | 2022-10-17 11:20:52 +0200 |
commit | 7bf9dd1c9799bc48ff386eca32dfb29c416f0608 (patch) | |
tree | ee4ae64ad8e7ae3c0f19195ed1b5f307c6b0a5cc /src | |
parent | 78b8df96b3b807acb368b9e7f077cecddfa86797 (diff) | |
download | argaze-7bf9dd1c9799bc48ff386eca32dfb29c416f0608.zip argaze-7bf9dd1c9799bc48ff386eca32dfb29c416f0608.tar.gz argaze-7bf9dd1c9799bc48ff386eca32dfb29c416f0608.tar.bz2 argaze-7bf9dd1c9799bc48ff386eca32dfb29c416f0608.tar.xz |
Processing TobiivideoFrame height and width at init time
Diffstat (limited to 'src')
-rw-r--r-- | src/argaze/TobiiGlassesPro2/TobiiVideo.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/argaze/TobiiGlassesPro2/TobiiVideo.py b/src/argaze/TobiiGlassesPro2/TobiiVideo.py index 2cc12cf..c7901f3 100644 --- a/src/argaze/TobiiGlassesPro2/TobiiVideo.py +++ b/src/argaze/TobiiGlassesPro2/TobiiVideo.py @@ -18,12 +18,16 @@ class TobiiVideoFrame(): """Define tobii video frame""" matrix: list - width: int - height: int + width: int = field(init=False) + height: int = field(init=False) + + def __post_init__(self): + """fill dimension attributes.""" + self.height, self.width = self.matrix.shape[:2] def copy(self): """Copy tobii video frame.""" - return TobiiVideoFrame(self.matrix.copy(), self.width, self.height) + return TobiiVideoFrame(self.matrix.copy()) class TobiiVideoSegment(): """Handle Tobii Glasses Pro 2 segment video file.""" @@ -90,7 +94,7 @@ class TobiiVideoSegment(): counter += 1 # return micro second timestamp and frame data - return video_ts, TobiiVideoFrame(frame.to_ndarray(format='bgr24'), frame.width, frame.height) + return video_ts, TobiiVideoFrame(frame.to_ndarray(format='bgr24')) def frames(self): """Access to frame iterator.""" @@ -121,7 +125,7 @@ class TobiiVideoSegment(): raise StopIteration # return micro second timestamp and frame data - return video_ts, TobiiVideoFrame(frame.to_ndarray(format='bgr24'), frame.width, frame.height) + return video_ts, TobiiVideoFrame(frame.to_ndarray(format='bgr24')) class TobiiVideoStream(threading.Thread): """Capture Tobii Glasses Pro 2 video camera stream.""" @@ -190,8 +194,8 @@ class TobiiVideoStream(threading.Thread): # lock frame access self.__read_lock.acquire() - # store frame time, matrix, width, height and pts into a tuple - self.__frame_tuple = (frame.time, frame.to_ndarray(format='bgr24'), frame.width, frame.height) + # store frame time, matrix into a tuple + self.__frame_tuple = (frame.time, frame.to_ndarray(format='bgr24')) # unlock frame access self.__read_lock.release() @@ -200,7 +204,7 @@ class TobiiVideoStream(threading.Thread): # if the video acquisition thread have been stopped or isn't started if self.__stop_event.isSet() or self.__frame_tuple == None: - return -1, TobiiVideoFrame(numpy.zeros((1, 1, 3), numpy.uint8), 1, 1) + return -1, TobiiVideoFrame(numpy.zeros((1, 1, 3), numpy.uint8)) # lock frame access self.__read_lock.acquire() @@ -211,7 +215,7 @@ class TobiiVideoStream(threading.Thread): # unlock frame access self.__read_lock.release() - return int(frame_tuple[0] * 1e6), TobiiVideoFrame(frame_tuple[1], frame_tuple[2], frame_tuple[3]) + return int(frame_tuple[0] * 1e6), TobiiVideoFrame(frame_tuple[1]) class TobiiVideoOutput(): """Export a video file at the same format than a given referent stream.""" |