Eyetracker
 
Loading...
Searching...
No Matches
pygaze._eyetracker.opengaze.OpenGazeTracker Class Reference

Public Member Functions

 __init__ (self, ip='127.0.0.1', port=4242, logfile='default.tsv', debug=False)
 
 calibrate (self)
 
 sample (self)
 
 pupil_size (self)
 
 log (self, message)
 
 start_recording (self)
 
 stop_recording (self)
 
 close (self)
 
 enable_send_data (self, state)
 
 enable_send_counter (self, state)
 
 enable_send_time (self, state)
 
 enable_send_time_tick (self, state)
 
 enable_send_pog_fix (self, state)
 
 enable_send_pog_left (self, state)
 
 enable_send_pog_right (self, state)
 
 enable_send_pog_best (self, state)
 
 enable_send_pupil_left (self, state)
 
 enable_send_pupil_right (self, state)
 
 enable_send_eye_left (self, state)
 
 enable_send_eye_right (self, state)
 
 enable_send_cursor (self, state)
 
 enable_send_user_data (self, state)
 
 calibrate_start (self, state)
 
 calibrate_show (self, state)
 
 calibrate_timeout (self, value)
 
 calibrate_delay (self, value)
 
 calibrate_result_summary (self)
 
 calibrate_clear (self)
 
 calibrate_reset (self)
 
 calibrate_addpoint (self, x, y)
 
 get_calibration_points (self)
 
 clear_calibration_result (self)
 
 get_calibration_result (self)
 
 wait_for_calibration_point_start (self, timeout=10.0)
 
 user_data (self, value)
 
 tracker_display (self, state)
 
 time_tick_frequency (self)
 
 get_time_tick_frequency (self)
 
 screen_size (self, x, y, w, h)
 
 get_screen_size (self)
 
 camera_size (self)
 
 get_camera_size (self)
 
 product_id (self)
 
 get_product_id (self)
 
 serial_id (self)
 
 get_serial_id (self)
 
 company_id (self)
 
 get_company_id (self)
 
 api_id (self)
 
 get_api_id (self)
 

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'
 

Constructor & Destructor Documentation

◆ __init__()

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

Member Function Documentation

◆ _debug_print()

pygaze._eyetracker.opengaze.OpenGazeTracker._debug_print ( self,
msg )
protected

◆ _format_msg()

pygaze._eyetracker.opengaze.OpenGazeTracker._format_msg ( self,
command,
ID,
values = None )
protected

◆ _log_consolidation()

pygaze._eyetracker.opengaze.OpenGazeTracker._log_consolidation ( self)
protected

◆ _log_sample()

pygaze._eyetracker.opengaze.OpenGazeTracker._log_sample ( self,
sample )
protected

◆ _parse_msg()

pygaze._eyetracker.opengaze.OpenGazeTracker._parse_msg ( self,
xml )
protected

◆ _process_incoming()

pygaze._eyetracker.opengaze.OpenGazeTracker._process_incoming ( self)
protected

◆ _process_logging()

pygaze._eyetracker.opengaze.OpenGazeTracker._process_logging ( self)
protected

◆ _process_outgoing()

pygaze._eyetracker.opengaze.OpenGazeTracker._process_outgoing ( self)
protected

◆ _send_message()

pygaze._eyetracker.opengaze.OpenGazeTracker._send_message ( self,
command,
ID,
values = None,
wait_for_acknowledgement = True,
resend_timeout = 3.0,
maxwait = 9.0 )
protected

◆ api_id()

pygaze._eyetracker.opengaze.OpenGazeTracker.api_id ( self)
Returns the API version number.

◆ calibrate()

pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate ( self)
Calibrates the eye tracker.

◆ calibrate_addpoint()

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.

◆ calibrate_clear()

pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_clear ( self)
Clear the internal list of calibration points.

◆ calibrate_delay()

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.

◆ calibrate_reset()

pygaze._eyetracker.opengaze.OpenGazeTracker.calibrate_reset ( self)
Reset the internal list of calibration points to the default
        values.

◆ calibrate_result_summary()

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.

◆ calibrate_show()

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.

◆ calibrate_start()

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.

◆ calibrate_timeout()

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.

◆ camera_size()

pygaze._eyetracker.opengaze.OpenGazeTracker.camera_size ( self)
Returns the size of the camera sensor in pixels, as [w,h].

◆ clear_calibration_result()

