Kinect spells and a camera lap timer: vision before deep learning
Two lab projects from 2011 and 2012: casting spells by drawing shapes in the air with a Kinect, and timing RC car laps with one camera, frame differencing and colour.
In 2011 Microsoft's Kinect could track a person's skeleton in a living room, and the first Windows SDK put that in the hands of anyone with a PC. A year later a cheap PlayStation 3 Eye camera could stream clean video to a desktop. Deep learning hadn't yet reached everyday computer vision. If you wanted a machine to understand a gesture or recognise a car, you wrote the rules yourself.
We built two lab projects in that window. The first was a small C++ engine, ZEngine, whose game idea was casting elemental spells by drawing shapes in the air. The second was a lap timer that watched a remote-control car track through one camera, worked out which car had just passed, and spoke the lap time aloud. Both were lab projects, and both taught us things we still use.
The problem: turning motion into meaning
The Kinect SDK gave us twenty joint positions per tracked person, many times a second, with jitter. It did not give us "this person drew a triangle". The camera gave us a stream of pixels. It did not give us "the red car just completed a lap".
In both cases the hard part was the same:
- deciding when something starts and stops (a gesture, a car passing)
- reducing noisy, continuous input to a few discrete symbols we could reason about
- matching those symbols tolerantly, because no two people draw a square the same way and no two frames are lit the same way
- doing it fast enough that the response felt immediate
Gestures: architecture
Kinect (wrists) | mouse --> stream of points (x, y, time)
-> PatternProcessor: points -> 8 compass directions (N, NE, E ...)
-> Match(): compare direction sequence with recorded patterns
-> spell name: FIRE triangle, EARTH square, WATER w, AIR z - Platform layers. Interfaces (
ILayer) for windows, rendering and pointing devices, with Win32 implementations (XLayer) created through a factory. The Kinect and the mouse were two implementations of the same point-input device, so the recogniser never knew which one it was listening to. - Patterns as data. The shapes lived in a text file, each with several recorded variants, not in code.
The engineering: a recogniser you can train by hand
Pen down, pen up
Air-drawing has no button to press, so we used the other hand. While the left wrist was raised into the top third of the frame, the right wrist was drawing. Points were snapped to a 10-pixel grid, and a new point was recorded only once the hand had moved more than one grid step. That threw away most of the jitter before any recognition happened. Lowering the left hand ended the stroke and handed the points to the recogniser.
From points to directions
Each pair of points became a heading, and each heading became one of eight compass directions. A direction was recorded only when it changed, so a long, wobbly stroke to the right became a single E:
float angle = MathUtil::RadToDeg(MathUtil::atan3((y1-y2), (x1-x2)));
if((angle >= 78.75f) && (angle <= 101.25f) && (lastDirection != DIR_N))
{
directions.push_back(DIR_N);
lastDirection = DIR_N;
}
else if((angle > 101.25f) && (angle <= 168.75f) && (lastDirection != DIR_NE))
{
directions.push_back(DIR_NE);
lastDirection = DIR_NE;
}
// ... six more sectors The windows weren't equal. The straight directions got a narrow 22.5-degree window and the diagonals a wide 67.5-degree one, so a stroke had to be close to straight before it counted as straight. A triangle drawn in the air came out as something like NE, SE, W.
Matching with room for error
The matcher asked one question: do the pattern's directions appear, in order, somewhere in what was drawn? It allowed up to three extra directions, for the wobble at the start of a stroke or a corner taken in two steps:
u32 matchCount = 0;
u32 aIndex = 0;
for(u32 i=0; i<B.size(); i++)
{
eDIR bDir = B[i];
for(; aIndex<aSize; aIndex++) // keep the pattern's order
{
if(A[aIndex] == bDir) { matchCount++; break; }
}
if(matchCount == bSize)
return true;
}
return false; Patterns were sorted longest first, so a square was tried before a shape that might be hiding inside it.
A built-in training mode
The part we are proudest of is the record mode. Switch it on, draw each shape five times, and the processor writes what it saw to a file. The pattern file ended up with nine variants of the square and seven of the triangle, each started from a different corner or drawn in the other direction. We didn't try to write rules for every way a person might draw a triangle. We recorded people drawing triangles.
The lap timer: classical computer vision
The lap timer was a C# Windows app with no vision library at all, just raw byte buffers from the camera.
camera thread -> frame
empty-track image vs frame -> changed tiles -> moving box + average colour
setup: register each new colour as a car
racing: nearest colour -> car -> lap (if past the minimum lap time)
lap -> results grid, spoken time, saved frame (on the thread pool) Tiles, not pixels
We averaged several frames of the empty track into a clean background. Each live frame was compared with it in square tiles. A tile counted as changed only if every pixel in it differed by at least a noise threshold on all three colour channels, and the check stopped at the first pixel that didn't. Most tiles on an empty track failed on the first pixel, so the scan was cheap. Shadows and sensor noise rarely changed a whole tile, so they were ignored. The changed tiles were merged into one bounding box, and anything smaller than a minimum width and height was discarded.
Identity by colour
The average colour of the box identified the car. In setup mode, each new colour that crossed the line became a new car. In racing mode, the timer picked the registered car with the nearest colour. We also wrote RGB-to-HSL conversion and a snap to a small palette (white, black, red, green, blue) while experimenting with lighting.
Two practical guards made it usable. A minimum lap time, five seconds by default, stopped one pass being counted twice as a car crossed the line. And everything slow went to the thread pool: speaking the time from pre-recorded number clips, saving the frame and saving the lap. The capture loop kept up with the camera.
Where AI fits
Both projects were AI in the older, honest sense: perception built from rules and measured thresholds, not learned weights. The skeleton tracking was Microsoft's. The recogniser, the matcher and the vision pipeline were ours.
What carried forward is the process. The record mode was really a data-collection tool: rather than guess what a gesture looks like, gather real examples and let them define it. That's exactly how we treat computer vision now, except the examples train a model instead of filling a text file. The lap timer's lessons matter just as much in a learned system. Control the scene where you can, decide what counts as an event before you measure it, and add guards for the double-count and the bad frame, because no model removes the need for them.
Gestures and cameras also led, many years later, to wearables. Our R&D prototype on Meta Ray-Ban glasses runs Gemma 4 E2B on the paired device through Google AI Edge LiteRT-LM, with no cloud. That's a very different machine, but it's still the same question: what can a device understand about the world in front of it, quickly and locally?
What it taught us
- Lab time pays. Neither project had a client. Both gave us hands-on experience with sensors, noise and real-time limits that we later used on paid work.
- Make the system teachable by non-programmers. Recording a gesture or registering a car by driving it past the camera meant anyone could set it up, not just whoever wrote the code.
- Keep thresholds in configuration. Noise tolerance, tile size, minimum box size and minimum lap time were all settings, so tuning never needed a rebuild.
- Abstract the sensor. Running the recogniser from a mouse meant we could develop and test without standing in front of a Kinect all day.
Why it still matters
Clients often ask whether a problem needs deep learning. Sometimes it does. Sometimes a fixed camera, a clean background and a well-chosen threshold will do the job more cheaply and more predictably, and that's the honest answer. Knowing both lets us choose. Our wearables and edge AI and computer vision pages show where we take this today, and other projects and R&D lists more of our lab work.