Skip to content

Others

Time Offset Estimation

1.1.0

Additionally, we offer you a convenient function to estimate the time offset between the device and your computer using the TimeOffsetEstimator.estimate method.

See time_echo for details.

        time_offset_estimator = TimeOffsetEstimator(
            status.phone.ip, status.phone.time_echo_port
        )
Mean time offset: -37.53 ms
Mean roundtrip duration: 12.91 ms
Check the whole example code here
device_time_offset.py
 1
 2
 3
 4
 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
import asyncio

from pupil_labs.realtime_api import Device, Network
from pupil_labs.realtime_api.time_echo import TimeOffsetEstimator


async def main():
    async with Network() as network:
        dev_info = await network.wait_for_new_device(timeout_seconds=5)
    if dev_info is None:
        print("No device could be found! Abort")
        return

    async with Device.from_discovered_device(dev_info) as device:
        status = await device.get_status()

        print(f"Device IP address: {status.phone.ip}")
        print(f"Device Time Echo port: {status.phone.time_echo_port}")

        if status.phone.time_echo_port is None:
            print(
                "You Pupil Invisible Companion app is out-of-date and does not yet "
                "support the Time Echo protocol. Upgrade to version 1.4.28 or newer."
            )
            return

        time_offset_estimator = TimeOffsetEstimator(
            status.phone.ip, status.phone.time_echo_port
        )
        estimated_offset = await time_offset_estimator.estimate()
        print(f"Mean time offset: {estimated_offset.time_offset_ms.mean} ms")
        print(
            f"Mean roundtrip duration: {estimated_offset.roundtrip_duration_ms.mean} ms"
        )


if __name__ == "__main__":
    asyncio.run(main())

Wanna get super precise time sync?

Have a look at our tutorial here.

Camera calibration

Neon

Getting the camera calibration coefficients can be extremely useful for undistorting the video. You can receive camera calibration parameters using the get_calibration method.

await device.get_calibration()

Returns a pupil_labs.neon_recording.calib.Calibration object.

Calibration(
    version = np.uint8(1)
    serial = '841684'
    scene_camera_matrix = array([[896.23068471,   0.        , 790.8950718 ],
                [  0.        , 895.99428647, 593.30938736],
                [  0.        ,   0.        ,   1.        ]])
    scene_distortion_coefficients = array([-0.13185823,  0.11141446, -0.00072215, -0.00019211, -0.00102044,
                0.17091784,  0.05497444,  0.02371847])
    scene_extrinsics_affine_matrix = array([[1., 0., 0., 0.],
                [0., 1., 0., 0.],
                [0., 0., 1., 0.],
                [0., 0., 0., 1.]])
    right_camera_matrix = array([[140.03968681,   0.        ,  99.07925009],
                [  0.        , 140.16685902,  96.21073359],
                [  0.        ,   0.        ,   1.        ]])
    right_distortion_coefficients = array([ 4.88968666e-02, -1.28678179e-01, -2.42854366e-04,  6.16360859e-04,
                -6.13765032e-01, -4.34790467e-02,  3.41057533e-02, -6.83627299e-01])
    right_extrinsics_affine_matrix = array([[-0.8363896 ,  0.14588414,  0.52836567, 16.93598175],
                [ 0.05819079,  0.98211712, -0.17905241, 19.64488983],
                [-0.54503787, -0.11901156, -0.82992166, -7.03995514],
                [ 0.        ,  0.        ,  0.        ,  1.        ]])
    left_camera_matrix = array([[139.60850687,   0.        ,  93.21881139],
                [  0.        , 139.73659663,  95.43463863],
                [  0.        ,   0.        ,   1.        ]])
    left_distortion_coefficients = array([ 4.95496340e-02, -1.27421933e-01,  6.92379886e-04,  4.98479011e-04,
                -6.26153622e-01, -4.43117940e-02,  3.31060602e-02, -6.91888536e-01])
    left_extrinsics_affine_matrix = array([[ -0.83850485,  -0.13447338,  -0.52804023, -17.65301514],
                [ -0.05493483,   0.98499447,  -0.16360955,  19.88935852],
                [  0.54211783,  -0.10817961,  -0.83330995,  -7.48944855],
                [  0.        ,   0.        ,   0.        ,   1.        ]])
    crc = np.uint32(734156985)
)

Wanna know how to undistort the video?"

Get a look at our tutorial.