Esempio n. 1
0
def call_eyetracker_manager_example():
    try:
        os_type = platform.system()
        ETM_PATH = ''
        DEVICE_ADDRESS = ''
        if os_type == "Windows":
            ETM_PATH = glob.glob(
                os.environ["LocalAppData"] +
                "/TobiiProEyeTrackerManager/app-*/TobiiProEyeTrackerManager.exe"
            )[0]
            ETM_PATH = glob.glob(
                "C:/Users/DELL/AppData/Local/Programs/TobiiProEyeTrackerManager/TobiiProEyeTrackerManager.exe"
            )[0]

            DEVICE_ADDRESS = " tet-tcp://*"  # Getting_Started中的 Address: tet-tcp://*
        elif os_type == "Linux":
            ETM_PATH = "TobiiProEyeTrackerManager"
            DEVICE_ADDRESS = "tobii-ttp://TOBII-IS404-100107417574"
        elif os_type == "Darwin":
            ETM_PATH = "/Applications/TobiiProEyeTrackerManager.app/Contents/MacOS/TobiiProEyeTrackerManager"
            DEVICE_ADDRESS = "tobii-ttp://TOBII-IS404-100107417574"
        else:
            print("Unsupported...")
            exit(1)

        eyetracker = tr.EyeTracker(DEVICE_ADDRESS)

        mode = "usercalibration"  # [displayarea|usercalibration|trackstatus]

        etm_p = subprocess.Popen([
            ETM_PATH, "--device-address=" + eyetracker.address,
            "--mode=" + mode
        ],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 shell=False)

        stdout, stderr = etm_p.communicate(
        )  # Returns a tuple with (stdout, stderr)

        if etm_p.returncode == 0:  # Exit codes
            print("Eye Tracker Manager was called successfully!")
        else:
            print("Eye Tracker Manager call returned the error code: " +
                  str(etm_p.returncode))
            errlog = None
            if os_type == "Windows":
                errlog = stdout  # On Windows ETM error messages are logged to stdout
            else:
                errlog = stderr

            for line in errlog.splitlines():
                if line.startswith("ETM Error:"):
                    print(line)

    except Exception as e:
        print(e)
Esempio n. 2
0
def execute(address):
    # <BeginExample>
    import tobii_research as tr

    # address = "tet-tcp://12.13.14.15"
    eyetracker = tr.EyeTracker(address)

    print("Address: " + eyetracker.address)
    print("Model: " + eyetracker.model)
    print("Name (It's OK if this is empty): " + eyetracker.device_name)
    print("Serial number: " + eyetracker.serial_number)

    if tr.CAPABILITY_CAN_SET_DISPLAY_AREA in eyetracker.device_capabilities:
        print("The display area can be set on the eye tracker.")
    else:
        print("The display area can not be set on the eye tracker.")

    if tr.CAPABILITY_HAS_EXTERNAL_SIGNAL in eyetracker.device_capabilities:
        print("The eye tracker can deliver an external signal stream.")
    else:
        print("The eye tracker can not deliver an external signal stream.")

    if tr.CAPABILITY_HAS_EYE_IMAGES in eyetracker.device_capabilities:
        print("The eye tracker can deliver an eye image stream.")
    else:
        print("The eye tracker can not deliver an eye image stream.")

    if tr.CAPABILITY_HAS_GAZE_DATA in eyetracker.device_capabilities:
        print("The eye tracker can deliver a gaze data stream.")
    else:
        print("The eye tracker can not deliver a gaze data stream.")

    if tr.CAPABILITY_HAS_HMD_GAZE_DATA in eyetracker.device_capabilities:
        print("The eye tracker can deliver a HMD gaze data stream.")
    else:
        print("The eye tracker can not deliver a HMD gaze data stream.")

    if tr.CAPABILITY_CAN_DO_SCREEN_BASED_CALIBRATION in eyetracker.device_capabilities:
        print("The eye tracker can do a screen based calibration.")
    else:
        print("The eye tracker can not do a screen based calibration.")

    if tr.CAPABILITY_CAN_DO_MONOCULAR_CALIBRATION in eyetracker.device_capabilities:
        print("The eye tracker can do a monocular calibration.")
    else:
        print("The eye tracker can not do a monocular calibration.")

    if tr.CAPABILITY_CAN_DO_HMD_BASED_CALIBRATION in eyetracker.device_capabilities:
        print("The eye tracker can do a HMD screen based calibration.")
    else:
        print("The eye tracker can not do a HMD screen based calibration.")

    if tr.CAPABILITY_HAS_HMD_LENS_CONFIG in eyetracker.device_capabilities:
        print("The eye tracker can get/set the HMD lens configuration.")
    else:
        print("The eye tracker can not get/set the HMD lens configuration.")
