Public Attributes | |
| host = ip | |
| port = port | |
Protected Member Functions | |
| _debug_print (self, msg) | |
| _format_msg (self, command, ID, values=None) | |
| _log_consolidation (self) | |
| _log_sample (self, sample) | |
| _parse_msg (self, xml) | |
| _process_logging (self) | |
| _process_incoming (self) | |
| _process_outgoing (self) | |
| _send_message (self, command, ID, values=None, wait_for_acknowledgement=True, resend_timeout=3.0, maxwait=9.0) | |
Protected Attributes | |
| _debug = debug | |
| _debuglog = open('debug_%s.txt' % (dt), 'w') | |
| int | _debugcounter = 0 |
| int | _debugconsolidatefreq = 100 |
| _sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| int | _maxrecvsize = 4096 |
| _socklock = Lock() | |
| _connected = Event() | |
| int | _current_calibration_point = None |
| _logfile = open(logfile, 'w') | |
| list | _logheader |
| _n_logvars = len(self._logheader) | |
| int | _logcounter = 0 |
| int | _log_consolidation_freq = 60 |
| _logqueue = Queue() | |
| _logging = Event() | |
| _log_ready_for_closing = Event() | |
| _logthread | |
| dict | _incoming = {} |
| dict | _acknowledgements = {} |
| _inlock = Lock() | |
| _acklock = Lock() | |
| str | _unfinished = '' |
| _inthread | |
| _outqueue = Queue() | |
| _sock_ready_for_closing = Event() | |
| _outthread | |
| dict | _outlatest = {} |
| _outlock = Lock() | |
| str | _thread_shutdown_signal = 'KILL_ALL_HUMANS' |
| pygaze._eyetracker.opengaze.OpenGazeTracker.__init__ | ( | self, | |
| ip = '127.0.0.1', | |||
| port = 4242, | |||
| logfile = 'default.tsv', | |||
| debug = False ) |
The OpenGazeConnection class communicates to the GazePoint
server through a TCP/IP socket. Incoming samples will be written
to a log at the specified path.
Keyword Arguments
ip - The IP address of the computer that is running the
OpenGaze server. This will usually be the localhost at
127.0.0.1. Type: str. Default = '127.0.0.1'
port - The port number that the OpenGaze server is on; usually
this will be 4242. Type: int. Default = 4242
logfile - The path to the intended log file, including a
file extension ('.tsv'). Type: str. Default =
'default.tsv'
debug - Boolean that determines whether DEBUG mode should be
active (True) or not (False). In DEBUG mode, all sent
and received messages are logged to a file. Type: bool.
Default = False
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| pygaze._eyetracker.opengaze.OpenGazeTracker.api_id | ( | self | ) |
Returns the API version number.
| pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate | ( | self | ) |
Calibrates the eye tracker.
| pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_addpoint | ( | self, | |
| x, | |||
| y ) |
Add a calibration point at the passed horizontal (x) and
vertical (y) coordinates. These coordinates should be as a
proportion of the screen resolution, where (0,0) is the top-left,
(0.5,0.5) is the screen centre, and (1,1) is the bottom-right.
| pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_clear | ( | self | ) |
Clear the internal list of calibration points.
| pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_delay | ( | self, | |
| value ) |
Set the duration of the calibration animation (before
calibration at a point begins) in seconds. The value can be an int
or a float.
| pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_reset | ( | self | ) |
Reset the internal list of calibration points to the default
values.
| pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_result_summary | ( | self | ) |
Returns a summary of the calibration results, which consists of
the following values:
AVE_ERROR: Average error over all calibrated points.
VALID_POINTS: Number of successfully calibrated points.
| pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_show | ( | self, | |
| state ) |
Shows (state=1) or hides (state=0) the calibration window on the
tracker's display window. While showing the calibration window, you
can call 'calibrate_start' to run the calibration procedure.
| pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_start | ( | self, | |
| state ) |
Starts (state=1) or stops (state=0) the calibration procedure.
Make sure to call the 'calibrate_show' function beforehand, or to
implement your own calibration visualisation; otherwise a call to
this function will make the calibration run in the background.
| pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_timeout | ( | self, | |
| value ) |
Set the duration of the calibration point (not including the
animation time) in seconds. The value can be an int or a float.
| pygaze._eyetracker.opengaze.OpenGazeTracker.camera_size | ( | self | ) |
Returns the size of the camera sensor in pixels, as [w,h].
| pygaze._eyetracker.opengaze.OpenGazeTracker.clear_calibration_result | ( | self | ) |
Clears the internally stored calibration result.
| pygaze._eyetracker.opengaze.OpenGazeTracker.close | ( | self | ) |
Closes the connection to the tracker, closes the log files, and
ends the Threads that process the incoming and outgoing messages,
and the logging of samples.
| pygaze._eyetracker.opengaze.OpenGazeTracker.company_id | ( | self | ) |
Returns the identifier of the manufacturer of the connected
eye-tracker.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_counter | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
the send counter in the data record string.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_cursor | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
data on the mouse cursor in the data record string. This data
consists of the following:
CX: The horizontal coordinate of the mouse cursor, as a percentage
of the screen resolution.
CY: The vertical coordinate of the mouse cursor, as a percentage
of the screen resolution.
CS: The mouse cursor state, 0 for steady state, 1 for left button
down, 2 for rigght button down.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_data | ( | self, | |
| state ) |
Start (state=True) or stop (state=False) the streaming of data
from the server to the client.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_eye_left | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
3D data on left eye in the data record string. This data consists
of the following:
LEYEX: The horizontal coordinate of the left eye in 3D space with
respect to the camera focal point, in meters.
LEYEY: The vertical coordinate of the left eye in 3D space with
respect to the camera focal point, in meters.
LEYEZ: The depth coordinate of the left eye in 3D space with
respect to the camera focal point, in meters.
LPUPILD: The diameter of the left eye pupil in meters.
LPUPILV: The valid flag with a value of 1 if the data is valid, and
0 if it is not.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_eye_right | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
3D data on right eye in the data record string. This data consists
of the following:
REYEX: The horizontal coordinate of the right eye in 3D space with
respect to the camera focal point, in meters.
REYEY: The vertical coordinate of the right eye in 3D space with
respect to the camera focal point, in meters.
REYEZ: The depth coordinate of the right eye in 3D space with
respect to the camera focal point, in meters.
RPUPILD: The diameter of the right eye pupil in meters.
RPUPILV: The valid flag with a value of 1 if the data is valid, and
0 if it is not.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_pog_best | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
the 'best' point of gaze in the data record string. This is based
on the average of the left and right POG if both eyes are available,
or on the value of the one available eye.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_pog_fix | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
the point of gaze as determined by the tracker's fixation filter in
the data record string.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_pog_left | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
the point of gaze of the left eye in the data record string.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_pog_right | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
the point of gaze of the right eye in the data record string.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_pupil_left | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
pupil data on the left eye in the data record string. This data
consists of the following:
LPCX: The horizontal coordinate of the left eye pupil in the camera
image, as a fraction of the camera size.
LPCY: The vertical coordinate of the left eye pupil in the camera
image, as a fraction of the camera size.
LPD: The left eye pupil's diameter in pixels.
LPS: The scale factor of the left eye pupil (unitless). Value
equals 1 at calibration depth, is less than 1 when the user
is closer to the eye tracker and greater than 1 when the user
is further away.
LPV: The valid flag with a value of 1 if the data is valid, and 0
if it is not.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_pupil_right | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
pupil data on the right eye in the data record string. This data
consists of the following:
RPCX: The horizontal coordinate of the right eye pupil in the camera
image, as a fraction of the camera size.
RPCY: The vertical coordinate of the right eye pupil in the camera
image, as a fraction of the camera size.
RPD: The right eye pupil's diameter in pixels.
RPS: The scale factor of the right eye pupil (unitless). Value
equals 1 at calibration depth, is less than 1 when the user
is closer to the eye tracker and greater than 1 when the user
is further away.
RPV: The valid flag with a value of 1 if the data is valid, and 0
if it is not.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_time | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
the send time in the data record string.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_time_tick | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
the send time tick in the data record string.
| pygaze._eyetracker.opengaze.OpenGazeTracker.enable_send_user_data | ( | self, | |
| state ) |
Enable (state=True) or disable (state=False) the inclusion of
user-defined variables in the data record string. User-defined
variables can be set with the 'user_data' method.
| pygaze._eyetracker.opengaze.OpenGazeTracker.get_api_id | ( | self | ) |
Returns the API version number.
| pygaze._eyetracker.opengaze.OpenGazeTracker.get_calibration_points | ( | self | ) |
Returns a list of the current calibration points.
| pygaze._eyetracker.opengaze.OpenGazeTracker.get_calibration_result | ( | self | ) |
Returns the latest available calibration results as a list of
dicts, each with the following keys:
CALX: Calibration point's horizontal coordinate.
CALY: Calibration point's vertical coordinate
LX: Left eye's recorded horizontal point of gaze.
LY: Left eye's recorded vertical point of gaze.
LV: Left eye's validity status (1=valid, 0=invalid)
RX: Right eye's recorded horizontal point of gaze.
RY: Right eye's recorded vertical point of gaze.
RV: Right eye's validity status (1=valid, 0=invalid)
Returns None if no calibration results are available.
| pygaze._eyetracker.opengaze.OpenGazeTracker.get_camera_size | ( | self | ) |
Returns the size of the camera sensor in pixels, as [w,h].
| pygaze._eyetracker.opengaze.OpenGazeTracker.get_company_id | ( | self | ) |
Returns the identifier of the manufacturer of the connected
eye-tracker.
| pygaze._eyetracker.opengaze.OpenGazeTracker.get_product_id | ( | self | ) |
Returns the identifier of the connected eye-tracker.
| pygaze._eyetracker.opengaze.OpenGazeTracker.get_screen_size | ( | self | ) |
Returns the x and y coordinates of the top-left of the screen in
pixels, as well as the screen width and height in pixels. The
result is returned as [x, y, w, h].
| pygaze._eyetracker.opengaze.OpenGazeTracker.get_serial_id | ( | self | ) |
Returns the serial number of the connected eye-tracker.
| pygaze._eyetracker.opengaze.OpenGazeTracker.get_time_tick_frequency | ( | self | ) |
Returns the time-tick frequency to convert the TIME_TICK
variable to seconds.
| pygaze._eyetracker.opengaze.OpenGazeTracker.log | ( | self, | |
| message ) |
Logs a message to the log file. ONLY CALL THIS WHILE RECORDING
DATA!
| pygaze._eyetracker.opengaze.OpenGazeTracker.product_id | ( | self | ) |
Returns the identifier of the connected eye-tracker.
| pygaze._eyetracker.opengaze.OpenGazeTracker.pupil_size | ( | self | ) |
Return the current pupil size.
| pygaze._eyetracker.opengaze.OpenGazeTracker.sample | ( | self | ) |
| pygaze._eyetracker.opengaze.OpenGazeTracker.screen_size | ( | self, | |
| x, | |||
| y, | |||
| w, | |||
| h ) |
Set the gaze tracking screen position (x,y) and size (w, h). You
can use this to work with multi-monitor systems. All values are in
pixels.
| pygaze._eyetracker.opengaze.OpenGazeTracker.serial_id | ( | self | ) |
Returns the serial number of the connected eye-tracker.
| pygaze._eyetracker.opengaze.OpenGazeTracker.start_recording | ( | self | ) |
Start writing data to the log file.
| pygaze._eyetracker.opengaze.OpenGazeTracker.stop_recording | ( | self | ) |
Pause writing data to the log file.
| pygaze._eyetracker.opengaze.OpenGazeTracker.time_tick_frequency | ( | self | ) |
Returns the time-tick frequency to convert the TIME_TICK
variable to seconds.
| pygaze._eyetracker.opengaze.OpenGazeTracker.tracker_display | ( | self, | |
| state ) |
Shows (state=1) or hides (state=0) the eye tracker display
window.
| pygaze._eyetracker.opengaze.OpenGazeTracker.user_data | ( | self, | |
| value ) |
Set the value of the user data field for embedding custom data
into the data stream. The user data value should be a string.
| pygaze._eyetracker.opengaze.OpenGazeTracker.wait_for_calibration_point_start | ( | self, | |
| timeout = 10.0 ) |
Waits for the next calibration point start, which is defined as
the first unregistered point after the latest calibration start
message. This function allows for setting a timeout in seconds
(default = 10.0). Returns the (x,y) coordinate in relative
coordinates (proportions of the screen width and height) if the
point started, and None after a timeout. (Also updates the
internally stored latest registered calibration point number.)
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| pygaze._eyetracker.opengaze.OpenGazeTracker.host = ip |
| pygaze._eyetracker.opengaze.OpenGazeTracker.port = port |