Example #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")
Example #2
0
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()
Example #3
0
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()
Example #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()
def main():
    # Configure LSL streams
    lsl_streams = StreamsObj()

    # Create Tobii glasses Controller
    tobiiglasses = TobiiGlassesController("192.168.71.50")

    # Start Streaming
    tobiiglasses.start_streaming()

    print("Please wait ...")
    time.sleep(1.0)

    input("Press any key to start streaming")

    old_time = time.time()
    try:
        while True:

            data = tobiiglasses.get_data()

            if time.time() - old_time > 0.020:  # Send data every 20ms/50Hz
                lsl_streams.sendData('mems', data['mems'])
                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'])

                old_time = time.time()

    except Exception:
        trace = traceback.format_exc()
        print(trace)

    finally:
        tobiiglasses.stop_streaming()
        tobiiglasses.close()
Example #6
0
    ret, frame = cap.read()
    if ret == True:

        height, width = frame.shape[:2]
        data_gp = tobiiglasses.get_data()['gp']
        data_pts = tobiiglasses.get_data()['pts']
        offset = data_gp['ts'] / 1000000.0 - data_pts['ts'] / 1000000.0
        if offset > 0.0 and offset <= frame_duration:
            cv2.circle(frame, (int(
                data_gp['gp'][0] * width), int(data_gp['gp'][1] * height)), 30,
                       (0, 0, 255), 2)
        # Display the resulting frame
        cv2.imshow('Tobii Pro Glasses 2 - Live Scene', frame)

        # Press Q on keyboard to  exit
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # Break the loop
    else:
        break

# When everything done, release the video capture object
cap.release()

# Closes all the frames
cv2.destroyAllWindows()

tobiiglasses.stop_streaming()
tobiiglasses.close()