Esempio n. 3
0
    gazeAccThreshold = .5
    stimDir = 'Stimuli'
    eyeTrackingHz = 90
    exp_images = 'exp_images' # in stimDir
    fixIdleThres = 10
    fontColor = (.66,.66,.66)
    lang = ['de', 'en']
    langID = 0 # defaults
    currPhase = 1
    resetRequest = False
    deviceAddress = "tobii-ttp://IS404-100107355222"

win = visual.Window([800,600], screen=0, fullscr=True, color='black')
mouse = event.Mouse()

eyetracker = tr.EyeTracker(cfg.deviceAddress)
 
# quit button 
button_quit = visual.ImageStim(win, image=os.path.join(cfg.stimDir, 'button_quit.png'), size=[.1, .1*win.aspect], pos=[-.90,.90])
button_quit.autoDraw=True;

def toPPnorm(pos):
    '''
    converts tobii's coordinate system
    '''
    pos_temp = copy.deepcopy(pos)

    # Convert between coordinate systems
    pos_temp[:, 0] = 2.0 * (pos_temp[:, 0] - 0.5)
    pos_temp[:, 1] = 2.0 * (pos_temp[:, 1] - 0.5) * -1
    
Esempio n. 4
0
Frequency = IntVar()
Frequency.set(60)
Frequency_1 = Entry(root, textvariable=Frequency, font=('Tahoma', 14), width=8).place(x=158, y=140)

Execution_Time = IntVar()
Execution_Time.set(15)
Execution_Time_1 = Entry(root, textvariable=Execution_Time, font=('Tahoma', 14), width=8).place(x=158, y=200)

count1 = 0
count2 = 0
count3 = 0
kkk = 0

address = Add_tcp.get()
eyetracker = tr.EyeTracker(address)  # 实际使用眼动仪时一定要打开的注释


# 设置初始化参数
def set_up_parameters():
    global Hz, r, eye_time, screen_width, screen_hight, address, small_w, small_h, list_x_img, list_y_img, list_x_mouse, list_y_mouse, dir_Originalimage, count1, count2, count3

    r = 60  # 中央凹半径的1/2
    screen_width = 1920  # 默认眼动仪的自带屏幕分辨率为:1920*1080
    screen_hight = 1080

    Hz = int(Frequency.get())  # 采样频率
    eye_time = int(Execution_Time.get())  # 眼动执行的总时间
    small_w = int(screen_width * 0.5)  # 在界面显示的宽与高
    small_h = int(screen_hight * 0.5)
    #dir_Originalimage = Base_image_add.get()  # 底图的存放地址
Esempio n. 5
0
    t1.start()


def gaze_sample(cmd):
    global gaze_data, gaze_strobe
    gaze_data = []
    gaze_strobe = time.time()
    print("sequence:", sequence)
    time.sleep(cmd["tm1"] + cmd["tm2"])
    gaze_strobe = 0


etrs = tr.find_all_eyetrackers()
for et in etrs:
    print(et.address)
eyetracker = tr.EyeTracker(etrs[0].address)
eyetracker.subscribe_to(tr.EYETRACKER_GAZE_DATA,
                        gaze_callback,
                        as_dictionary=True)  #eyetracker start streaming
#dummy_callback()

#Trigger
sock0 = socket(AF_INET, SOCK_DGRAM)
sock0.bind(('', 5000))  #5000 UDP socket for trigger


def sock0_on_received(msg):
    global sequence, gaze_cmd
    val = eval(msg)
    for k in val:
        gaze_cmd[k] = float(val[k]) * 0.001
Esempio n. 6
0
    print("Subscribing to eye images for eye tracker with serial number {0}.".
          format(eyetracker.serial_number))

    eyetracker.subscribe_to(tr.EYETRACKER_GAZE_DATA,
                            gaze_callback,
                            as_dictionary=True)
    eyetracker.subscribe_to(tr.EYETRACKER_EYE_IMAGES,
                            eye_image_callback,
                            as_dictionary=True)

    # Wait for eye images.
    time.sleep(5)

    eyetracker.unsubscribe_from(tr.EYETRACKER_EYE_IMAGES, eye_image_callback)
    eyetracker.unsubscribe_from(tr.EYETRACKER_GAZE_DATA, gaze_callback)

    print("Unsubscribed from eye images.")

# <EndExample>

eyetracker = tr.EyeTracker('tet-tcp://169.254.5.182')
print("Address: " + eyetracker.address)
print("Serial number: " + eyetracker.serial_number)
execute(eyetracker)

for e in em:
    print("width {}, height {}".format(e.shape, e.shape))

print(len(em))