How To Build Your Own IR Head Tracker


With all the recent hubbub about Microsoft’s Kinect and Sony’s PlayStation Move, you’d be excused for thinking that motion control is some new phenomenon. In reality, it’s a technology that’s been around on the PC for years. Head tracking allows you to control your PC with your head. Mostly used in sim games, head tracking lets you move and tilt your head to control where your character looks. There are, of course, some excellent commercial head-tracking systems available, but it’s possible (thanks to free software called FreeTrack) to build your own head tracker with just a webcam and a few dollars worth of electrical supplies. We’ll show you how.

How It Works

From a hardware standpoint, a head tracker is remarkably simple. It’s composed of two parts: a webcam and an array of lights, worn on the head. The camera filters out everything it sees except for the array of lights, and the FreeTrack software interprets the positions of these points of light so that it can tell where your head is facing. It sounds a little complicated, but makes perfect sense when you see it in motion. Here’s an example:

(Image A)

Here, a V-shaped, three-light array is worn on the side of the head (image A). When facing forward, it forms a straight vertical line of lights. As seen by the webcam (image B), the same array is turned to the right, moving the lights out of alignment.

(Image B)

Not so complicated, right? Here’s what you need:

The Webcam

First, you need a webcam. Most modern webcams will work, but what you really want is one that has a high frame rate, low CPU usage, and an auto-exposure function that can be turned off. Note that we didn’t mention high resolution—you don’t actually need anything more than 320x240. So if your camera lets you turn down the resolution and get a higher frame rate, that’s a plus.

