Beispiel #1
0
def main():

    #Configure LSL streams
    lsl_streams = StreamsObj()

    #Create Tobii glasses Controller
    tobiiglasses = TobiiGlassesController("192.168.71.50")
    print("Sampling frequency: ", tobiiglasses.get_et_freq())
    print(tobiiglasses.get_battery_status())

    #Calibrate
    # calibration(tobiiglasses)

    #Start Streaming
    tobiiglasses.start_streaming()
    print("Please wait ...")
    time.sleep(3.0)

    input("Press any key to start streaming")

    current_gidx = -9999

    startTime = time.time()
    old_time = time.time()
    time.sleep(0.1)
    try:
        while True:

            data = tobiiglasses.get_data()

            #Send data to LSL only there is a new data point
            if current_gidx < data['gp']['gidx']:
                current_gidx = data['gp']['gidx']
                print(data['gp'])
                #Send data
                lsl_streams.sendData('left_eye', data['left_eye'])
                lsl_streams.sendData('right_eye', data['right_eye'])
                lsl_streams.sendData('gp', data['gp'])
                lsl_streams.sendData('gp3', data['gp3'])

                #Print Battery status
                # print(tobiiglasses.get_battery_status())

            if time.time() - old_time > 0.02:  #Send data every 20ms
                lsl_streams.sendData('mems', data['mems'])
                old_time = time.time()

    except Exception as e:
        print(e)
        print("Closing Tobii")
        trace = traceback.format_exc()
        print(trace)

    finally:
        file.close()
        tobiiglasses.stop_streaming()
        tobiiglasses.close()

    print("Closing programme")
def main():

    tobiiglasses = TobiiGlassesController()
    print tobiiglasses.get_battery_status()

    tobiiglasses.start_streaming()

    raw_input("Press a key to start streaming (1000 samples will be shown)")

    for i in range(1000):
        print "Head unit: %s" % tobiiglasses.get_data()['mems']
        print "Left Eye: %s " % tobiiglasses.get_data()['left_eye']
        print "Right Eye: %s " % tobiiglasses.get_data()['right_eye']
        print "Gaze Position: %s " % tobiiglasses.get_data()['gp']
        print "Gaze Position 3D: %s " % tobiiglasses.get_data()['gp3']

    tobiiglasses.stop_streaming()
    tobiiglasses.close()
def main():

    tobiiglasses = TobiiGlassesController("192.168.71.50")
    print(tobiiglasses.get_battery_status())

    #Get the bounds of the viewable range
    print("Enter x upperbound:")
    x_upper = float(input())

    print("Enter x lowerbound:")
    x_lower = float(input())

    print("Enter y upperbound:")
    y_upper = float(input())

    print("Enter y lowerbound:")
    y_lower = float(input())

    print("Enter time to run in seconds:")
    tt = int(input())

    tobiiglasses.start_streaming()
    print("Please wait ...")
    time.sleep(3.0)

    for i in range(tt):
        time.sleep(1.0)
        # 		print("Head unit: %s" % tobiiglasses.get_data()['mems'])
        # 		print("Left Eye: %s " % tobiiglasses.get_data()['left_eye'])
        # 		print("Right Eye: %s " % tobiiglasses.get_data()['right_eye'])
        # 		print("Gaze Position: %s " % tobiiglasses.get_data()['gp'])

        x_pos = tobiiglasses.get_data()['gp']['gp'][0]
        y_pos = tobiiglasses.get_data()['gp']['gp'][1]

        print("Test number %s " % i)
        print("X Position: %s " % x_pos)
        print("Y Position: %s " % y_pos)

        #if out of bounds in the x axis
        if (x_pos > x_upper or x_pos < x_lower):
            print('X out of bounds')
            print('\a')  #makes a beeping noise
        elif (y_pos > y_upper or y_pos < y_lower):
            print('Y out of bounds')
            print('\a')  #makes a beeping noise
        else:
            print('In bounds')

        print("Gaze Position 3D: %s " % tobiiglasses.get_data()['gp3'])

    tobiiglasses.stop_streaming()
    tobiiglasses.close()
Beispiel #4
0
def main():

    tobiiglasses = TobiiGlassesController("192.168.71.50")
    print(tobiiglasses.get_battery_status())

    tobiiglasses.start_streaming()
    print("Please wait ...")
    time.sleep(3.0)

    for i in range(1000):
        print("Head unit: %s" % tobiiglasses.get_data()['mems'])
        print("Left Eye: %s " % tobiiglasses.get_data()['left_eye'])
        print("Right Eye: %s " % tobiiglasses.get_data()['right_eye'])
        print("Gaze Position: %s " % tobiiglasses.get_data()['gp'])
        print("Gaze Position 3D: %s " % tobiiglasses.get_data()['gp3'])

    tobiiglasses.stop_streaming()
    tobiiglasses.close()