Asynchronous API¶
Device Discovery¶
discovery
¶
Classes:
-
Network
–Network discovery client for finding devices.
Functions:
-
discover_devices
–Use Bonjour to find devices in the local network that serve the Realtime API.
-
is_valid_service_name
–Check if the service name is valid for Realtime API
Network
¶
Network()
Network discovery client for finding devices.
This class manages device discovery on the local network using Zeroconf/Bonjour. It maintains a list of discovered devices and provides methods to access them.
Attributes:
-
_devices
(dict | None
) –A dictionary of discovered devices, where the keys are device names and the values are DiscoveredDeviceInfo objects.
-
_new_devices
(Queue
) –A queue to hold newly discovered devices.
-
_aiozeroconf
(AsyncZeroconf | None
) –An instance of AsyncZeroconf for network discovery.
-
_aiobrowser
(AsyncServiceBrowser | None
) –An instance of AsyncServiceBrowser for browsing services on the network.
-
_open
(bool
) –A flag indicating whether the network discovery client is open.
Methods:
-
close
–Close all network resources.
-
wait_for_new_device
–Wait for a new device to be discovered.
Source code in src/pupil_labs/realtime_api/discovery.py
33 34 35 36 37 38 39 40 41 42 |
|
close
async
¶
close() -> None
Close all network resources.
This method stops the Zeroconf browser, closes connections, and clears the device list.
Source code in src/pupil_labs/realtime_api/discovery.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
wait_for_new_device
async
¶
wait_for_new_device(timeout_seconds: float | None = None) -> DiscoveredDeviceInfo | None
Wait for a new device to be discovered.
Parameters:
-
timeout_seconds
(float | None
, default:None
) –Maximum time to wait for a new device. If None, wait indefinitely.
Returns:
-
DiscoveredDeviceInfo | None
–Optional[DiscoveredDeviceInfo]: The newly discovered device, or None if the timeout was reached.
Source code in src/pupil_labs/realtime_api/discovery.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
discover_devices
async
¶
discover_devices(timeout_seconds: float | None = None) -> AsyncIterator[DiscoveredDeviceInfo]
Use Bonjour to find devices in the local network that serve the Realtime API.
This function creates a temporary network discovery client and yields discovered devices as they are found.
Parameters:
-
timeout_seconds
(float | None
, default:None
) –Stop after
timeout_seconds
. IfNone
, run discovery forever.
Yields:
-
DiscoveredDeviceInfo
(AsyncIterator[DiscoveredDeviceInfo]
) –Information about discovered devices.
Example
async for device in discover_devices(timeout_seconds=10.0):
print(f"Found device: {device.name} at {device.addresses[0]}:{device.port}")
Source code in src/pupil_labs/realtime_api/discovery.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
is_valid_service_name
¶
Check if the service name is valid for Realtime API
Source code in src/pupil_labs/realtime_api/discovery.py
210 211 212 |
|
Remote Control¶
device
¶
Classes:
-
Device
–Class representing a Pupil Labs device.
-
DeviceError
–Exception raised when a device operation fails.
-
StatusUpdateNotifier
–Helper class for handling device status update callbacks.
Attributes:
-
UpdateCallback
–Type annotation for synchronous and asynchronous callbacks
-
UpdateCallbackAsync
–Type annotation for asynchronous update callbacks
-
UpdateCallbackSync
–Type annotation for synchronous update callbacks
UpdateCallback
module-attribute
¶
UpdateCallback = UpdateCallbackSync | UpdateCallbackAsync
Type annotation for synchronous and asynchronous callbacks
UpdateCallbackAsync
module-attribute
¶
Type annotation for asynchronous update callbacks
See Also
:class:~pupil_labs.realtime_api.models.Component
UpdateCallbackSync
module-attribute
¶
Type annotation for synchronous update callbacks
See Also
:class:~pupil_labs.realtime_api.models.Component
Device
¶
Bases: DeviceBase
Class representing a Pupil Labs device.
This class provides methods to interact with the device, such as starting and stopping recordings, sending events, and fetching device status. It also provides a context manager for automatically closing the device session.
Methods:
-
api_url
–Construct a full API URL for the given path.
-
close
–Close the connection to the device.
-
convert_from
–Convert another device instance to this type.
-
from_discovered_device
–Create a device instance from discovery information.
-
get_calibration
–Get the current cameras calibration data.
-
get_status
–Get the current status of the device.
-
get_template
–Get the template currently selected on device.
-
get_template_data
–Get the template data entered on device.
-
post_template_data
–Set the data for the currently selected template.
-
recording_cancel
–Cancel the current recording without saving it.
-
recording_start
–Start a recording on the device.
-
recording_stop_and_save
–Stop and save the current recording.
-
send_event
–Send an event to the device.
-
status_updates
–Stream status updates from the device.
Attributes:
-
active_session
(ClientSession
) –Returns the active session, raising an error if it's None.
-
session
(ClientSession | None
) –The HTTP session used for making requests.
-
template_definition
(Template | None
) –The template definition currently selected on the device.
Source code in src/pupil_labs/realtime_api/device.py
74 75 76 77 |
|
active_session
property
¶
active_session: ClientSession
Returns the active session, raising an error if it's None.
session
instance-attribute
¶
session: ClientSession | None
The HTTP session used for making requests.
template_definition
class-attribute
instance-attribute
¶
template_definition: Template | None = None
The template definition currently selected on the device.
api_url
¶
Construct a full API URL for the given path.
Parameters:
-
path
(APIPath
) –API path to access.
-
protocol
(str
, default:'http'
) –Protocol to use (http).
-
prefix
(str
, default:'/api'
) –API URL prefix.
Returns:
-
str
–Complete URL for the API endpoint.
Source code in src/pupil_labs/realtime_api/base.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
close
async
¶
close() -> None
Close the connection to the device.
Source code in src/pupil_labs/realtime_api/device.py
336 337 338 339 |
|
convert_from
classmethod
¶
convert_from(other: T) -> DeviceType
Convert another device instance to this type.
Parameters:
-
other
(T
) –Device instance to convert.
Returns:
-
DeviceType
–Converted device instance.
Source code in src/pupil_labs/realtime_api/base.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
from_discovered_device
classmethod
¶
from_discovered_device(device: DiscoveredDeviceInfo) -> DeviceType
Create a device instance from discovery information.
Parameters:
-
device
(DiscoveredDeviceInfo
) –Discovered device information.
Returns:
-
DeviceType
–Device instance
Source code in src/pupil_labs/realtime_api/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
get_calibration
async
¶
get_calibration() -> Calibration
Get the current cameras calibration data.
Note that Pupil Invisible and Neon are calibration free systems, this refers to the intrinsincs and extrinsics of the cameras and is only available for Neon.
Returns:
-
Calibration
–pupil_labs.neon_recording.calib.Calibration: The calibration data.
Raises:
-
DeviceError
–If the request fails.
Source code in src/pupil_labs/realtime_api/device.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
get_status
async
¶
get_status() -> Status
Get the current status of the device.
Returns:
-
Status
(Status
) –The current device status.
Raises:
-
DeviceError
–If the request fails.
Source code in src/pupil_labs/realtime_api/device.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
get_template
async
¶
get_template() -> Template
Get the template currently selected on device.
Returns:
-
Template
(Template
) –The currently selected template.
Raises:
-
DeviceError
–If the template can't be fetched.
Source code in src/pupil_labs/realtime_api/device.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
get_template_data
async
¶
get_template_data(template_format: TemplateDataFormat = 'simple') -> Any
Get the template data entered on device.
Parameters:
-
template_format
(TemplateDataFormat
, default:'simple'
) –Format of the returned data. - "api" returns the data as is from the api e.g., {"item_uuid": ["42"]} - "simple" returns the data parsed e.g., {"item_uuid": 42}
Returns:
-
Any
–The template data in the requested format.
Raises:
-
DeviceError
–If the template's data could not be fetched.
-
AssertionError
–If an invalid format is provided.
Source code in src/pupil_labs/realtime_api/device.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
post_template_data
async
¶
post_template_data(template_answers: dict[str, list[str]], template_format: TemplateDataFormat = 'simple') -> Any
Set the data for the currently selected template.
Parameters:
-
template_answers
(dict[str, list[str]]
) –The template data to send.
-
template_format
(TemplateDataFormat
, default:'simple'
) –Format of the input data. - "api" accepts the data as in realtime api format e.g., {"item_uuid": ["42"]} - "simple" accepts the data in parsed format e.g., {"item_uuid": 42}
Returns:
-
Any
–The result of the operation.
Raises:
-
DeviceError
–If the data can not be sent.
-
ValueError
–If invalid data type.
-
AssertionError
–If an invalid format is provided.
Source code in src/pupil_labs/realtime_api/device.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
recording_cancel
async
¶
recording_cancel() -> None
Cancel the current recording without saving it.
Raises:
-
DeviceError
–If the recording could not be cancelled. Possible reasons include: - Recording not running
Source code in src/pupil_labs/realtime_api/device.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
recording_start
async
¶
recording_start() -> str
Start a recording on the device.
Returns:
-
str
(str
) –ID of the started recording.
Raises:
-
DeviceError
–If recording could not be started. Possible reasons include: - Recording already running - Template has required fields - Low battery - Low storage - No wearer selected - No workspace selected - Setup bottom sheets not completed
Source code in src/pupil_labs/realtime_api/device.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
recording_stop_and_save
async
¶
recording_stop_and_save() -> None
Stop and save the current recording.
Raises:
-
DeviceError
–If recording could not be stopped. Possible reasons include: - Recording not running - Template has required fields
Source code in src/pupil_labs/realtime_api/device.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
send_event
async
¶
Send an event to the device.
Parameters:
-
event_name
(str
) –Name of the event.
-
event_timestamp_unix_ns
(int | None
, default:None
) –Optional timestamp in unix nanoseconds. If None, the current time will be used.
Returns:
-
Event
(Event
) –The created event.
Raises:
-
DeviceError
–If sending the event fails.
Source code in src/pupil_labs/realtime_api/device.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
status_updates
async
¶
status_updates() -> AsyncIterator[Component]
Stream status updates from the device.
Yields:
-
Component
(AsyncIterator[Component]
) –Status update components as they arrive.
Auto-reconnect, see: https://websockets.readthedocs.io/en/stable/reference/asyncio/client.html#websockets.asyncio.client.connect
Source code in src/pupil_labs/realtime_api/device.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
StatusUpdateNotifier
¶
StatusUpdateNotifier(device: Device, callbacks: list[UpdateCallback])
Helper class for handling device status update callbacks.
This class manages the streaming of status updates from a device and dispatches them to registered callbacks.
Attributes:
-
_auto_update_task
(Task | None
) –Task for the update loop.
-
_device
(Device
) –The device to get updates from.
-
_callbacks
(list[UpdateCallback]
) –List of callbacks to invoke.
Methods:
-
receive_updates_start
–Start receiving status updates.
-
receive_updates_stop
–Stop receiving status updates.
Source code in src/pupil_labs/realtime_api/device.py
408 409 410 411 |
|
receive_updates_start
async
¶
receive_updates_start() -> None
Start receiving status updates.
This method starts the background task that receives updates and dispatches them to registered callbacks.
Source code in src/pupil_labs/realtime_api/device.py
413 414 415 416 417 418 419 420 421 422 |
|
receive_updates_stop
async
¶
receive_updates_stop() -> None
Stop receiving status updates.
This method cancels the background task that receives updates.
Source code in src/pupil_labs/realtime_api/device.py
424 425 426 427 428 429 430 431 432 433 434 435 436 |
|
Streaming¶
Gaze Data¶
gaze
¶
Classes:
-
DualMonocularGazeData
–Experimental class for dual monocular gaze data.
-
EyestateEyelidGazeData
–Gaze data with additional eyelid state information.
-
EyestateGazeData
–Gaze data with additional eye state information.
-
GazeData
–Basic gaze data with position, timestamp and indicator of glasses worn status.
-
Point
–A point in 2D space, represented by x and y coordinates.
-
RTSPGazeStreamer
–Stream and parse gaze data from an RTSP source.
Functions:
-
receive_gaze_data
–Receive gaze data from an RTSP stream.
Attributes:
-
GazeDataType
–Type alias for various gaze data types.
GazeDataType
module-attribute
¶
GazeDataType = GazeData | DualMonocularGazeData | EyestateGazeData | EyestateEyelidGazeData
Type alias for various gaze data types.
DualMonocularGazeData
¶
Bases: NamedTuple
Experimental class for dual monocular gaze data.
Contains separate gaze points for left and right eyes.
Methods:
-
from_raw
–Create a DualMonocularGazeData instance from raw data.
Attributes:
-
datetime
(datetime
) –Get the timestamp as a datetime object.
-
left
(Point
) –Gaze point for the left eye.
-
right
(Point
) –Gaze point for the right eye.
-
timestamp_unix_ns
(int
) –Get the timestamp in nanoseconds since Unix epoch.
-
timestamp_unix_seconds
(float
) –Timestamp in seconds since Unix epoch.
-
worn
(bool
) –Whether the glasses are being worn.
timestamp_unix_ns
property
¶
timestamp_unix_ns: int
Get the timestamp in nanoseconds since Unix epoch.
timestamp_unix_seconds
instance-attribute
¶
timestamp_unix_seconds: float
Timestamp in seconds since Unix epoch.
from_raw
classmethod
¶
from_raw(data: RTSPData) -> DualMonocularGazeData
Create a DualMonocularGazeData instance from raw data.
Parameters:
-
data
(RTSPData
) –The raw data received from the RTSP stream.
Returns:
-
DualMonocularGazeData
(DualMonocularGazeData
) –An instance of DualMonocularGazeData with the parsed values.
Source code in src/pupil_labs/realtime_api/streaming/gaze.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
EyestateEyelidGazeData
¶
Bases: NamedTuple
Gaze data with additional eyelid state information.
Contains gaze point, pupil diameter, eyeball center coordinates, optical axis coordinates, as well as eyelid angles and aperture for both left and right eyes.
Methods:
-
from_raw
–Create an EyestateEyelidGazeData instance from raw data.
Attributes:
-
datetime
(datetime
) –Get the timestamp as a datetime object.
-
eyeball_center_left_x
(float
) –X coordinate of the eyeball center for the left eye.
-
eyeball_center_left_y
(float
) –Y coordinate of the eyeball center for the left eye.
-
eyeball_center_left_z
(float
) –Z coordinate of the eyeball center for the left eye.
-
eyeball_center_right_x
(float
) –X coordinate of the eyeball center for the right eye.
-
eyeball_center_right_y
(float
) –Y coordinate of the eyeball center for the right eye.
-
eyeball_center_right_z
(float
) –Z coordinate of the eyeball center for the right eye.
-
eyelid_angle_bottom_left
(float
) –Angle of the bottom eyelid for the left eye(rad).
-
eyelid_angle_bottom_right
(float
) –Angle of the bottom eyelid for the right eye (rad).
-
eyelid_angle_top_left
(float
) –Angle of the top eyelid for the left eye(rad).
-
eyelid_angle_top_right
(float
) –Angle of the top eyelid for the right eye (rad).
-
eyelid_aperture_left
(float
) –Aperture of the eyelid for the left eye (mm).
-
eyelid_aperture_right
(float
) –Aperture of the eyelid for the right eye (mm).
-
optical_axis_left_x
(float
) –X coordinate of the optical axis for the left eye.
-
optical_axis_left_y
(float
) –Y coordinate of the optical axis for the left eye.
-
optical_axis_left_z
(float
) –Z coordinate of the optical axis for the left eye.
-
optical_axis_right_x
(float
) –X coordinate of the optical axis for the right eye.
-
optical_axis_right_y
(float
) –Y coordinate of the optical axis for the right eye.
-
optical_axis_right_z
(float
) –Z coordinate of the optical axis for the right eye.
-
pupil_diameter_left
(float
) –Pupil diameter for the left eye.
-
pupil_diameter_right
(float
) –Pupil diameter for the right eye.
-
timestamp_unix_ns
(int
) –Get the timestamp in nanoseconds since Unix epoch.
-
timestamp_unix_seconds
(float
) –Timestamp in seconds since Unix epoch.
-
worn
(bool
) –Whether the glasses are being worn.
-
x
(float
) –X coordinate of the gaze point.
-
y
(float
) –Y coordinate of the gaze point.
eyeball_center_left_x
instance-attribute
¶
eyeball_center_left_x: float
X coordinate of the eyeball center for the left eye.
eyeball_center_left_y
instance-attribute
¶
eyeball_center_left_y: float
Y coordinate of the eyeball center for the left eye.
eyeball_center_left_z
instance-attribute
¶
eyeball_center_left_z: float
Z coordinate of the eyeball center for the left eye.
eyeball_center_right_x
instance-attribute
¶
eyeball_center_right_x: float
X coordinate of the eyeball center for the right eye.
eyeball_center_right_y
instance-attribute
¶
eyeball_center_right_y: float
Y coordinate of the eyeball center for the right eye.
eyeball_center_right_z
instance-attribute
¶
eyeball_center_right_z: float
Z coordinate of the eyeball center for the right eye.
eyelid_angle_bottom_left
instance-attribute
¶
eyelid_angle_bottom_left: float
Angle of the bottom eyelid for the left eye(rad).
eyelid_angle_bottom_right
instance-attribute
¶
eyelid_angle_bottom_right: float
Angle of the bottom eyelid for the right eye (rad).
eyelid_angle_top_left
instance-attribute
¶
eyelid_angle_top_left: float
Angle of the top eyelid for the left eye(rad).
eyelid_angle_top_right
instance-attribute
¶
eyelid_angle_top_right: float
Angle of the top eyelid for the right eye (rad).
eyelid_aperture_left
instance-attribute
¶
eyelid_aperture_left: float
Aperture of the eyelid for the left eye (mm).
eyelid_aperture_right
instance-attribute
¶
eyelid_aperture_right: float
Aperture of the eyelid for the right eye (mm).
optical_axis_left_x
instance-attribute
¶
optical_axis_left_x: float
X coordinate of the optical axis for the left eye.
optical_axis_left_y
instance-attribute
¶
optical_axis_left_y: float
Y coordinate of the optical axis for the left eye.
optical_axis_left_z
instance-attribute
¶
optical_axis_left_z: float
Z coordinate of the optical axis for the left eye.
optical_axis_right_x
instance-attribute
¶
optical_axis_right_x: float
X coordinate of the optical axis for the right eye.
optical_axis_right_y
instance-attribute
¶
optical_axis_right_y: float
Y coordinate of the optical axis for the right eye.
optical_axis_right_z
instance-attribute
¶
optical_axis_right_z: float
Z coordinate of the optical axis for the right eye.
pupil_diameter_left
instance-attribute
¶
pupil_diameter_left: float
Pupil diameter for the left eye.
pupil_diameter_right
instance-attribute
¶
pupil_diameter_right: float
Pupil diameter for the right eye.
timestamp_unix_ns
property
¶
timestamp_unix_ns: int
Get the timestamp in nanoseconds since Unix epoch.
timestamp_unix_seconds
instance-attribute
¶
timestamp_unix_seconds: float
Timestamp in seconds since Unix epoch.
from_raw
classmethod
¶
from_raw(data: RTSPData) -> EyestateEyelidGazeData
Create an EyestateEyelidGazeData instance from raw data.
Parameters:
-
data
(RTSPData
) –The raw data received from the RTSP stream.
Returns:
-
EyestateEyelidGazeData
(EyestateEyelidGazeData
) –An instance of EyestateEyelidGazeData with the parsed values.
Source code in src/pupil_labs/realtime_api/streaming/gaze.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
|
EyestateGazeData
¶
Bases: NamedTuple
Gaze data with additional eye state information.
Contains gaze point, pupil diameter, eyeball center coordinates, and optical axis coordinates for both left and right eyes.
Methods:
-
from_raw
–Create an EyestateGazeData instance from raw data.
Attributes:
-
datetime
(datetime
) –Get the timestamp as a datetime object.
-
eyeball_center_left_x
(float
) –X coordinate of the eyeball center for the left eye.
-
eyeball_center_left_y
(float
) –Y coordinate of the eyeball center for the left eye.
-
eyeball_center_left_z
(float
) –Z coordinate of the eyeball center for the left eye.
-
eyeball_center_right_x
(float
) –X coordinate of the eyeball center for the right eye.
-
eyeball_center_right_y
(float
) –Y coordinate of the eyeball center for the right eye.
-
eyeball_center_right_z
(float
) –Z coordinate of the eyeball center for the right eye.
-
optical_axis_left_x
(float
) –X coordinate of the optical axis for the left eye.
-
optical_axis_left_y
(float
) –Y coordinate of the optical axis for the left eye.
-
optical_axis_left_z
(float
) –Z coordinate of the optical axis for the left eye.
-
optical_axis_right_x
(float
) –X coordinate of the optical axis for the right eye.
-
optical_axis_right_y
(float
) –Y coordinate of the optical axis for the right eye.
-
optical_axis_right_z
(float
) –Z coordinate of the optical axis for the right eye.
-
pupil_diameter_left
(float
) –Pupil diameter for the left eye.
-
pupil_diameter_right
(float
) –Pupil diameter for the right eye.
-
timestamp_unix_ns
(int
) –Get the timestamp in nanoseconds since Unix epoch.
-
timestamp_unix_seconds
(float
) –Timestamp in seconds since Unix epoch.
-
worn
(bool
) –Whether the glasses are being worn.
-
x
(float
) –X coordinate of the gaze point.
-
y
(float
) –Y coordinate of the gaze point.
eyeball_center_left_x
instance-attribute
¶
eyeball_center_left_x: float
X coordinate of the eyeball center for the left eye.
eyeball_center_left_y
instance-attribute
¶
eyeball_center_left_y: float
Y coordinate of the eyeball center for the left eye.
eyeball_center_left_z
instance-attribute
¶
eyeball_center_left_z: float
Z coordinate of the eyeball center for the left eye.
eyeball_center_right_x
instance-attribute
¶
eyeball_center_right_x: float
X coordinate of the eyeball center for the right eye.
eyeball_center_right_y
instance-attribute
¶
eyeball_center_right_y: float
Y coordinate of the eyeball center for the right eye.
eyeball_center_right_z
instance-attribute
¶
eyeball_center_right_z: float
Z coordinate of the eyeball center for the right eye.
optical_axis_left_x
instance-attribute
¶
optical_axis_left_x: float
X coordinate of the optical axis for the left eye.
optical_axis_left_y
instance-attribute
¶
optical_axis_left_y: float
Y coordinate of the optical axis for the left eye.
optical_axis_left_z
instance-attribute
¶
optical_axis_left_z: float
Z coordinate of the optical axis for the left eye.
optical_axis_right_x
instance-attribute
¶
optical_axis_right_x: float
X coordinate of the optical axis for the right eye.
optical_axis_right_y
instance-attribute
¶
optical_axis_right_y: float
Y coordinate of the optical axis for the right eye.
optical_axis_right_z
instance-attribute
¶
optical_axis_right_z: float
Z coordinate of the optical axis for the right eye.
pupil_diameter_left
instance-attribute
¶
pupil_diameter_left: float
Pupil diameter for the left eye.
pupil_diameter_right
instance-attribute
¶
pupil_diameter_right: float
Pupil diameter for the right eye.
timestamp_unix_ns
property
¶
timestamp_unix_ns: int
Get the timestamp in nanoseconds since Unix epoch.
timestamp_unix_seconds
instance-attribute
¶
timestamp_unix_seconds: float
Timestamp in seconds since Unix epoch.
from_raw
classmethod
¶
from_raw(data: RTSPData) -> EyestateGazeData
Create an EyestateGazeData instance from raw data.
Parameters:
-
data
(RTSPData
) –The raw data received from the RTSP stream.
Returns:
-
EyestateGazeData
(EyestateGazeData
) –An instance of EyestateGazeData with the parsed values.
Source code in src/pupil_labs/realtime_api/streaming/gaze.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
GazeData
¶
Bases: NamedTuple
Basic gaze data with position, timestamp and indicator of glasses worn status.
Represents the 2D gaze point on the scene camera coordinates with a timestamp in nanoseconds unix epoch and an indicator of whether the glasses are being worn.
Methods:
-
from_raw
–Create a GazeData instance from raw data.
Attributes:
-
datetime
(datetime
) –Get the timestamp as a datetime object.
-
timestamp_unix_ns
(int
) –Get the timestamp in nanoseconds since Unix epoch.
-
timestamp_unix_seconds
(float
) –Timestamp in seconds since Unix epoch.
-
worn
(bool
) –Whether the glasses are being worn.
-
x
(float
) –"X coordinate of the gaze point
-
y
(float
) –Y coordinate of the gaze point.
timestamp_unix_ns
property
¶
timestamp_unix_ns: int
Get the timestamp in nanoseconds since Unix epoch.
timestamp_unix_seconds
instance-attribute
¶
timestamp_unix_seconds: float
Timestamp in seconds since Unix epoch.
from_raw
classmethod
¶
Create a GazeData instance from raw data.
Parameters:
-
data
(RTSPData
) –The raw data received from the RTSP stream.
Returns:
-
GazeData
(GazeData
) –An instance of GazeData with the parsed values.
Source code in src/pupil_labs/realtime_api/streaming/gaze.py
35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
Point
¶
RTSPGazeStreamer
¶
Bases: RTSPRawStreamer
Stream and parse gaze data from an RTSP source.
This class extends RTSPRawStreamer to parse raw RTSP data into structured gaze data objects. The specific type of gaze data is determined by the length of the raw data packet.
Methods:
-
receive
–Receive and parse gaze data from the RTSP stream.
Attributes:
-
encoding
(str
) –Get the encoding of the RTSP stream.
-
reader
(_WallclockRTSPReader
) –Get the underlying RTSP reader.
Source code in src/pupil_labs/realtime_api/streaming/base.py
78 79 80 |
|
encoding
property
¶
encoding: str
Get the encoding of the RTSP stream.
Returns:
-
str
(str
) –The encoding name in lowercase.
Raises:
-
SDPDataNotAvailableError
–If SDP data is missing or incomplete.
receive
async
¶
receive() -> AsyncIterator[GazeDataType]
Receive and parse gaze data from the RTSP stream.
Yields:
-
AsyncIterator[GazeDataType]
–GazeDataType
-
AsyncIterator[GazeDataType]
–Parsed gaze data of various types. The type of gaze data object is
-
AsyncIterator[GazeDataType]
–determined by the length of the raw data packet:
- 9 bytes: GazeData (basic gaze position)
- 17 bytes: DualMonocularGazeData (left and right eye positions)
- 65 bytes: EyestateGazeData (gaze with eye state)
- 89 bytes: EyestateEyelidGazeData (gaze with eye state and eyelid info)
Raises:
-
KeyError
–If the data length does not match any known format.
-
Exception
–If there is an error parsing the gaze data.
Source code in src/pupil_labs/realtime_api/streaming/gaze.py
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
|
receive_gaze_data
async
¶
receive_gaze_data(url: str, *args: Any, **kwargs: Any) -> AsyncIterator[GazeDataType]
Receive gaze data from an RTSP stream.
This is a convenience function that creates an RTSPGazeStreamer and yields parsed gaze data.
Parameters:
-
url
(str
) –RTSP URL to connect to.
-
*args
(Any
, default:()
) –Additional positional arguments passed to RTSPGazeStreamer.
-
**kwargs
(Any
, default:{}
) –Additional keyword arguments passed to RTSPGazeStreamer.
Yields:
-
GazeDataType
(AsyncIterator[GazeDataType]
) –Parsed gaze data of various types.
-
AsyncIterator[GazeDataType]
–The type of gaze data object is determined by the length of the raw data packet:
-
AsyncIterator[GazeDataType]
–- 9 bytes: GazeData (basic gaze position)
-
AsyncIterator[GazeDataType]
–- 17 bytes: DualMonocularGazeData (left and right eye positions)
-
AsyncIterator[GazeDataType]
–- 65 bytes: EyestateGazeData (gaze with eye state)
-
AsyncIterator[GazeDataType]
–- 89 bytes: EyestateEyelidGazeData (gaze with eye state and eyelid info)
Source code in src/pupil_labs/realtime_api/streaming/gaze.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
|
IMU Data¶
imu
¶
Classes:
-
Data3D
–3D data point with x, y, z coordinates.
-
IMUData
–Data from the Inertial Measurement Unit (IMU).
-
Quaternion
–Quaternion data point with x, y, z, w coordinates.
-
RTSPImuStreamer
–Stream and parse IMU data from an RTSP source.
Functions:
-
IMUPacket_to_IMUData
–Create an IMUData instance from a protobuf IMU packet.
-
receive_imu_data
–Receive IMU data from a given RTSP URL.
Data3D
¶
IMUData
¶
Bases: NamedTuple
Data from the Inertial Measurement Unit (IMU).
Contains gyroscope, accelerometer, and rotation data from the IMU sensor.
Attributes:
-
accel_data
(Data3D
) –Accelerometer data in m/s².
-
datetime
(datetime
) –Get timestamp as a datetime object.
-
gyro_data
(Data3D
) –Gyroscope data in deg/s.
-
quaternion
(Quaternion
) –Rotation represented as a quaternion.
-
timestamp_unix_nanoseconds
(int
) –Get timestamp in nanoseconds since Unix epoch.
-
timestamp_unix_ns
(int
) –Get timestamp in nanoseconds since Unix epoch.
-
timestamp_unix_seconds
(float
) –Timestamp in seconds since Unix epoch.
Quaternion
¶
RTSPImuStreamer
¶
Bases: RTSPRawStreamer
Stream and parse IMU data from an RTSP source.
This class extends RTSPRawStreamer to parse raw RTSP data into structured IMU data objects.
Methods:
-
receive
–Receive and parse IMU data from the RTSP stream.
Attributes:
-
encoding
(str
) –Get the encoding of the RTSP stream.
-
reader
(_WallclockRTSPReader
) –Get the underlying RTSP reader.
Source code in src/pupil_labs/realtime_api/streaming/base.py
78 79 80 |
|
encoding
property
¶
encoding: str
Get the encoding of the RTSP stream.
Returns:
-
str
(str
) –The encoding name in lowercase.
Raises:
-
SDPDataNotAvailableError
–If SDP data is missing or incomplete.
receive
async
¶
receive() -> AsyncIterator[IMUData]
Receive and parse IMU data from the RTSP stream.
This method parses the raw binary data into IMUData objects by using the protobuf deserializer.
Yields:
-
IMUData
(AsyncIterator[IMUData]
) –Parsed IMU data.
Raises:
-
Exception
–If there is an error parsing the IMU data.
Source code in src/pupil_labs/realtime_api/streaming/imu.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
IMUPacket_to_IMUData
¶
IMUPacket_to_IMUData(imu_packet: ImuPacket) -> IMUData
Create an IMUData instance from a protobuf IMU packet.
Parameters:
-
imu_packet
(ImuPacket
) –Protobuf IMU packet.
Returns:
-
IMUData
(IMUData
) –Converted IMU data.
Source code in src/pupil_labs/realtime_api/streaming/imu.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
receive_imu_data
async
¶
receive_imu_data(url: str, *args: Any, **kwargs: Any) -> AsyncIterator[IMUData]
Receive IMU data from a given RTSP URL.
Parameters:
-
url
(str
) –RTSP URL to connect to.
-
*args
(Any
, default:()
) –Additional arguments for the streamer.
-
**kwargs
(Any
, default:{}
) –Additional keyword arguments for the streamer.
Yields:
-
IMUData
(AsyncIterator[IMUData]
) –Parsed IMU data from the RTSP stream.
Source code in src/pupil_labs/realtime_api/streaming/imu.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
Eye Events¶
eye_events
¶
Classes:
-
BlinkEventData
–Data for a blink event.
-
FixationEventData
–Data for a fixation or saccade event.
-
FixationOnsetEventData
–Data for a fixation or saccade onset event.
-
RTSPEyeEventStreamer
–Stream and parse eye events from an RTSP source.
Functions:
-
receive_eye_events_data
–Receive eye events data from an RTSP stream.
BlinkEventData
¶
Bases: NamedTuple
Data for a blink event.
Represents a detected blink event with timing information.
Methods:
-
from_raw
–Create a BlinkEventData instance from raw RTSP data.
Attributes:
-
datetime
(datetime
) –Get the timestamp as a datetime object.
-
end_time_ns
(int
) –End time of the blink in nanoseconds.
-
event_type
(int
) –Type of event (4 -> blink events).
-
rtp_ts_unix_seconds
(float
) –RTP timestamp in seconds since Unix epoch.
-
start_time_ns
(int
) –Start time of the blink in nanoseconds.
-
timestamp_unix_ns
(int
) –Get the timestamp in nanoseconds since the Unix epoch.
rtp_ts_unix_seconds
instance-attribute
¶
rtp_ts_unix_seconds: float
RTP timestamp in seconds since Unix epoch.
timestamp_unix_ns
property
¶
timestamp_unix_ns: int
Get the timestamp in nanoseconds since the Unix epoch.
from_raw
classmethod
¶
from_raw(data: RTSPData) -> BlinkEventData
Create a BlinkEventData instance from raw RTSP data.
Source code in src/pupil_labs/realtime_api/streaming/eye_events.py
27 28 29 30 31 32 33 34 35 |
|
FixationEventData
¶
Bases: NamedTuple
Data for a fixation or saccade event.
Represents a completed fixation or saccade event with detailed information.
Methods:
-
from_raw
–Create a FixationEventData instance from raw RTSP data.
Attributes:
-
amplitude_angle_deg
(float
) –Amplitude in degrees.
-
amplitude_pixels
(float
) –Amplitude in pixels.
-
datetime
(datetime
) –Get the timestamp as a datetime object.
-
end_gaze_x
(float
) –End gaze x-coordinate in pixels.
-
end_gaze_y
(float
) –End gaze y-coordinate in pixels.
-
end_time_ns
(int
) –End time of the event in nanoseconds.
-
event_type
(int
) –Type of event (0 for saccade, 1 for fixation).
-
max_velocity
(float
) –Maximum velocity in pixels per degree.
-
mean_gaze_x
(float
) –Mean gaze x-coordinate in pixels.
-
mean_gaze_y
(float
) –Mean gaze y-coordinate in pixels.
-
mean_velocity
(float
) –Mean velocity in pixels per degree.
-
rtp_ts_unix_seconds
(float
) –RTP timestamp in seconds since Unix epoch.
-
start_gaze_x
(float
) –Start gaze x-coordinate in pixels.
-
start_gaze_y
(float
) –Start gaze y-coordinate in pixels.
-
start_time_ns
(int
) –Start time of the event in nanoseconds.
-
timestamp_unix_ns
(int
) –Get the timestamp in nanoseconds since the Unix epoch.
rtp_ts_unix_seconds
instance-attribute
¶
rtp_ts_unix_seconds: float
RTP timestamp in seconds since Unix epoch.
timestamp_unix_ns
property
¶
timestamp_unix_ns: int
Get the timestamp in nanoseconds since the Unix epoch.
from_raw
classmethod
¶
from_raw(data: RTSPData) -> FixationEventData
Create a FixationEventData instance from raw RTSP data.
Source code in src/pupil_labs/realtime_api/streaming/eye_events.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
FixationOnsetEventData
¶
Bases: NamedTuple
Data for a fixation or saccade onset event.
Represents the beginning of a fixation or saccade event.
Attributes:
-
datetime
(datetime
) –Get the timestamp as a datetime object.
-
event_type
(int
) –Type of event (2 for saccade onset, 3 for fixation onset).
-
rtp_ts_unix_seconds
(float
) –RTP timestamp in seconds since Unix epoch.
-
start_time_ns
(int
) –Start time of the event in nanoseconds.
-
timestamp_unix_ns
(int
) –Get the timestamp in nanoseconds since the Unix epoch.
RTSPEyeEventStreamer
¶
Bases: RTSPRawStreamer
Stream and parse eye events from an RTSP source.
This class extends RTSPRawStreamer to parse raw RTSP data into structured eye event data objects.
Methods:
-
receive
–Receive and parse eye events from the RTSP stream.
Attributes:
-
encoding
(str
) –Get the encoding of the RTSP stream.
-
reader
(_WallclockRTSPReader
) –Get the underlying RTSP reader.
Source code in src/pupil_labs/realtime_api/streaming/base.py
78 79 80 |
|
encoding
property
¶
encoding: str
Get the encoding of the RTSP stream.
Returns:
-
str
(str
) –The encoding name in lowercase.
Raises:
-
SDPDataNotAvailableError
–If SDP data is missing or incomplete.
receive
async
¶
receive() -> AsyncIterator[FixationEventData | FixationOnsetEventData | BlinkEventData]
Receive and parse eye events from the RTSP stream.
Yields:
-
AsyncIterator[FixationEventData | FixationOnsetEventData | BlinkEventData]
–FixationEventData | FixationOnsetEventData | BlinkEventData: Parsed eye event data.
Raises:
-
KeyError
–If the event type is not recognized.
-
Exception
–If there is an error parsing the event data.
Source code in src/pupil_labs/realtime_api/streaming/eye_events.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
receive_eye_events_data
async
¶
receive_eye_events_data(url: str, *args: Any, **kwargs: Any) -> AsyncIterator[FixationEventData | FixationOnsetEventData | BlinkEventData]
Receive eye events data from an RTSP stream.
This is a convenience function that creates an RTSPEyeEventStreamer and yields parsed eye event data.
Parameters:
-
url
(str
) –RTSP URL to connect to.
-
*args
(Any
, default:()
) –Additional positional arguments passed to RTSPEyeEventStreamer.
-
**kwargs
(Any
, default:{}
) –Additional keyword arguments passed to RTSPEyeEventStreamer.
Yields:
-
FixationEventData
(AsyncIterator[FixationEventData | FixationOnsetEventData | BlinkEventData]
) –Parsed fixation event data.
Source code in src/pupil_labs/realtime_api/streaming/eye_events.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
Scene Video¶
video
¶
Classes:
-
RTSPVideoFrameStreamer
–Stream and decode video frames from an RTSP source.
-
VideoFrame
–A video frame with timestamp information.
Functions:
-
receive_video_frames
–Receive video frames from an RTSP stream.
Attributes:
-
BGRBuffer
–Type annotation for raw BGR image buffers of the scene camera
BGRBuffer
module-attribute
¶
BGRBuffer = NDArray[uint8]
Type annotation for raw BGR image buffers of the scene camera
RTSPVideoFrameStreamer
¶
Bases: RTSPRawStreamer
Stream and decode video frames from an RTSP source.
This class extends RTSPRawStreamer to parse raw RTSP data into video frames using the pupil_labs.video and pyav library for decoding.
Attributes:
-
_sprop_parameter_set_payloads
(list[ByteString] | None
) –Cached SPS/PPS parameters for the H.264 codec.
Methods:
-
receive
–Receive and decode video frames from the RTSP stream.
Source code in src/pupil_labs/realtime_api/streaming/video.py
93 94 95 |
|
encoding
property
¶
encoding: str
Get the encoding of the RTSP stream.
Returns:
-
str
(str
) –The encoding name in lowercase.
Raises:
-
SDPDataNotAvailableError
–If SDP data is missing or incomplete.
sprop_parameter_set_payloads
property
¶
sprop_parameter_set_payloads: list[ByteString] | None
Get the SPS/PPS parameter set payloads for the H.264 codec.
These parameters are extracted from the SDP data and are required for initializing the H.264 decoder.
Returns:
-
list[ByteString] | None
–list[ByteString]: List of parameter set payloads.
Raises:
-
SDPDataNotAvailableError
–If SDP data is missing required fields.
receive
async
¶
receive() -> AsyncIterator[VideoFrame]
Receive and decode video frames from the RTSP stream.
Source code in src/pupil_labs/realtime_api/streaming/video.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
VideoFrame
¶
Bases: NamedTuple
A video frame with timestamp information.
This class represents a video frame from the scene camera with associated timestamp information. The Class inherits VideoFrame from py.av library.
Methods:
-
bgr_buffer
–Convert the video frame to a BGR buffer.
-
to_ndarray
–Convert the video frame to a NumPy array.
Attributes:
-
av_frame
(VideoFrame
) –The video frame.
-
datetime
(datetime
) –Get timestamp as a datetime object.
-
timestamp_unix_ns
(int
) –Get timestamp in nanoseconds since Unix epoch.
-
timestamp_unix_seconds
(float
) –Timestamp in seconds since Unix epoch.
timestamp_unix_seconds
instance-attribute
¶
timestamp_unix_seconds: float
Timestamp in seconds since Unix epoch.
bgr_buffer
¶
bgr_buffer() -> BGRBuffer
Convert the video frame to a BGR buffer.
This method converts the video frame to a BGR buffer, which is a NumPy array with the shape (height, width, 3) and dtype uint8. The BGR format is commonly used in computer vision applications.
Returns:
-
BGRBuffer
(BGRBuffer
) –The BGR buffer as a NumPy array.
Source code in src/pupil_labs/realtime_api/streaming/video.py
46 47 48 49 50 51 52 53 54 55 56 57 |
|
to_ndarray
¶
Convert the video frame to a NumPy array.
Source code in src/pupil_labs/realtime_api/streaming/video.py
42 43 44 |
|
receive_video_frames
async
¶
receive_video_frames(url: str, *args: Any, **kwargs: Any) -> AsyncIterator[VideoFrame]
Receive video frames from an RTSP stream.
This is a convenience function that creates an RTSPVideoFrameStreamer and yields video frames.
Parameters:
-
url
(str
) –RTSP URL to connect to.
-
*args
(Any
, default:()
) –Additional positional arguments passed to RTSPVideoFrameStreamer.
-
**kwargs
(Any
, default:{}
) –Additional keyword arguments passed to RTSPVideoFrameStreamer.
Yields:
-
VideoFrame
(AsyncIterator[VideoFrame]
) –Parsed video frames.
Source code in src/pupil_labs/realtime_api/streaming/video.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
extract_payload_from_nal_unit
¶
extract_payload_from_nal_unit(unit: ByteString) -> ByteString
Extract and process payload from a Network Abstraction Layer (NAL) unit.
This function extracts the payload from a NAL unit, handling various formats: - Prepends NAL unit start code to payload if necessary - Handles fragmented units (of type FU-A)
The implementation follows RFC 3984 specifications for H.264 NAL units.
Parameters:
-
unit
(ByteString
) –The NAL unit as a ByteString.
Returns:
-
ByteString
(ByteString
) –The processed payload, potentially with start code prepended.
Raises:
-
ValueError
–If the first bit is not zero (forbidden_zero_bit).
References
Inspired by https://github.com/runtheops/rtsp-rtp/blob/master/transport/primitives/nal_unit.py Rewritten due to license incompatibility. See RFC 3984 (https://www.ietf.org/rfc/rfc3984.txt) for detailed NAL unit specifications.
Source code in src/pupil_labs/realtime_api/streaming/nal_unit.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
Raw RTSP Data¶
base
¶
Classes:
-
RTSPData
–Container for RTSP data with timestamp information.
-
RTSPRawStreamer
–Stream raw data from an RTSP source.
-
SDPDataNotAvailableError
–Exception raised when SDP data is not available or incomplete.
Functions:
-
receive_raw_rtsp_data
–Receive raw data from an RTSP stream.
RTSPData
¶
Bases: NamedTuple
Container for RTSP data with timestamp information.
Attributes:
-
datetime
(datetime
) –Get the timestamp as a datetime object.
-
raw
(ByteString
) –Raw binary data received from the RTSP stream.
-
timestamp_unix_ns
(int
) –Get the timestamp in nanoseconds since the Unix epoch.
-
timestamp_unix_seconds
(float
) –Timestamp in seconds since the Unix epoch from RTCP SR packets.
RTSPRawStreamer
¶
Stream raw data from an RTSP source.
This class connects to an RTSP source and provides access to the raw data with timestamps synchronized to the device's clock.
All constructor arguments are forwarded to the underlying aiortsp.rtsp.reader.RTSPReader.
Methods:
-
receive
–Receive raw data from the RTSP stream.
Attributes:
-
encoding
(str
) –Get the encoding of the RTSP stream.
-
reader
(_WallclockRTSPReader
) –Get the underlying RTSP reader.
Source code in src/pupil_labs/realtime_api/streaming/base.py
78 79 80 |
|
encoding
property
¶
encoding: str
Get the encoding of the RTSP stream.
Returns:
-
str
(str
) –The encoding name in lowercase.
Raises:
-
SDPDataNotAvailableError
–If SDP data is missing or incomplete.
receive
async
¶
receive() -> AsyncIterator[RTSPData]
Receive raw data from the RTSP stream.
This method yields RTSPData objects containing the raw data and corresponding timestamps.
Source code in src/pupil_labs/realtime_api/streaming/base.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
SDPDataNotAvailableError
¶
Bases: Exception
Exception raised when SDP data is not available or incomplete.
This exception is raised when attempting to access SDP (Session Description Protocol) data that is not yet available or is missing required fields.
receive_raw_rtsp_data
async
¶
receive_raw_rtsp_data(url: str, *args: Any, **kwargs: Any) -> AsyncIterator[RTSPData]
Receive raw data from an RTSP stream.
This is a convenience function that creates an RTSPRawStreamer and yields timestamped data packets.
Parameters:
-
url
(str
) –RTSP URL to connect to.
-
*args
(Any
, default:()
) –Additional positional arguments passed to RTSPRawStreamer.
-
**kwargs
(Any
, default:{}
) –Additional keyword arguments passed to RTSPRawStreamer.
Yields:
-
RTSPData
(AsyncIterator[RTSPData]
) –Timestamped RTSP data packets.
Source code in src/pupil_labs/realtime_api/streaming/base.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
Time Echo Protocol¶
time_echo
¶
Manual time offset estimation via the Pupil Labs Time Echo protocol.
The Realtime Network API host device timestamps its data with nanoseconds since the Unix epoch(January 1, 1970, 00:00:00 UTC). This clock is kept in sync by the operating system through NTP Network Time Protocol. For some use cases, this sync is not good enough. For more accurate time syncs, the Time Echo protocol allows the estimation of the direct offset between the host's and the client's clocks.
The Time Echo protocol works in the following way:
- The API host (Neon / Pupil Invisible Companion app) opens a TCP server at an specific port
- The client connects to the host address and port
- The client sends its current time (
t1
) in milliseconds as an uint64 in network byte order to the host - The host responds with the time echo, two uint64 values in network byte order
- The first value is equal to the sent client time (
t1
) - The second value corresponds to the host's time in milliseconds (
tH
) - The client calculates the duration of steps 3 and 4 (roundtrip time) by measuring the
client time before sending the request (
t1
) and after receiving the echo (t2
) - The protocol assumes that the transport duration is symmetric. It will assume that
tH
was measured at the same time as the midpoint betweet1
andt2
. -
To calculate the offset between the host's and client's clock, we subtract
tH
from the client's midpoint(t1 + t2) / 2
::offset_ms = ((t1 + t2) / 2) - tH
-
This measurement can be repeated multiple times to make the time offset estimation more robust.
To convert client to host time, subtract the offset::
host_time_ms = client_time_ms() - offset_ms
This is particularly helpful to accurately timestamp local events, e.g. a stimulus presentation.
To convert host to client time, add the offset::
client_time_ms = host_time_ms() + offset_ms
This is particularly helpful to convert the received data into the client's time domain.
Classes:
-
Estimate
–Provides easy access to statistics over a collection of measurements.
-
TimeEcho
–Measurement of a single time echo.
-
TimeEchoEstimates
–Provides estimates for the roundtrip duration and time offsets.
-
TimeOffsetEstimator
–Estimates the time offset between PC and Companion using the Time Echo protocol.
Functions:
-
time_ms
–Return milliseconds since
Unix epoch
_ (January 1, 1970, 00:00:00 UTC)
Attributes:
-
TimeFunction
–Returns time in milliseconds
Estimate
¶
Provides easy access to statistics over a collection of measurements.
This class calculates descriptive statistics (mean, standard deviation, median) over a collection of measurements.
Attributes:
-
measurements
(tuple[int]
) –The raw measurements.
-
mean
(float
) –Mean value of the measurements.
-
std
(float
) –Standard deviation of the measurements.
-
median
(float
) –Median value of the measurements.
Source code in src/pupil_labs/realtime_api/time_echo.py
88 89 90 91 92 |
|
TimeEcho
¶
Bases: NamedTuple
Measurement of a single time echo.
Attributes:
-
roundtrip_duration_ms
(int
) –Round trip duration of the time echo, in milliseconds.
-
time_offset_ms
(int
) –Time offset between host and client, in milliseconds.
TimeEchoEstimates
¶
Bases: NamedTuple
Provides estimates for the roundtrip duration and time offsets.
Attributes:
-
roundtrip_duration_ms
(Estimate
) –Statistics for roundtrip durations.
-
time_offset_ms
(Estimate
) –Statistics for time offsets.
TimeOffsetEstimator
¶
Estimates the time offset between PC and Companion using the Time Echo protocol.
This class implements the Time Echo protocol to estimate the time offset between the client and host clocks.
Attributes:
Methods:
-
estimate
–Estimate the time offset between client and host.
-
request_time_echo
–Request a time echo, measure the roundtrip time and estimate the time offset.
Source code in src/pupil_labs/realtime_api/time_echo.py
145 146 147 |
|
estimate
async
¶
estimate(number_of_measurements: int = 100, sleep_between_measurements_seconds: float | None = None, time_fn_ms: TimeFunction = time_ms) -> TimeEchoEstimates | None
Estimate the time offset between client and host.
Parameters:
-
number_of_measurements
(int
, default:100
) –Number of measurements to take.
-
sleep_between_measurements_seconds
(float | None
, default:None
) –Optional sleep time between measurements.
-
time_fn_ms
(TimeFunction
, default:time_ms
) –Function that returns the current time in milliseconds.
Returns:
-
TimeEchoEstimates
(TimeEchoEstimates | None
) –Statistics for roundtrip durations and time offsets, or None if estimation failed.
Source code in src/pupil_labs/realtime_api/time_echo.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
request_time_echo
async
staticmethod
¶
request_time_echo(time_fn_ms: TimeFunction, reader: StreamReader, writer: StreamWriter) -> TimeEcho
Request a time echo, measure the roundtrip time and estimate the time offset.
Parameters:
-
time_fn_ms
(TimeFunction
) –Function that returns the current time in milliseconds.
-
reader
(StreamReader
) –Stream reader for receiving responses.
-
writer
(StreamWriter
) –Stream writer for sending requests.
Returns:
-
TimeEcho
(TimeEcho
) –Roundtrip duration and time offset.
Raises:
-
ValueError
–If the response is invalid.
Source code in src/pupil_labs/realtime_api/time_echo.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
models
¶
Classes:
-
APIPath
–API endpoint paths for the Realtime API.
-
ConnectionType
–Enumeration of connection types.
-
DiscoveredDeviceInfo
–Information about a discovered device on the network.
-
Event
–Event information from the device.
-
Hardware
–Information about the Hardware connected (eye tracker).
-
InvalidTemplateAnswersError
–Exception raised when template answers fail validation.
-
NetworkDevice
–Information about devices discovered by the host device, not the client.
-
Phone
–Information relative to the Companion Device.
-
Recording
–Information about a recording.
-
Sensor
–Information about a sensor on the device.
-
SensorName
–Enumeration of sensor types.
-
Status
–Represents the Companion's Device full status
-
Template
–Template Class for data collection.
-
TemplateItem
–Individual item/ question in a Template.
-
UnknownComponentError
–Exception raised when a component cannot be parsed.
Functions:
-
allow_empty
–Convert empty strings to None.
-
make_template_answer_model_base
–Create a base class for template answer models.
-
not_empty
–Validate that a string is not empty.
-
option_in_allowed_values
–Validate that a value is in a list of allowed values.
-
parse_component
–Initialize an explicitly modelled representation
Attributes:
-
Component
–Type annotation for :class:
Status
components. -
ComponentRaw
–Type annotation for json-parsed responses from the REST and Websocket API.
-
TemplateDataFormat
–Format specification for template data.
-
TemplateItemInputType
–Type of input data for a template item.
-
TemplateItemWidgetType
–Type of widget to display for a template item.
Component
module-attribute
¶
Type annotation for :class:Status
components.
ComponentRaw
module-attribute
¶
Type annotation for json-parsed responses from the REST and Websocket API.
TemplateDataFormat
module-attribute
¶
TemplateDataFormat = Literal['api', 'simple']
Format specification for template data.
TemplateItemInputType
module-attribute
¶
TemplateItemInputType = Literal['any', 'integer', 'float']
Type of input data for a template item.
TemplateItemWidgetType
module-attribute
¶
TemplateItemWidgetType = Literal['TEXT', 'PARAGRAPH', 'RADIO_LIST', 'CHECKBOX_LIST', 'SECTION_HEADER', 'PAGE_BREAK']
Type of widget to display for a template item.
APIPath
¶
Bases: Enum
API endpoint paths for the Realtime API.
This enum defines the various API endpoints that can be accessed through the Realtime API.
Methods:
-
full_address
–Construct a full URL for this API endpoint.
full_address
¶
Construct a full URL for this API endpoint.
Source code in src/pupil_labs/realtime_api/models.py
47 48 49 50 51 |
|
DiscoveredDeviceInfo
¶
Bases: NamedTuple
Information about a discovered device on the network.
Attributes:
Event
¶
Bases: NamedTuple
Event information from the device.
Methods:
-
from_dict
–Create an Event from a dictionary.
Attributes:
-
datetime
(datetime
) –Get the event time as a datetime object.
-
name
(str | None
) –Name of the event.
-
recording_id
(str | None
) –ID of the recording this event belongs to.
-
timestamp
(int
) –Unix epoch timestamp in nanoseconds.
datetime
property
¶
datetime: datetime
Get the event time as a datetime object.
Returns:
-
datetime
(datetime
) –Event time as a Python datetime.
recording_id
instance-attribute
¶
recording_id: str | None
ID of the recording this event belongs to.
from_dict
classmethod
¶
Create an Event from a dictionary.
Parameters:
Returns:
-
Event
(Event
) –New Event instance.
Source code in src/pupil_labs/realtime_api/models.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
Hardware
¶
Bases: NamedTuple
Information about the Hardware connected (eye tracker).
Attributes:
-
glasses_serial
(str
) –Serial number of the glasses. For Pupil Invisible devices.
-
module_serial
(str
) –Serial number of the module. For Neon devices.
-
version
(str
) –Hardware version.
-
world_camera_serial
(str
) –Serial number of the world camera. For Pupil Invisible devices.
glasses_serial
class-attribute
instance-attribute
¶
glasses_serial: str = 'unknown'
Serial number of the glasses. For Pupil Invisible devices.
module_serial
class-attribute
instance-attribute
¶
module_serial: str = 'unknown'
Serial number of the module. For Neon devices.
InvalidTemplateAnswersError
¶
InvalidTemplateAnswersError(template: Template | TemplateItem, answers: dict[str, Any], errors: list[ErrorDetails])
Bases: Exception
Exception raised when template answers fail validation.
Attributes:
-
template
(Template | TemplateItem
) –Template or item that failed validation.
-
errors
(list[dict]
) –List of validation errors.
-
answers
(dict
) –The answers that failed validation.
Source code in src/pupil_labs/realtime_api/models.py
936 937 938 939 940 941 942 943 944 |
|
NetworkDevice
¶
Bases: NamedTuple
Information about devices discovered by the host device, not the client.
This class represents device information made available via the websocket update
connection by the host device (exposed via
pupil_labs.realtime_api.device.Device.status_updates
. Devices
discovered directly by this library are represented as
DiscoveredDeviceInfo and
returned by discover_devices
Network.
Attributes:
Phone
¶
Bases: NamedTuple
Information relative to the Companion Device.
Attributes:
-
battery_level
(int
) –Battery percentage (0-100)
-
battery_state
(Literal['OK', 'LOW', 'CRITICAL']
) –Battery state.
-
device_id
(str
) –Unique device identifier.
-
device_name
(str
) –Human-readable device name.
-
ip
(str
) –IP address of the phone.
-
memory
(int
) –Available memory in bytes.
-
memory_state
(Literal['OK', 'LOW', 'CRITICAL']
) –Memory state.
-
time_echo_port
(int | None
) –Port for time synchronization, if available.
Recording
¶
Bases: NamedTuple
Information about a recording.
Attributes:
-
action
(str
) –Current recording action.
-
id
(str
) –Unique recording identifier.
-
message
(str
) –Status message.
-
rec_duration_ns
(int
) –Recording duration in nanoseconds.
-
rec_duration_seconds
(float
) –Get the recording duration in seconds.
Sensor
¶
Bases: NamedTuple
Information about a sensor on the device.
Attributes:
-
conn_type
(str
) –Connection type (see ConnectionType Enum).
-
connected
(bool
) –Whether the sensor is connected.
-
ip
(str | None
) –IP address of the sensor.
-
params
(str | None
) –Additional parameters.
-
port
(int | None
) –Port number.
-
protocol
(str
) –Protocol used for the connection.
-
sensor
(str
) –Sensor type (see Name Enum).
-
stream_error
(bool
) –Whether the stream errors.
-
url
(str | None
) –Get the URL for accessing this sensor's data stream.
connected
class-attribute
instance-attribute
¶
connected: bool = False
Whether the sensor is connected.
protocol
class-attribute
instance-attribute
¶
protocol: str = 'rtsp'
Protocol used for the connection.
Status
dataclass
¶
Represents the Companion's Device full status
Methods:
-
direct_eye_events_sensor
–Get blinks, fixations sensor.
-
direct_eyes_sensor
–Get the eye camera sensor with direct connection. Only available on Neon.
-
direct_gaze_sensor
–Get the gaze sensor with direct connection.
-
direct_imu_sensor
–Get the IMU sensor with direct connection.
-
direct_world_sensor
–Get the scene camera sensor with direct connection.
-
from_dict
–Create a Status from a list of raw components.
-
matching_sensors
–Find sensors matching specified criteria.
-
update
–Update Component.
Attributes:
-
hardware
(Hardware
) –Information about glasses connected, won't be present if not connected
-
phone
(Phone
) –Information about the connected phone. Always present.
-
recording
(Recording | None
) –Current recording, if any.
-
sensors
(list[Sensor]
) –"List of sensor information.
hardware
instance-attribute
¶
hardware: Hardware
Information about glasses connected, won't be present if not connected
direct_eye_events_sensor
¶
direct_eye_events_sensor() -> Sensor | None
Get blinks, fixations sensor.
Only available on Neon with Companion App version 2.9 or newer.
Source code in src/pupil_labs/realtime_api/models.py
460 461 462 463 464 465 466 467 468 469 470 471 |
|
direct_eyes_sensor
¶
direct_eyes_sensor() -> Sensor | None
Get the eye camera sensor with direct connection. Only available on Neon.
Source code in src/pupil_labs/realtime_api/models.py
453 454 455 456 457 458 |
|
direct_gaze_sensor
¶
direct_gaze_sensor() -> Sensor | None
Get the gaze sensor with direct connection.
Source code in src/pupil_labs/realtime_api/models.py
439 440 441 442 443 444 |
|
direct_imu_sensor
¶
direct_imu_sensor() -> Sensor | None
Get the IMU sensor with direct connection.
Source code in src/pupil_labs/realtime_api/models.py
446 447 448 449 450 451 |
|
direct_world_sensor
¶
direct_world_sensor() -> Sensor | None
Get the scene camera sensor with direct connection.
Note
Pupil Invisible devices, the world camera can be detached
Source code in src/pupil_labs/realtime_api/models.py
425 426 427 428 429 430 431 432 433 434 435 436 437 |
|
from_dict
classmethod
¶
from_dict(status_json_result: list[ComponentRaw]) -> Status
Create a Status from a list of raw components.
Parameters:
-
status_json_result
(list[ComponentRaw]
) –List of raw component dictionaries.
Returns:
-
Status
(Status
) –New Status instance.
Source code in src/pupil_labs/realtime_api/models.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
matching_sensors
¶
matching_sensors(name: SensorName, connection: ConnectionType) -> Iterator[Sensor]
Find sensors matching specified criteria.
Parameters:
-
name
(SensorName
) –Sensor name to match, or ANY to match any name.
-
connection
(ConnectionType
) –Connection type to match, or ANY to match any type.
Yields:
-
Sensor
(Sensor
) –Sensors matching the criteria.
Source code in src/pupil_labs/realtime_api/models.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
|
update
¶
update(component: Component) -> None
Update Component.
Parameters:
-
component
(Component
) –Component to update.
Source code in src/pupil_labs/realtime_api/models.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
|
Template
¶
Template Class for data collection.
Methods:
-
convert_from_api_to_simple_format
–Convert data from API format to simple format.
-
convert_from_simple_to_api_format
–Convert data from simple format to API format.
-
get_question_by_id
–Get a template item by ID.
-
validate_answers
–Validate answers for this Template.
Attributes:
-
archived_at
(datetime | None
) –Archival timestamp (if archived).
-
created_at
(datetime
) –Creation timestamp.
-
description
(str | None
) –Template description.
-
id
(UUID
) –Unique identifier.
-
is_default_template
(bool
) –Whether this is the default template for the Workspace
-
items
(list[TemplateItem]
) –List of template items.
-
label_ids
(list[UUID]
) –Associated label IDs.
-
name
(str
) –Template name.
-
published_at
(datetime | None
) –Publication timestamp.
-
recording_ids
(list[UUID] | None
) –Associated recording IDs.
-
recording_name_format
(list[str]
) –Format for recording name.
-
updated_at
(datetime
) –Last update timestamp.
archived_at
class-attribute
instance-attribute
¶
archived_at: datetime | None = None
Archival timestamp (if archived).
description
class-attribute
instance-attribute
¶
description: str | None = None
Template description.
is_default_template
class-attribute
instance-attribute
¶
is_default_template: bool = True
Whether this is the default template for the Workspace
items
class-attribute
instance-attribute
¶
items: list[TemplateItem] = field(default_factory=list)
List of template items.
label_ids
class-attribute
instance-attribute
¶
Associated label IDs.
published_at
class-attribute
instance-attribute
¶
published_at: datetime | None = None
Publication timestamp.
recording_ids
class-attribute
instance-attribute
¶
Associated recording IDs.
recording_name_format
instance-attribute
¶
Format for recording name.
convert_from_api_to_simple_format
¶
Convert data from API format to simple format.
Parameters:
Returns:
Source code in src/pupil_labs/realtime_api/models.py
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
|
convert_from_simple_to_api_format
¶
Convert data from simple format to API format.
Parameters:
Returns:
Source code in src/pupil_labs/realtime_api/models.py
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
|
get_question_by_id
¶
get_question_by_id(question_id: str | UUID) -> TemplateItem | None
Get a template item by ID.
Parameters:
Returns:
-
TemplateItem | None
–TemplateItem | None: The template item, or None if not found.
Source code in src/pupil_labs/realtime_api/models.py
775 776 777 778 779 780 781 782 783 784 785 786 787 788 |
|
validate_answers
¶
validate_answers(answers: dict[str, list[str]], template_format: TemplateDataFormat, raise_exception: bool = True) -> list[ErrorDetails]
Validate answers for this Template.
Parameters:
-
answers
(dict[str, list[str]]
) –Answers to validate.
-
raise_exception
(bool
, default:True
) –Whether to raise an exception on validation failure.
-
template_format
(TemplateDataFormat
) –Format of the answers ("simple" or "api").
Returns:
-
list
(list[ErrorDetails]
) –List of validation errors, or empty list if validation succeeded.
Raises:
-
InvalidTemplateAnswersError
–If validation fails and raise_exception is
Source code in src/pupil_labs/realtime_api/models.py
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 |
|
TemplateItem
¶
Individual item/ question in a Template.
Methods:
-
validate_answer
–Validate an answer for this template item.
Attributes:
-
choices
(list[str] | None
) –Available choices for selection items (e.g., radio or checkbox).
-
help_text
(str | None
) –Help or description text for the item.
-
id
(UUID
) –Unique identifier for the template item.
-
input_type
(TemplateItemInputType
) –Type of input data for this item.
-
required
(bool
) –Whether the item is required or not.
-
title
(str
) –Title or question text for the template item.
-
widget_type
(TemplateItemWidgetType
) –Type of widget to display for this item.
choices
instance-attribute
¶
Available choices for selection items (e.g., radio or checkbox).
widget_type
instance-attribute
¶
widget_type: TemplateItemWidgetType
Type of widget to display for this item.
validate_answer
¶
validate_answer(answer: Any, template_format: TemplateDataFormat = 'simple', raise_exception: bool = True) -> list[ErrorDetails]
Validate an answer for this template item.
Parameters:
-
answer
(Any
) –Answer to validate.
-
template_format
(TemplateDataFormat
, default:'simple'
) –Format of the template ("simple" or "api").
-
raise_exception
(bool
, default:True
) –Whether to raise an exception on validation failure.
Returns:
-
list
(list[ErrorDetails]
) –List of validation errors, or empty list if validation succeeded.
Raises:
-
InvalidTemplateAnswersError
–If validation fails and raise_exception is
Source code in src/pupil_labs/realtime_api/models.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
|
UnknownComponentError
¶
Bases: ValueError
Exception raised when a component cannot be parsed.
allow_empty
¶
Convert empty strings to None.
Source code in src/pupil_labs/realtime_api/models.py
864 865 866 867 868 |
|
make_template_answer_model_base
¶
Create a base class for template answer models.
Parameters:
-
template_
(Template
) –Template to create the model for.
Returns:
-
type
(type[BaseModel]
) –Base class for template answer models.
Source code in src/pupil_labs/realtime_api/models.py
878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
|
not_empty
¶
Validate that a string is not empty.
Source code in src/pupil_labs/realtime_api/models.py
857 858 859 860 861 |
|
option_in_allowed_values
¶
Validate that a value is in a list of allowed values.
Source code in src/pupil_labs/realtime_api/models.py
871 872 873 874 875 |
|
parse_component
¶
parse_component(raw: ComponentRaw) -> Component
Initialize an explicitly modelled representation
(:obj:pupil_labs.realtime_api.models.Component
) from the json-parsed dictionary
(:obj:pupil_labs.realtime_api.models.ComponentRaw
) received from the API.
Parameters:
-
raw
(ComponentRaw
) –Dictionary containing component data.
Returns:
-
Component
(Component
) –Parsed component instance.
Raises:
-
UnknownComponentError
–If the component name cannot be mapped to an
Source code in src/pupil_labs/realtime_api/models.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
base
¶
Classes:
-
DeviceBase
–Abstract base class representing Realtime API host devices.
Attributes:
-
DeviceType
–Type annotation for concrete sub-classes of :class:`DeviceBase
DeviceType
module-attribute
¶
DeviceType = TypeVar('DeviceType', bound='DeviceBase')
Type annotation for concrete sub-classes of :class:DeviceBase
<pupil_labs.realtime_api.base.DeviceBase>
.
DeviceBase
¶
DeviceBase(address: str, port: int, full_name: str | None = None, dns_name: str | None = None, suppress_decoding_warnings: bool = True)
Bases: ABC
Abstract base class representing Realtime API host devices.
This class provides the foundation for device implementations that connect to the Realtime API.
Attributes:
-
address
(str
) –REST API server address.
-
port
(int
) –REST API server port.
-
full_name
(str | None
) –Full service discovery name.
-
dns_name
(str | None
) –REST API server DNS name, e.g.
neon.local / pi.local.
.
Parameters:
-
address
(str
) –REST API server address.
-
port
(int
) –REST API server port.
-
full_name
(str | None
, default:None
) –Full service discovery name.
-
dns_name
(str | None
, default:None
) –REST API server DNS name, e.g.
neon.local / pi.local.
. -
suppress_decoding_warnings
(bool
, default:True
) –Whether to suppress libav decoding warnings.
Methods:
-
api_url
–Construct a full API URL for the given path.
-
convert_from
–Convert another device instance to this type.
-
from_discovered_device
–Create a device instance from discovery information.
Source code in src/pupil_labs/realtime_api/base.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
api_url
¶
Construct a full API URL for the given path.
Parameters:
-
path
(APIPath
) –API path to access.
-
protocol
(str
, default:'http'
) –Protocol to use (http).
-
prefix
(str
, default:'/api'
) –API URL prefix.
Returns:
-
str
–Complete URL for the API endpoint.
Source code in src/pupil_labs/realtime_api/base.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
convert_from
classmethod
¶
convert_from(other: T) -> DeviceType
Convert another device instance to this type.
Parameters:
-
other
(T
) –Device instance to convert.
Returns:
-
DeviceType
–Converted device instance.
Source code in src/pupil_labs/realtime_api/base.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
from_discovered_device
classmethod
¶
from_discovered_device(device: DiscoveredDeviceInfo) -> DeviceType
Create a device instance from discovery information.
Parameters:
-
device
(DiscoveredDeviceInfo
) –Discovered device information.
Returns:
-
DeviceType
–Device instance
Source code in src/pupil_labs/realtime_api/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|