About finding pupil in a video

痞子三分冷 提交于 2019-12-03 03:41:55

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 -

You can use OpenCV then to threshold.

Then use the Erode function.

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

Eliminate the holes and invert the image.

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

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

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.)

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

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..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!