pygaze._eyetracker.opengaze.OpenGazeTracker.clear_calibration_result ( self)
Clears the internally stored calibration result.

◆ close()

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.

◆ company_id()

pygaze._eyetracker.opengaze.OpenGazeTracker.company_id ( self)
Returns the identifier of the manufacturer of the connected
        eye-tracker.

◆ enable_send_counter()

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.

◆ enable_send_cursor()

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.

◆ enable_send_data()

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.

◆ enable_send_eye_left()

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.

◆ enable_send_eye_right()

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.

◆ enable_send_pog_best()

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.

◆ enable_send_pog_fix()

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.

◆ enable_send_pog_left()

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.

◆ enable_send_pog_right()

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.

◆ enable_send_pupil_left()

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.

◆ enable_send_pupil_right()

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.

◆ enable_send_time()

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.

◆ enable_send_time_tick()

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.

◆ enable_send_user_data()

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.

◆ get_api_id()

pygaze._eyetracker.opengaze.OpenGazeTracker.get_api_id ( self)
Returns the API version number.

◆ get_calibration_points()

pygaze._eyetracker.opengaze.OpenGazeTracker.get_calibration_points ( self)
Returns a list of the current calibration points.

◆ get_calibration_result()

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.

◆ get_camera_size()

pygaze._eyetracker.opengaze.OpenGazeTracker.get_camera_size ( self)
Returns the size of the camera sensor in pixels, as [w,h].

◆ get_company_id()

pygaze._eyetracker.opengaze.OpenGazeTracker.get_company_id ( self)
Returns the identifier of the manufacturer of the connected
        eye-tracker.

◆ get_product_id()

pygaze._eyetracker.opengaze.OpenGazeTracker.get_product_id ( self)
Returns the identifier of the connected eye-tracker.

◆ get_screen_size()

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].

◆ get_serial_id()

pygaze._eyetracker.opengaze.OpenGazeTracker.get_serial_id ( self)
Returns the serial number of the connected eye-tracker.

◆ get_time_tick_frequency()

pygaze._eyetracker.opengaze.OpenGazeTracker.get_time_tick_frequency ( self)
Returns the time-tick frequency to convert the TIME_TICK
        variable to seconds.

◆ log()

pygaze._eyetracker.opengaze.OpenGazeTracker.log ( self,
message )
Logs a message to the log file. ONLY CALL THIS WHILE RECORDING
        DATA!

◆ product_id()

pygaze._eyetracker.opengaze.OpenGazeTracker.product_id ( self)
Returns the identifier of the connected eye-tracker.

◆ pupil_size()

pygaze._eyetracker.opengaze.OpenGazeTracker.pupil_size ( self)
Return the current pupil size.

◆ sample()

pygaze._eyetracker.opengaze.OpenGazeTracker.sample ( self)

◆ screen_size()

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.

◆ serial_id()

pygaze._eyetracker.opengaze.OpenGazeTracker.serial_id ( self)
Returns the serial number of the connected eye-tracker.

◆ start_recording()

pygaze._eyetracker.opengaze.OpenGazeTracker.start_recording ( self)
Start writing data to the log file.

◆ stop_recording()

pygaze._eyetracker.opengaze.OpenGazeTracker.stop_recording ( self)
Pause writing data to the log file.

◆ time_tick_frequency()

pygaze._eyetracker.opengaze.OpenGazeTracker.time_tick_frequency ( self)
Returns the time-tick frequency to convert the TIME_TICK
        variable to seconds.

◆ tracker_display()

pygaze._eyetracker.opengaze.OpenGazeTracker.tracker_display ( self,
state )
Shows (state=1) or hides (state=0) the eye tracker display
        window.

◆ user_data()

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.

◆ wait_for_calibration_point_start()

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.)

Member Data Documentation

◆ _acklock

pygaze._eyetracker.opengaze.OpenGazeTracker._acklock = Lock()
protected

◆ _acknowledgements

dict pygaze._eyetracker.opengaze.OpenGazeTracker._acknowledgements = {}
protected

◆ _connected

pygaze._eyetracker.opengaze.OpenGazeTracker._connected = Event()
protected

◆ _current_calibration_point

int pygaze._eyetracker.opengaze.OpenGazeTracker._current_calibration_point = None
protected

◆ _debug

pygaze._eyetracker.opengaze.OpenGazeTracker._debug = debug
protected

◆ _debugconsolidatefreq

int pygaze._eyetracker.opengaze.OpenGazeTracker._debugconsolidatefreq = 100
protected

