79 lines
4.4 KiB
Markdown
79 lines
4.4 KiB
Markdown
# Calibration guide
|
|
|
|
The virtual Kinect needs a one-time calibration so the player-space scale, the depth placement,
|
|
and the mirror orientation match your room and camera mount. The logic lives in
|
|
`core/calibration/` (`calibration.h` / `calibration.cpp`), which computes, persists, and
|
|
reload-tests a `CalibrationConfig`.
|
|
|
|
> **Current limitation: not yet wired into runtime.** `core/calibration/` produces and reloads a
|
|
> config file, and that round-trip is unit-tested, but no runtime surface reads it back yet.
|
|
> Today the tracker places depth using a hard-coded default origin, `DEFAULT_Z0_METERS = 2.5`
|
|
> (`tracker/joint_mapping.py`), regardless of what you calibrate. Running the steps below exercises
|
|
> and validates the calibration math and writes a real config file, but it does not yet change what
|
|
> the running tracker, OpenNI2 driver, USB emitter, or Windows shim do at runtime. Wiring the saved
|
|
> config into those startup paths is a known pending step.
|
|
|
|
Calibration is two short poses: a **mirror-confirm** (raise one arm) and a **T-pose** (arms out).
|
|
Both are read from the live tracker's pose output; no extra tool is needed beyond the running
|
|
tracker.
|
|
|
|
## Why calibrate
|
|
|
|
- **Scale.** A single webcam has no absolute size. The T-pose shoulder span fixes the player-space
|
|
scale so your body maps to roughly Kinect-sized skeleton coordinates. The target shoulder width
|
|
is 0.40 m (`kTargetShoulderWidthMeters`).
|
|
- **Depth placement (Z0).** Your standing distance from the camera becomes the depth origin, so the
|
|
synthetic depth sits in the Kinect's valid band instead of pegging at a floor value. Z0 is clamped
|
|
to the Kinect's usable range, 0.8 m to 4.0 m.
|
|
- **Mirror.** A raw camera image is left/right flipped relative to how a Kinect presents the scene.
|
|
The mirror flag makes your anatomical right arm land where the host tracker and the game expect
|
|
it. Getting this wrong is the most common "my moves are inverted" bug (see troubleshooting).
|
|
|
|
## Step 1: mirror confirm (raise your right arm)
|
|
|
|
Stand facing the camera and raise **only your anatomical right arm**, left arm down.
|
|
|
|
`confirm_mirror_raise_right_arm()` checks that exactly the right arm is up (right wrist above the
|
|
right shoulder, left wrist at or below its shoulder). It then sets the global `mirror` flag from
|
|
where that raised arm appears horizontally in the image: if the raised arm shows up on image-left,
|
|
the feed is mirrored and the flag is set so downstream consumers flip it back.
|
|
|
|
If the check fails it returns an error ("mirror confirmation requires only the right arm raised");
|
|
lower your left arm fully and raise only the right, then retry.
|
|
|
|
## Step 2: T-pose (arms straight out)
|
|
|
|
Stand at your normal playing distance and hold a **T-pose**: both arms straight out to the sides,
|
|
level with your shoulders, facing the camera, whole body in frame.
|
|
|
|
`calibrate_tpose()` reads one `TposeObservation`:
|
|
|
|
- `person_detected` must be true (one clean detection),
|
|
- `root_depth_meters` becomes the clamped Z0 depth origin,
|
|
- `normalized_shoulder_width` sets `player_scale` so your shoulders map to 0.40 m,
|
|
- `floor_plane` carries the floor estimate through unchanged,
|
|
- `mirror` comes from step 1.
|
|
|
|
It produces a `CalibrationConfig` (mapping intrinsics, smoothing parameters, player scale, floor
|
|
plane). Invalid or non-finite inputs (no person, zero shoulder width) fail with a clear error
|
|
rather than writing a bad config.
|
|
|
|
## Step 3: save and reuse
|
|
|
|
`save_config()` writes the calibration to a plain-text key/value file; `load_config()` reads it
|
|
back, and this save/reload round-trip is covered by tests. **No runtime surface loads this file
|
|
yet** - the tracker, the OpenNI2 SynthKinect driver, the USB emitter (`core/protocol`), and the
|
|
`Kinect10.dll` shim do not call `load_config()` on startup today; the tracker instead uses the
|
|
hard-coded `DEFAULT_Z0_METERS = 2.5` for every session. Once that wiring lands, all of those
|
|
surfaces are expected to consume the same saved file so you calibrate once and every path agrees.
|
|
|
|
Recalibrate when you move the camera, change your playing distance, or switch rooms (once wired
|
|
into runtime, below). The mirror step is worth repeating any time left/right feels wrong in a game.
|
|
|
|
## Tips
|
|
|
|
- Calibrate in the lighting you will play in; poor light degrades the pose estimate the calibration
|
|
is built from.
|
|
- Keep your whole body in frame for the T-pose; a cropped arm skews the shoulder-span scale.
|
|
- If moves still invert after a clean T-pose, redo step 1. Mirror is the usual culprit, not scale.
|