Howdy, Stranger!

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

Supported by

[open] post-hoc pygaze webcam tracker?

edited February 2015 in PyGaze

Hi there,

I'm wondering if there's any straightforward way to use PyGaze with existing HD videos of faces to get pupil dilation sizes automatically, without using an eye tracker? The videos are 1080p60 and so the pupil size is very easy to manually determine... but I've never used eye tracking before so have no idea if one can automate the measuring without having an eye tracker present that projects an infrared light.

any ideas?
thanks!
Sam

Comments

  • edited February 2015

    Hi Sam,

    Post-hoc image processing is quite possible indeed! You could use the same approach my webcam pupil tracker does, perhaps even by tweaking the code to load images from a video rather than a webcam.

    The approach is as follows:

    1) Set a darkness threshold for the entire image

    2) Use the threshold to binary mask the image (e.g. code 0 for 'darker' and 1 for 'lighter')

    3) Every connected area in the 'darker' category could be the pupil

    4) Indicate the actual pupil by clicking on it

    5) Set the size of the (moving!) window in which the pupil may be detected

    6) Only allow for limited movement of the pupil, so we can be relatively sure that the connected darker area we are currently following is in fact the pupil (and not, for example, an eyebrow)

    Cheers,

    Edwin

  • edited 5:10PM

    Thanks, Edwin! This is exactly what we were hoping for. I wonder: have you tried different lighting setups? Maybe a soft light directed toward the face might be best?

    And this is just from a raw webcam image, right? From what I gather it doesn't require a bunch of infrared lights or anything, which is super elegant. We'll be using a super high quality camera which likely will be able to really differentiate in color between the pupils and hair (for instance).

    Sam

  • edited 5:10PM

    also, one question on the pupillometry: what happens if your head moves toward the camera, but pupil dilation remains constant? does the reported pupil size change? or is it getting the raw size from some immobile face locations like tip of nose or something?

    thanks!
    Sam

  • edited 5:10PM

    Hi Sam,

    For pupil tracking, the lighting is usually best if the participant is not illuminated too much, preferably using a diffuse light source. Directing a light directly towards the face might result in a massive reflection that obscures the pupil.

    The current code does indeed depend on an image from a webcam, which has been converted to a PyGame Surface. So should you want to replace the webcam stream with a video, all you need to figure out is how to convert the images in your video to PyGame Surfaces.

    Regarding your questions on the pupil tracker: If you move closer to the screen, the pupil size will increase. Please note that this is not very sophisticated software, it really just does what I described above. So there's no fancy way of estimating the distance between head and camera. For more info, see this page on my website.

    Cheers,

    Edwin

  • edited 5:10PM

    Thanks, Edwin! Sounds great.

    We have some friends in the vision lab who may be able to add in some face processing algorithms so that we can adjust the pupil size based on forward/backward head movement. If they come up with anything useful I'll let you know!

    Sam

  • edited 5:10PM

    Would be great, thanks!

    BTW: probably good to point out that OpenCV (for which Python bindings are available) has some built-in face detection, if I'm not mistaken.

Sign In or Register to comment.