About finding pupil in a video

3k views Asked by At

I am now working on an eye tracking project. In this project I am tracking eyes in a webcam video (resolution if 640X480).

I can locate and track the eye in every frame, but I need to locate the pupil. I read a lot of papers and most of them refer to Alan Yuille's deformable template method to extract and track the eye features. Can anyone help me with the code of this method in any languages (matlab/OpenCV)?

I have tried with different thresholds, but due to the low resolution in the eye regions, it does not work very well. I will really appreciate any kind of help regarding finding pupil or even iris in the video.

Sample image

4

There are 4 answers

0
Luke On

If you're still working on this, check out my OptimEyes project: https://github.com/LukeAllen/optimeyes

It uses Python with OpenCV, and works fairly well with images from a 640x480 webcam. You can check out the "Theory Paper" and demo video on that page also. (It was a class project at Stanford earlier this year; it's not very polished but we made some attempts to comment the code.)

9
vaebnkehn On

Depending on the application for tracking the pupil I would find a bounding box for the eyes and then find the darkest pixel within that box.

Some psuedocode:

box left_location = findlefteye()
box right_location = findrighteye()
image_matrix left = image[left_location]
image_matrix right = image[right_location]
image_matrix average = left + right
pixel min = min(average)
pixel left_pupil = left_location.corner + min
pixel right_pupil = right_location.corner + min
2
Anirudh On

What you need to do is to convert your webcam to a Near-Infrared Cam. There are plenty of tutorials online for that. Try this.

A Image taken from an NIR cam will look something like this -

enter image description here

You can use OpenCV then to threshold.

enter image description here

Then use the Erode function.

enter image description here

After this fill the image with some color takeing a corner as the seed point.

enter image description here

Eliminate the holes and invert the image.

enter image description here

Use the distance transform to the nearest non-zero value.

enter image description here

Find the max-value's coordinate and draw a circle.

enter image description here

0
Aditya Byreddy On

In the first answer suggested by Anirudth...
Just apply the HoughCirles function after thresholding function (2nd step).
Then you can directly draw the circles around the pupil and using radius(r) and center of eye(x,y) you can easily find out the Center of Eye..