Source code for pupil_labs.realtime_api.simple.models
import datetime
import typing as T
from ..streaming.gaze import GazeData
from ..streaming.video import BGRBuffer, VideoFrame
[docs]class SimpleVideoFrame(T.NamedTuple):
bgr_pixels: BGRBuffer
timestamp_unix_seconds: float
[docs] @classmethod
def from_video_frame(cls, vf: VideoFrame) -> "SimpleVideoFrame":
return cls(vf.bgr_buffer(), vf.timestamp_unix_seconds)
@property
def datetime(self):
return datetime.datetime.fromtimestamp(self.timestamp_unix_seconds)
@property
def timestamp_unix_ns(self):
return int(self.timestamp_unix_seconds * 1e9)
# The following name can be considered technical debt from the time when there were only
# two streams (scene video and gaze) to match. When I added support for streaming eyes
# video, I thought about giving it a more descriptive name. But since this is an output
# class of the public API, I decided against it to avoid breaking possible imports.
[docs]class MatchedGazeEyesSceneItem(T.NamedTuple):
scene: SimpleVideoFrame
eyes: SimpleVideoFrame
gaze: GazeData
MATCHED_ITEM_LABEL = "matched_gaze_and_scene_video"
MATCHED_GAZE_EYES_LABEL = "matched_gaze_eyes_and_scene_video"