betaboon / python-tobii-stream-engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tobii-stream-engine

Important

This is an unofficial library!

Introduction

The Tobii Eye Tracker 5 is an affordable, consumer-grade eye tracker.

It is not officially supported on linux.

This library is a cffi-wrapper for the undocumented tobii-stream-engine contained in the official Tobii Pro SDK.

Usage

from tobii_stream_engine import Api, Device, GazePoint, Stream

def on_gaze_point(timestamp: int, gaze_point: GazePoint) -> None:
    print(f"{gaze_point=}")

def main() -> None:
    api = Api()
    device_urls = api.enumerate_local_device_urls()

    if not len(device_urls):
        print("no device found")
        return

    device = Device(api=api, url=device_urls[0])

    if not device.is_supported_stream(Stream.GAZE_POINT):
        print("gaze-point not supported")
        return

    device.subscribe_gaze_point(callback=on_gaze_point)
    device.run()

if __name__ == "__main__":
    main()

Preconditions

Tobii Pro SDK

Download and install the Tobii Pro SDK C for Linux.

tobiiusbservice

Download and install the tobiiusbservice.

It is not contained in this repository for licensing reasons.

Use the search-engine of your choice to locate it.

To install it:

sudo dpkg -i tobiiusbservice_l64U14_2.1.5-28fd4a.deb

It has been found that the directory /var/run/tobiiusb has to exist for it to start.

sudo mkdir -p /var/run/tobiiusb

To start it:

sudo tobiiusbserviced

To enable debug logging:

sudo sh -c "echo 4 | nc -U /var/run/tobii_log"

Build dependencies

apt install build-essential python3.10-dev

Installation

export LD_LIBRARY_PATH=/usr/local/lib/libtobii_research

pip install git+https://github.com/betaboon/python-tobii-stream-engine.git

Examples

Background

Tobii Pro SDK provides libtobii_research.so whose interface is documented1.

As it turns out, this library contains all the exports that are present in libtobii_stream_engine.so, but they are undocumented.

Luckily documentation for Tobii Stream Engine is publicly available2.

For the CFFI wrapper we generate header-files from this documentation3.

Prior work

Footnotes

  1. https://developer.tobiipro.com/c/c-sdk-reference-guide.html

  2. https://tobiitech.github.io/stream-engine-docs/

  3. tobii_stream_engine/builder/build_header_files.py

About


Languages

Language:Python 57.9%Language:C 40.5%Language:Nix 1.5%