Updated peyetribe

Development forum for the Python programming language.

Updated peyetribe

Postby pgba » 14 Aug 2014, 16:42

There now seems to be an abundance of python interfaces to the eye tribe :-)

I have nevertheless updated the peyetribe interface a bit, to make it more robust and maybe also easier to use.

It works with both python3 and python2, so you could use it with e.g. the PsychoPy toolbox and others that are not updated to python3 yet. Just copy the peyetribe.py file to the directory where you have your other python files (or install it as a module).

It offers a very simple interface, and hides most of the complexity of multiple threads (listener and heartbeat).

A very simple use case could be as follows, using the tracker in pull mode:

Code: Select all
from peyetribe import eyetribe

tracker = eyetribe()
tracker.connect()

while True: # or some better condition...
    n = tracker.next()
    print(str(n))

tracker.close()


Or a more elaborate example, using push mode and relying on multiple synchronised threads and internal queues that ensure you don't loose any data, and only printing the left eye coordinates:

Code: Select all
from peyetribe import eyetribe

tracker = eyetribe(host="your.host", port=1234)
tracker.connect()

tracker.pushmode()
count = 0
while count < 100:
    n = tracker.next()
    print("Left: %s" % (str(n.geteye(left=True))))
    count += 1

tracker.pullmode()

tracker.close()


It can still be found at https://github.com/baekgaard/peyetribe

I may still clean up the code a bit; this has evolved some over time and could obviously be made smarter in some places.

Comments or ideas for improvement are obviously welcome :-)
pgba
 
Posts: 8
Joined: 14 Jan 2014, 10:12

Return to Python



cron