Reply To: inserting getEyetracker start and stop into the code

PennController for IBEX Forums Support inserting getEyetracker start and stop into the code Reply To: inserting getEyetracker start and stop into the code

#10377
Jeremy
Keymaster

Hi,

Your experiment crashes when it reaches the first trial labeled “eyetracking” because you’re adding Image elements to the eye tracker that are not on the page. In fact, all the elements you add will be mutually exclusively be printed on the page, which is not the kind of setup that the EyeTracker was designed to handle: the elements are supposed to be placed on the page together, at different locations, and the eye tracker tracks which one you are looking at a given time point

Now, you are using a hack to track the (X,Y) coordinates on top, which is what you are interested in, so you should just add one element that will persist on the page, in which you will successively print your four images: that’s a Canvas element

At the beginning of your trial, create that element, and make the Image elements automatically print on it:

newCanvas("imageContainer", 1280, 720)
,
defaultImage.size(1280,720).print(0,0,getCanvas("imageContainer"))

Then before starting the tracker, just print the Canvas element and then add it to the tracker instead of the Image elements:

getEyeTracker("tracker")
    .calibrate(5)
    .log()
,
getCanvas("imageContainer").print("center at 50vw", "middle at 50vh")
,
getEyeTracker("tracker")
    .add( getCanvas("imageContainer") )
    .start()

Once you do that, you do get eye tracking data at your server, e.g. here from my test run

Jeremy