Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] AttributeError: 'module' object has no attribute 'sample'

edited February 2015 in PyGaze

Hi,

I'am working on a gaze-contingent project and was really happy to read that PyGaze can help me because I just begin to use Python. But I have troubles with the following code which I created to achieve my purpose :

# create display object
disp = libscreen.Display()

# create eyetracker object
tracker = eyetracker.EyeTracker(disp)

def Affichage_glob(image, score):
    window.fill(bg_col)
    gaze_contingent()
    face(image)
    pygame.display.flip()
    ti_0 = datetime.datetime.fromtimestamp(time.time())
    pygame.time.wait(1000)
    window.fill(bg_col)
    scale()
    he, we = scale()
    arrow(he, we, score)
    pygame.display.flip()
    ti_1 = datetime.datetime.fromtimestamp(time.time())
    ti_2 = time.time()
    pygame.time.wait(30)
    return ti_0, ti_1, ti_2


trou = pygame.image.load('trou.png')
wg, hg = trou.get_size()

def gaze_contingent():
    x, y = eyetracker.sample()
    window.blit(trou, [- wg/2+c_x, - hg/2+c_y])
    pygame.display.flip()

I obtain the following error message :

  File "F:\Programme_python\gaze_contingent.py", line 320, in <module>
    ti_0, ti_1, ti_2 = Affichage_glob(image, score)
  File "F:\Programme_python\gaze_contingent.py", line 216, in Affichage_glob
    gaze_contingent()
  File "F:\Programme_python\gaze_contingent.py", line 272, in gaze_contingent
    x, y = eyetracker.sample()
AttributeError: 'module' object has no attribute 'sample'

Can you explain to me why, and how to solve it ?

Many thanks for your help !

Comments

  • edited February 2015

    I am very sorry for my stupid question, I just forgot to switch the DUMMYMODE from False to True...
    But I have now a new error :

      File "F:\Programme_python\tobii\eye_tracking_io\__init__.py", line 5, in <module>
        from tobii.eye_tracking_io._native import tetio, BoundHandler
      File "F:\Programme_python\tobii\eye_tracking_io\_native\__init__.py", line 6, in <module>
        import _tetiopy27
    ImportError: No module named _tetiopy27
    

    I have looked for that module in internet but found nothing.

  • edited 5:12PM

    Hi,

    Actually, your first error did not arise from not using DUMMYMODE. In dummy mode, you should still be able to get samples (the mouse serves as a simulated eye tracker).

    What did cause the error, is that you use eyetracker.sample rather than tracker.sample. The former refers to the entire module eyetracker, whereas the latter refers to the instance tracker (which is the one you want to use to get samples).

    Additionally, you seem to be mixing PyGame with PyGaze functions, which is not necessarily wrong, but it kind of defeats the purpose of PyGaze providing you the same functionality without directly having to use PyGame (you can opt for a PsychoPy back-end as well).

    Finally, the import error suggests that you might not have installed the Tobii SDK properly. The weird path ("F:\Programme_python\tobii") seems to suggest the same thing. Usually, installed modules should go to the site-packages directory of your Python installation.

    Good luck!

    Edwin

  • Hi,

    thanks for your answer !

    I don't understand in this case why in the example files shooting_game.py there is eyetracker.sample()... (line 60) what is the difference with what I am doing ?

    I have written all my code, in the perspective to take measures by the Eye-Tribe, when we realize that the Eye-Tribe was not the better device for our work and that adding a gaze-contingent function will be great... That's only at that time I discover Pygaze. It take me a very long time, I hope I wont have to rewrite everything.

    I have all uninstall and reinstall, that's ok now.

    But I have a new problem : my program start, I have a message "Start calibration" and a window with a light brown fond color and a green circle appear. Then, it freeze and nothing else append.
    I have the same problem when I try to run simple_tracker_experiment.py.
    I have check the eye-tracker, the calibration can be done well with the TobiiStudio.

    Marie

  • Sorry, I forgot to give you the error message about my last problem :

    Traceback (most recent call last):
    File "F:\Programme_python\simple_tracker_experiment.py", line 49, in
    tracker.calibrate()
    File "C:\Python27\lib\site-packages\pygaze\libtobii.py", line 211, in calibrate
    self.disp.fill(self.screen)
    AttributeError: 'str' object has no attribute 'fill'

Sign In or Register to comment.