In this post I’ll be describing how I made a head mounted IR camera for tracking where a person is looking. I’ve been working on gettingÂ low-costÂ home brew eye tracking running on my Mac. I want the computer to know where I’m looking on the screen and to be able to interact with my gaze.Â My first attempt uses a head mounted IR camera to determine the pupil position and a second remote camera to detect the head position relative to the screen.
Picture Rachel Chapman.
I was inspired by the OpenEyes project which provides open-source software and hardware forÂ constructingÂ low cost real-time eye tracking. Their hardware designs are focused on mobile eye tracking – that is eye tracking whilst a person is freely moving around. They use two head mounted cameras: a scene camera and an eye camera. I’m only interested in where someone is looking on a fixed screen so I only use one head mounted camera focused on the pupil.
The eye camera
I converted a cheap webcam to be used as the head mounted eye camera. The webcam was modified in two major ways: firstly it was converted into an IR web cam by swapping the infrared filter for an visual light filter; secondly I swapped the standard lens for a telephoto lens. As ever the usual disclaimer applies.
I’m using “dark pupil” tracking which requires an image of the eye under IR light. Under these conditions the pupil is dark andÂ stronglyÂ contrasts with the surrounding iris. I experimented withÂ an old Apple iSight web cam. I had several problems with it Â though. Firstly it was big and heavy so it obscured the user’s view of the screen and was difficult to fix to the head. The iSight has a nice autofocus glass lens, which gives you lovely crisp images. However, the autofocus mechanism would sometimes get confused and would get into cycles of focusing on the eye then trying to focus further away. Since the camera is going to be fixedÂ relativeÂ to the eye a manual focus camera seems more approprate. Note that the focus of the iSight can be set by software using either comercial products like iGlasses or programmatically though IIDC (see iSight Programming Guide).
I bought a manual focus Logitech QuickCam Deluxe. Here’s how I removed the casing and got to the lens:
You just need a Phillips #00 Screwdriver to remove all the screws.
Changing the lens
To get the image of the eye to fill the frame using the regular lens required the camera to be only a few cm from my eye. The close placementÂ obscuredÂ part of my view of the screen and made lighting the eye with the IR LED very challenging. By swapping the webcam lens for a telephoto lens I could position the camera further from the eye solving these two problems – and it only cost $3.25!
I bought a lens with a 12mm focal length for just $3 on eBay. The telephoto lens mount as M12 x 0.5 – this means that the diameter of the barrel of the lens in 12mm – unfortunately the webcam lens had more like an 8mm diameter. The proper lens would have been more expensive so I just spend 25c on some plastic hose with about a 10mm internal diameter. I used a 1cm long piece as a collar to attach the old lens housing (with the elements removed) to the telephoto lens.
With the case off the webcam the CCD detected light that was comingÂ throughÂ the circuit board. To block this light I wrapped it in a layer of plastic wrap, a layer of foil and then another layer of plastic wrap. I then attached two IR LEDs to it and it was ready to be attached to my head mount. I also tried to power the IR LEDs from the webcams “working” LED. I removed the blue surface-mount LED and connected an IR LED. The connections were very fiddly and fragile and LED only shone dimly. I’d not bother if I were to do it again. Instead I’m powering the LEDs from a separate USB port.