◆ _debugcounter

int pygaze._eyetracker.opengaze.OpenGazeTracker._debugcounter = 0
protected

◆ _debuglog

pygaze._eyetracker.opengaze.OpenGazeTracker._debuglog = open('debug_%s.txt' % (dt), 'w')
protected

◆ _incoming

dict pygaze._eyetracker.opengaze.OpenGazeTracker._incoming = {}
protected

◆ _inlock

pygaze._eyetracker.opengaze.OpenGazeTracker._inlock = Lock()
protected

◆ _inthread

pygaze._eyetracker.opengaze.OpenGazeTracker._inthread
protected
Initial value:
= Thread( \
target=self._process_incoming, \
name='PyGaze_OpenGazeConnection_incoming', \
args=[])

◆ _log_consolidation_freq

int pygaze._eyetracker.opengaze.OpenGazeTracker._log_consolidation_freq = 60
protected

◆ _log_ready_for_closing

pygaze._eyetracker.opengaze.OpenGazeTracker._log_ready_for_closing = Event()
protected

◆ _logcounter

int pygaze._eyetracker.opengaze.OpenGazeTracker._logcounter = 0
protected

◆ _logfile

pygaze._eyetracker.opengaze.OpenGazeTracker._logfile = open(logfile, 'w')
protected

◆ _logging

pygaze._eyetracker.opengaze.OpenGazeTracker._logging = Event()
protected

◆ _logheader

pygaze._eyetracker.opengaze.OpenGazeTracker._logheader
protected
Initial value:
= ['CNT', 'TIME', 'TIME_TICK', \
'FPOGX', 'FPOGY', 'FPOGS', 'FPOGD', 'FPOGID', 'FPOGV', \
'LPOGX', 'LPOGY', 'LPOGV', \
'RPOGX', 'RPOGY', 'RPOGV', \
'BPOGX', 'BPOGY', 'BPOGV', \
'LPCX', 'LPCY', 'LPD', 'LPS', 'LPV', \
'RPCX', 'RPCY', 'RPD', 'RPS', 'RPV', \
'LEYEX', 'LEYEY', 'LEYEZ', 'LPUPILD', 'LPUPILV', \
'REYEX', 'REYEY', 'REYEZ', 'RPUPILD', 'RPUPILV', \
'CX', 'CY', 'CS', \
'USER']

◆ _logqueue

pygaze._eyetracker.opengaze.OpenGazeTracker._logqueue = Queue()
protected

◆ _logthread

pygaze._eyetracker.opengaze.OpenGazeTracker._logthread
protected
Initial value:
= Thread( \
target=self._process_logging,
name='PyGaze_OpenGazeConnection_logging', \
args=[])

◆ _maxrecvsize

int pygaze._eyetracker.opengaze.OpenGazeTracker._maxrecvsize = 4096
protected

◆ _n_logvars

pygaze._eyetracker.opengaze.OpenGazeTracker._n_logvars = len(self._logheader)
protected

◆ _outlatest

dict pygaze._eyetracker.opengaze.OpenGazeTracker._outlatest = {}
protected

◆ _outlock

pygaze._eyetracker.opengaze.OpenGazeTracker._outlock = Lock()
protected

◆ _outqueue

pygaze._eyetracker.opengaze.OpenGazeTracker._outqueue = Queue()
protected

◆ _outthread

pygaze._eyetracker.opengaze.OpenGazeTracker._outthread
protected
Initial value:
= Thread( \
target=self._process_outgoing, \
name='PyGaze_OpenGazeConnection_outgoing', \
args=[])

◆ _sock

pygaze._eyetracker.opengaze.OpenGazeTracker._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
protected

◆ _sock_ready_for_closing

pygaze._eyetracker.opengaze.OpenGazeTracker._sock_ready_for_closing = Event()
protected

◆ _socklock

pygaze._eyetracker.opengaze.OpenGazeTracker._socklock = Lock()
protected

◆ _thread_shutdown_signal

pygaze._eyetracker.opengaze.OpenGazeTracker._thread_shutdown_signal = 'KILL_ALL_HUMANS'
protected

◆ _unfinished

str pygaze._eyetracker.opengaze.OpenGazeTracker._unfinished = ''
protected

◆ host

pygaze._eyetracker.opengaze.OpenGazeTracker.host = ip

◆ port

pygaze._eyetracker.opengaze.OpenGazeTracker.port = port

The documentation for this class was generated from the following file: