Esempio n. 1
0
def initEyeGaze():
    """
    Function to create the _stEgControl object and init the 
    EyeGaze system. Exits the program if the init fails.
    """
    import sys

    eyegaze_control = pEyeGaze._stEgControl()

    eyegaze_control.iNDataSetsInRingBuffer = 32
    eyegaze_control.bTrackingActive = False
    # hardcoding display resolution here; for this example only. ;)
    eyegaze_control.iScreenWidthPix = 1280
    eyegaze_control.iScreenHeightPix = 1024
    eyegaze_control.bEgCameraDisplayActive = False
    eyegaze_control.iEyeImagesScreenPos = 1
    eyegaze_control.iVisionSelect = 0
    # Set this reserved variable to 0
    eyegaze_control.iCommType = pEyeGaze.EG_COMM_TYPE_LOCAL

    result = pEyeGaze.EgInit(byref(eyegaze_control))
    if result != 0:
        print "Could not connect to EyeGaze. Error: ", result
        sys.exit(0)

    return eyegaze_control
Esempio n. 2
0
        time.sleep(0.005)

        # we'll use async. mode, getting avail samples
        # and then 'do something else'.
        while eyegaze_control.iNPointsAvailable:
            pEyeGaze.EgGetData(byref(eyegaze_control))
            # assume monocular for this example only. ;)
            sample_data0 = eyegaze_control.pstEgData[0]
            stime = sample_data0.dGazeTimeSec
            current_time = (pEyeGaze.lct_TimerRead(None) / 1000000.0
                            ) - pEyeGaze.EgGetApplicationStartTimeSec()
            delay = current_time - stime
            gaze_x = sample_data0.iIGaze
            gaze_y = sample_data0.iJGaze
            print 'Sample Time: {0}\t{1}\t{2}\tX: {3}\tY: {4}\ti: {5}'.format(
                stime, current_time, delay, gaze_x, gaze_y, samples_rx)
            samples_rx += 1
            if samples_rx > MAX_SAMPLES:
                break

    rec_end = timeit.default_timer()

    # stop recording
    eyegaze_control.bTrackingActive = False

    # Exit the lcteg system
    result = pEyeGaze.EgInit(byref(eyegaze_control))

    dur = rec_end - rec_start
    print 'Collected {0} samples in {1} seconds. {2} SPS'.format(
        samples_rx, dur, samples_rx / dur)