headtracking Version française

How headtracking works

A camera on the cabinet watches the player. The plugin works out where that camera is from the cabinet itself, finds your head in each image, turns it into a position in millimetres, and moves the Visual Pinball X point of view to match.

The fish-tank effect

When you move your head in front of a real pinball machine, you see the playfield from a slightly different angle: near objects shift more than far ones. headtracking reproduces that on a screen. Visual Pinball X has a Window view layout designed for this: the screen becomes a fixed window into the cabinet, and as your head moves, the plugin moves the viewpoint so the 3D table stays in place behind the glass.

Calibration from the cabinet itself

To turn a head seen in an image into a real position, a program needs to know where the camera is and how it sees (its focal length). Most setups ask you to measure or to go through a calibration routine. headtracking uses what every cabinet already has: the lockbar and the two side rails.

Lockbar outlined by a box and side rails marked by lines on a real cabinet
The detection on a real cabinet: lockbar (box) and side rails.
Camera view from the backbox with four traced lines along the lockbar and side rails and their intersection points
The reference frame traced on a capture: the lockbar's two edges, the two side rails and their six intersection points.

Finding your head

The head is found by BlazePose, a body-pose model that runs in a few milliseconds per image. It finds the head, the shoulders and the wrists at once, including on infrared images. It is a body detector, not a face detector: a face detector loses track as soon as you lean over the playfield and the camera only sees the top of your head. The flip side is that your bust (head and shoulders) must be in the picture.

Measuring the distance

See choosing a camera for the practical differences.

Inside Visual Pinball X

The demo app

Each release also contains headtracking-demo, a standalone program that needs no VPX. It shows the camera picture with what the detection sees, lets you set the lockbar width and the playfield incline, and opens a 3D parallax window where moving your head moves the scene, a quick way to judge the tracking. It also offers a one-click fix when a Kinect is plugged in but cannot be opened, and the 🎁 Contribute button that shares a capture of your cabinet.

Everything in one plugin

The Kinect libraries (libfreenect and libfreenect2), libjpeg-turbo and the ONNX runtime that runs the neural networks are built into the plugin, and the models are embedded in the program. There is no Microsoft Kinect SDK and no Python to install. The whole project is written in Rust; CLAUDE.md describes the architecture for developers.