Skip to content

Commit

Permalink
Exceptions and internal thread added
Browse files Browse the repository at this point in the history
  • Loading branch information
balancana committed Jul 8, 2015
1 parent d68db1d commit 6bce7fc
Show file tree
Hide file tree
Showing 5 changed files with 2,873 additions and 461 deletions.
32 changes: 8 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,35 @@ Note that use of this software is not officially supported by Tobii.

## Example ##

The following example prints normalized screen coordinates for first 10 events.
The following example prints normalized screen coordinates for first 20 events.

```python

from gazesdk import *
import threading

t = Tracker()
t.create(get_connected_eye_tracker())

def eventloop(tracker):
tracker.run_event_loop()

el = threading.Thread(target=eventloop, args=(t,))
el.start()
url = get_connected_eye_tracker()
t = Tracker(url)
t.run_event_loop()

print "Connecting..."
t.connect()

print "Starting..."
t.start_tracking()

for _ in range(20):
data = t.event_queue.get()
print data.left.gaze_point_on_display_normalized, data.left.gaze_point_on_display_normalized
print (data.left.gaze_point_on_display_normalized,
data.right.gaze_point_on_display_normalized)
t.event_queue.task_done()

print "Stopping..."
t.stop_tracking()

print "Disconnecting..."
t.disconnect()

print "Breaking event loop"
t.break_event_loop()
el.join()
t.destroy()

```

## TODO ##

- [ ] Calibration functions
- [ ] Raising exceptions on error codes
- [ ] Internal thread running
- [X] Raising exceptions on error codes
- [X] Internal thread running
- [ ] API docs

## Licence ##
Expand Down
20 changes: 12 additions & 8 deletions cgazesdk.pxd
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from libc.stdint cimport uint32_t, uint64_t

cdef extern from "tobiigaze_data_types.h":

cdef extern from "tobiigaze_error_codes.h":

ctypedef enum tobiigaze_error_code:
pass

cdef extern from "tobiigaze_data_types.h":

ctypedef enum tobiigaze_tracking_status:
pass

Expand Down Expand Up @@ -46,13 +49,14 @@ cdef extern from "tobiigaze.h":
void tobiigaze_run_event_loop(tobiigaze_eye_tracker *eye_tracker, tobiigaze_error_code *error_code) nogil

void tobiigaze_connect(tobiigaze_eye_tracker *eye_tracker, tobiigaze_error_code *error_code) nogil
void tobiigaze_disconnect(tobiigaze_eye_tracker *eye_tracker)
int tobiigaze_is_connected(tobiigaze_eye_tracker *eye_tracker)

void tobiigaze_start_tracking(tobiigaze_eye_tracker *eye_tracker, tobiigaze_gaze_listener gaze_callback, tobiigaze_error_code *error_code, void *user_data)
void tobiigaze_stop_tracking(tobiigaze_eye_tracker *eye_tracker, tobiigaze_error_code *error_code)
void tobiigaze_break_event_loop(tobiigaze_eye_tracker *eye_tracker)
void tobiigaze_destroy(tobiigaze_eye_tracker *eye_tracker)
void tobiigaze_disconnect(tobiigaze_eye_tracker *eye_tracker) nogil
int tobiigaze_is_connected(tobiigaze_eye_tracker *eye_tracker) nogil

void tobiigaze_start_tracking(tobiigaze_eye_tracker *eye_tracker, tobiigaze_gaze_listener gaze_callback,
tobiigaze_error_code *error_code, void *user_data) nogil
void tobiigaze_stop_tracking(tobiigaze_eye_tracker *eye_tracker, tobiigaze_error_code *error_code) nogil
void tobiigaze_break_event_loop(tobiigaze_eye_tracker *eye_tracker) nogil
void tobiigaze_destroy(tobiigaze_eye_tracker *eye_tracker) nogil


cdef extern from "tobiigaze_discovery.h":
Expand Down
Loading

0 comments on commit 6bce7fc

Please sign in to comment.