2

I am trying to write a program in python that will be able to identify tobii pro nano eye tracker, then calibrate it and , finally, take some gaze data. All done using the help of tobii pro sdk package. According to tobii's step by step guide on how to write the program, calibration is a difficult task and it would be best to call Eye Tracker Manager (another program by tobii) from python in order to let it handle display settings and calibration for you. As a beginner that's what I tried. Tobbi gives information about integrating Python and Eye Tracking Manager in the following link https://www.developer.tobiipro.com/eyetrackermanager/etm-sdk-integration.html. It also gives an example of how to actually call Eye Tracking Manager in Python in the following link https://www.developer.tobiipro.com/python/python-sdk-reference-guide.html. From what I understand you can call Eye tracking Manager in two modes: displayarea (for display area configuration) and usercalibration (to calibrate eye tracker). In my code I implemented tobii's example with some changes (I didn't examine the case of working with anything other than windows cause that's what I am currently working with. I put mode of calibration and eye tracker adress as arguments in call_eyetracker_manager function. I also changed eye tracker manager path in order to fit my case). My code is the following:

def call_eyetracker_manager(address, mode):     
try:
    os_type = platform.system()
    etm_path = ''
    if os_type == "Windows":
        print("Operating System: Windows")
        etm_path = "C:/Users/antho/AppData/Local/Programs/TobiiProEyeTrackerManager/TobiiProEyeTrackerManager.exe"
    # Opens Eye Tracker Manager in calibration mode
    etm_p = subprocess.Popen([etm_path, "--device-address=" + 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:
        print("Eye Tracker Manager was called successfully!")
    else:
        print("Eye Tracker Manager call returned the error code: " + str(etm_p.returncode))
        errlog = None           # Tobii suggests this exact code, so I ignored the warning
        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)

if __name__ == "__main__":
    call_eyetracker_manager(eyetracker.address, "displayarea")      
    call_eyetracker_manager(eyetracker.address, "usercalibration")

And so I called Eye tracker Manager in both display area and calibration modes. (eyetracker.adress is the address of the eye tracker found in another part of the program). Problem is that some times everything works perfectly, Eye tracker Manager is called and a window opens up to help you configure display area and, then perform calibration. However, sometimes Eye Tracker Manager returns error code 44 (EXIT_ERROR_NOT_FOUND). Other times, the program will tell me that eye tracker manager was called successfully but no window will open. And there are also times when the window will just take too long to open up so I stop the program manually. I am really confused with the whole situation and can't seem to find the problem. The fact that there were a lot of times that everything went fine confuses me even more.. Sorry If I said to much. I tried to be as thorough as I could. Can anyone spot the problem?

Pitoguro
  • 21
  • 3

0 Answers0