Example #1
0
}
img_original_path = (
    "C:\\Users\\Coginf\\repos\\tobii_sdk\\imagenet_tree_renew\\128_128\\128_128.png"
)
img_resized_640_path = (
    "C:\\Users\\CogInf\\repos\\tobii_sdk\\imagenet_tree_renew\\640_640\\640_640.png"
)
# Read Images
img_original = Image.open(img_original_path).resize(display_size)
img_size = img_original.size
img_resized_640 = Image.open(img_resized_640_path).resize(display_size)
# Output file
out = []

# Create and Show introduction
win, message1 = features.introduction(display_size)

# Trace eyes
circle = visual.Circle(
    win,
    units="norm",  # [(-1.0, 1.0), (-1.0, 1.0)],
    size=(0.1 / (display_size[0] / display_size[1]), 0.1),
    lineColor=(0, 255, 255),
)

# Start eye tracking
my_eyetracker.subscribe_to(tr.EYETRACKER_GAZE_DATA,
                           gaze_data_callback,
                           as_dictionary=True)

test_image = visual.ImageStim(
found_eyetrackers = tr.find_all_eyetrackers()
my_eyetracker = found_eyetrackers[0]

# Variables
display_size = [1920, 1080]
flag_l = False
flag_r = False

# Output file
out = []

# Show eye tracker settings
features.show_eyetracker(my_eyetracker)

# Create and Show introduction
win = features.introduction(display_size)[0]

# Start eye tracking
my_eyetracker.subscribe_to(tr.EYETRACKER_GAZE_DATA,
                           gaze_data_callback,
                           as_dictionary=True)

while True:
    if len(out) != 0 and len(out) % 300 == 0:
        # When a subject is looking at Left side in 1 seconds
        if flag_l and out[-1][0][0] < 0.5:
            test_image = visual.ImageStim(
                win, image="./images/eye_direction_right.jpg", pos=[0, 0])
            test_image.draw()
            win.flip(clearBuffer=True)