You can find a list of webcams that have been successfully used with FreeTrack here . For our build, we went with the PlayStation 3 Eye (image C). There are some great reasons to use it (it’s a high-quality, super–high frame rate camera that doesn’t cost a lot. But we had an even better reason—we already have one, modified to see only infrared light. If you remember when we built the multitouch surface computer , you’ll recall that we had great luck using the PlayStation 3 Eye, so we’re going to use it again.

(Image C)

What’s that, you say? You don’t already have a modified webcam? Well, don’t worry, there are plenty of resources that will help you modify your camera. The link for the FreeTrack Forum above has info about how to modify a webcam, and if you decide to go with the PlayStation 3 Eye, you can check out our very own illustrated guide to turning it into an IR camera here .

The Point Model

Once your camera is ready to go, it’s time to get started on the point model. The point model is the gear that will, one way or another, let your computer see (via the webcam) which direction your head is pointed. There are a lot of ways to make a point model.

The simplest is a single point of light—an LED or a reflector attached to your head. This is enough to allow the computer to calculate your head’s location along two axes. When you look up, the point of light moves up, when you look right it moves right, and so forth.

However, if we’re going to all the trouble of strapping some lights to our head, we might as well get a full three degrees of precision out of it. By upgrading from a single point to a three-point model, FreeTrack gains the ability to determine your head’s position and rotation about the Z axis—in addition to being able to tell when you’re looking right or left, and up or down, it can also tell when you move and cock your head.

For a three-point model, you can either use a “clip” model, in which the three points are arranged in a lopsided V shape, and attached vertically to a headset (image A), or a hat model, where one point is placed on top of a baseball cap or visor, and two are placed along the rim. Whichever one you want to go with is really up to you. We chose to go with the clip model because we usually wear a headset while gaming.

The Light Source

Now that you’ve decided on a configuration for your point model, you need to pick a light source. Your two choices here are infrared LEDs (image D) and reflectors. The advantage to LEDs is that because they emit a ton of infrared light, your webcam will have no trouble isolating the three points. The downside is that they have to be powered, meaning you’ll have a battery pack attached to your body somewhere. Reflectors are popular, because they don’t require a battery pack. However, they require significant illumination to function, so you’ll need to shine a bright array of eight or more IR LEDs on them, preferably from a source near your webcam.

(Image D)

For their consistency, and because we don’t mind keeping track of a battery pack with a single triple-A battery, we chose to use IR LEDs. Of all the infrared LEDs available, the SFH485P model is the most recommended, for its wavelength and viewing angle. We happened to have some on hand (again, from the Surface Computer) but you can find them for well under a dollar apiece at online electronics dealers like Digi-Key .

Some people swear up and down that you need a resistor any time you’re building an LED into a circuit. It so happens that the forward voltage drop of the SFH485P is 1.5V, same as a standard battery, so it’s possible that you can get away without one. If you want to play it safe, you can find a very handy resistor calculator here .

Building the Point Model

(Image E)

How you actually put your lights together into a point model is up to you. The optimal shapes for both clip- and hat-type point models are described here but the actual materials you use to construct them can include almost anything. For maximum thriftiness, we built ours out of the tubes of three basic Bic pens and a paperclip (image E). We simply cut the pen tubes to the right length (according to the diagram linked above), drilled holes for the wires, and glued the whole thing together. Then, we glued the clip on the back to hold the lights to a headset (image F). Is it beautiful? Hell, no. But it gets the job done, costs next to nothing, and makes us feel like MacGyver every time we wear it.

(Image F)

For lots more examples of how a completed point model looks, check out this page .

The Software

For this section of the how-to, we’re going to assume that, like us, you are using a PlayStation 3 Eye camera. If so, you’ll need to install a custom driver for the camera before anything else, as Sony hasn’t released official Windows drivers for it. You can download the custom driver here .

Installation is as easy as running the executable (making sure that your camera isn’t plugged in beforehand), and telling Windows it’s all right to install this unsigned driver. Afterward, plug in the camera, and you should see Windows recognize it as a PlayStation 3 Eye (image G). To make sure that everything’s working fine, you can run the program called CL-Eye Test that came with the driver. You can also use this program to see what your point model looks like through the camera and make sure everything’s working.

(Image G)

After installing the driver software for the camera, you can install FreeTrack itself. The latest version is available at .

If you’re using the PS3 Eye, don’t run FreeTrack after installing it. First, you have to download the hack file and extract it to your FreeTrack folder. If you already ran FreeTrack, just uninstall it and reinstall, then apply the fix.

Finally, you’re ready to launch Free-Track. If you’re running Windows 7, you’ll have to run the program as an administrator, or else it can’t access your webcam. To run it as an administrator, just right-click the FreeTrack executable, and choose Run as Administrator (image H).

(Image H)

When you launch FreeTrack, you’ll need to make some major settings tweaks. First, click the Model button in the upper right corner and choose the type of point model you built. Next, go back to the Cam window and click the Source drop-down and select your webcam. Now, click the Start button and you’ll begin to see a live preview of FreeTrack’s point detection, which will help you perform the rest of your calibration. Clicking the Camera button will show you some camera-specific options including gain and exposure, which you can adjust to increase how bright your point model will appear (at the expense of adding noise).

Back at the main window, look at the Threshold slider. This sets the brightness cutoff for the point detection. What you want to see are three steady circles, and nothing else. If you see extra speckles or noise on the screen, adjust the slider to the right. If any of the three circles are flickering, adjust it to the left. If you can’t get three steady circles, consider going back and adjusting the exposure and gain again, or reducing sources of environmental IR light by turning off overhead lights.

Move on to the next tab, labeled Framerate. By default, this is set to 30fps. The best feature of the PS3 Eye is its amazing frame rate, so if you’ve got it, bump the fps up to 120. The multiplier should automatically reduce to 1. This will make the head tracking noticeably more responsive.

(Image I)

The next tab, Point Size, lets you set constraints on what the program will consider when it’s looking for points. For instance, if you can tell by looking at the preview window that your points tend to be in the 10–20 pixels wide range, then you should set the minimum point size up higher than the default of 2 pixels. Setting the minimum pixel size higher will reduce lag, so set it as high as you can without causing the program to lose track of the real points.

In the Global Settings menu, you can change the sensitivity of FreeTrack’s movement axes. Leave these alone for now, but you’ll probably find yourself wanting to come back and adjust these once you’ve played a few games.

FreeTrack should now be working as advertised—the 3D skull in the FreeTrack window should smoothly mirror the movements of your head in real time (image I). We can finally get into the games.

The Games

There are three ways that a game can support FreeTrack. First, the game can support FreeTrack natively. There’s actually only one game that does this, but it’s a doozy: Arma 2. The high-water mark for soldiering sims, Arma 2 takes excellent advantage of FreeTrack head tracking, allowing you to look around, lean, and zoom in or out by moving and turning your head.

Even if a game doesn’t support FreeTrack directly, you can still make it work. Many sim and racing games support TrackIR, a commercial head-tracking package from NaturalPoint. FreeTrack can emulate TrackIR, so it works with most TrackIR-compatible games (for a list, see here ). Recently, NaturalPoint has started encrypting the TrackIR software, specifically to break compatibility with FreeTrack.

How you set up FreeTrack with a game is different for every game, of course, but generally you’ll find the option somewhere in the control-settings menu (image J).

(Image J)

Even if a game doesn’t support Free-Track or TrackIR natively, it’s still possible to incorporate head tracking. In the Controls menu, under the Main tab, you can see the different control options available using FreeTrack. Below the FreeTrack and TrackIR options, you can see an unchecked box labeled Mouse. Enabling this option allows you to control your mouse with FreeTrack. Obviously, you’re not going to want to play shooters with this kind of head tracking, but it can work for some other types of games. In the controls menu there’s also a tab marked Keyboard, which allows you to bind head movements to keystrokes, giving you yet another option for controlling games with head tracking.

It can take a little finagling to find the combination of control setup and sensitivity options that works for you, but once you do, you won’t want to go back.

Around the web

by CPMStar (Sponsored) Free to play