You do so by setting a threshold value: a single number below which everything is considered ‘dark’.
Therefore, you will have to tell my software what ‘dark’ actually is. Of course, how dark exactly your pupil is can differ depending on the environment you are in. This makes sense, because your pupil usually is one of the darkest parts of an image of your face (go check for yourself by looking through your Facebook profile pics). Every image that the webcam produces (30 per second!) is analyzed to find the dark bits in the image. My software works in a relatively straightforward way.
Note that the lighting conditions were pretty normal in the current videos: I was simply sitting in my office, with all the lights and two monitors on, without the infrared LEDs that I used for the previous video. As you can see in the video, this pupil enclosure moves along with the pupil, so you don’t have to worry about moving your head. The blue rectangle you see in the screen that says “select pupil and set pupil detection bounds” is the enclosure outside of which no pupil detection is attempted. As you can see, my eyebrows and hair are pretty dark as well, therefore oftentimes falsely recognized as a pupil. This is useful, because the pupil detection is done based on a rather simple principle: “find the largest dark bit in the picture, this must be the pupil!”. The pupil centre is still indicated by the red dot, but now there is the option to only locate a potential pupil inside of a user-defined enclosure. Furthermore, the pupil’s edges (indicated by the green rectangle) are now detected, which means the software can now be used for pupilometry (the science of measuring pupil size).
As you can see, I made quite a bit of progress! A Graphical User Interface (GUI) has been added, to allow users to set their own system up in an easier way (previously, it was done via code and keyboard shortcuts). I’ve added two new videos, showing the current state of the project. All regular lights in my office were off during tracking I used a bunch of infrared LEDs to illuminate my face. The webcam I use is a Trust Cuby model (retail price: 15 Euro), from which I removed the infrared filter. Image analysis is done on the fly, using PyGame. The software is, of course, based on PyGaze. A lot of work needs to be done before this is actually useable, but I’m already quite happy with the results. This video shows the result of my first attempt at pupil tracking.
If you want to play around with the source code, feel free to grab if off GitHub. How hard can it be? Turns out the basics are surprisingly simple! On this page, I’ll try to keep you posted on how the project advances. Building your own eye tracker for dirt cheap.