Files
kinect/tracker
kinect-botandsisyphus-dev-ai c08bc922b6 feat(tracker): add Linux cursor calibration, matching the Windows flow exactly
"the cursor scaling is still wrong, make it like the windows one" - the
Linux tracker had no way to calibrate at all. The in-game cursor's arm-reach
gains (default 3.2/2.6) were tuned specifically for the native Windows
tracker's camera/pose characteristics via its "Calibrate cursor" button
(core/calibration.h's derive_arm_gains); Linux users were stuck on that
default regardless of their own camera/body, with no equivalent tool.

tracker/calibration.py is a byte-for-byte port of core/calibration.h's
arm-gain derivation (mean(|reach|) -> target/mean, clamped [1,6]) and the
calibration.cfg text format load_config()/save_config() share, so a config
written by either side is read identically by the shim - not a
reimplementation that happens to produce similar numbers, the same formula
and the same wire format, verified against tests/test_calibration.cpp's own
cases (averaging, diagonal-gesture success, horizontal-only rejection,
clamp-to-min, save/reload round-trip) ported 1:1 into
tests/test_calibration_py.py - 6/6 passing, plus the existing tracker suite
still 11/11.

tracker.py gets a --calibrate mode (calibrate_cursor()): mirrors each frame
for pose inference exactly like the main loop, computes Kinect joints with
mirror=False, and reads HAND_LEFT (index 7) minus SHOULDER_LEFT (index 4) -
the slots the player's actual right arm lands in post-mirror, pre-shim-swap,
matching exactly where win_main.cpp's CalibrateCursor() reads
skeleton.joints[7]/[4] (verified by reading that function directly). Usage:
nix run .#tracker -- --calibrate --source 0.

docs/calibration.md and docs/linux-wine.md document the Linux flow, the
Linux default config path (no %LOCALAPPDATA% equivalent - XDG config dir),
and that KINECT_SHIM_CONFIG must be set explicitly in both the calibration
tool's environment and the game's launch options (Wine or Proton) so they
agree on one file - the same pattern already established for
KINECT_SHIM_SHM_FILE.

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
2026-11-30 12:53:45 -05:00
..

tracker/ — webcam pose + segmentation tracker (plan todo 5)

Python pipeline: OpenCV capture (webcam or video file) → MediaPipe Pose Landmarker (33 normalized landmarks + 33 world landmarks in metres + per-landmark visibility + segmentation mask) → published to the frozen shared-memory IPC contract (tracker/contract.py, mirror of core/contract/contract.h) at the newest-wins slot each frame, plus a control-plane handshake/heartbeat.

Layout

file role
pose.py PoseResult, PoseProvider seam, MediaPipePoseProvider (Tasks API, VIDEO mode)
publisher.py FrameContractPublisher — shared-memory triple-buffer producer (seqlock publish)
control.py handshake + heartbeat control plane over a unix socket
tracker.py capture + background inference + monotonic-clock publish loop + CLI
fake_pose.py synthetic providers/sources that drive the data path without MediaPipe

Design (satisfies the plan's MUST-NOTs)

  • Inference never blocks the publish path. Capture + inference run on a background thread and cache the latest (frame, PoseResult); the publish loop publishes whatever is latest, re-publishing the previous pose when inference is slower than the cadence.
  • No fixed sleeps. The publish loop paces to a monotonic frame clock (deadline = start + n·period) and waits exactly until the next deadline.
  • Scope boundary. The 20 contract joints are a provisional pass-through of the raw MediaPipe world landmarks, and the depth buffer is a flat mask→silhouette placeholder. The real MediaPipe-33 → Kinect-20 mapping (todo 6) and the articulated synthetic-depth rasterizer (todo 7) replace these; todo 5 owns only moving a pose through the contract at a steady cadence.

Environment setup (this host: Python 3.14, no sudo/apt-install)

The system Python is 3.14, which has no MediaPipe wheel, and python3-venv's ensurepip is missing. The working route is user-space uv:

pip install --user --break-system-packages uv
export PATH="$HOME/.local/bin:$PATH"
uv python install 3.12
uv venv --python 3.12 tracker/.venv
uv pip install --python tracker/.venv numpy pytest opencv-python-headless mediapipe

Installed here: Python 3.12.16, numpy 2.5.5, opencv-python-headless 5.1.0, mediapipe 1.2.3.

MediaPipe model bundles

mediapipe ≥ 1.x ships only the Tasks API (no legacy mp.solutions.pose); it loads a .task bundle. Download the tiers into tracker/models/ (git-ignored):

base="https://storage.googleapis.com/mediapipe-models/pose_landmarker"
for t in lite full heavy; do
  curl -fsSL -o tracker/models/pose_landmarker_$t.task \
    "$base/pose_landmarker_$t/float16/latest/pose_landmarker_$t.task"
done

System GL library (user-space workaround)

mediapipe 1.2.3's C bindings need libGLESv2.so.2, which is absent on this box and cannot be apt installed without sudo. It was supplied user-space (no sudo) via:

cd /tmp && apt-get download libgles2 && dpkg-deb -x libgles2_*.deb ext
mkdir -p ~/.cache/kinect/gllibs && cp -a ext/usr/lib/*/libGLESv2.so.2* ~/.cache/kinect/gllibs/
export LD_LIBRARY_PATH="$HOME/.cache/kinect/gllibs:$LD_LIBRARY_PATH"

Run

export LD_LIBRARY_PATH="$HOME/.cache/kinect/gllibs:$LD_LIBRARY_PATH"
# webcam:
tracker/.venv/bin/python -m tracker.tracker --source 0 --model full
# recorded file:
tracker/.venv/bin/python -m tracker.tracker --source clip.avi --model full --max-frames 300
# benchmark the tiers and exit:
tracker/.venv/bin/python -m tracker.tracker --source clip.avi --measure-fps

Tests & measured evidence

tracker/.venv/bin/python -m pytest tests/test_tracker.py -v

Data-path suite is green (9/9): fake-pose → contract packing → shared-memory publish → read-back, plus the no-person (low-visibility / no-body) frame and the control-plane handshake/heartbeat round-trip. Full repo Python suite: 73 passed.

Live MediaPipe smoke (recorded 256×256 synthetic-humanoid clip, CPU/XNNPACK): real 33-landmark detection (x∈[0.21,0.79], y∈[0.21,0.93]), world landmarks in metres, a 256×256 segmentation mask, tracking_id=1, depth body pixels published, publish cadence ~31.6 fps. Measured inference fps on this CPU:

tier fps (256×256, CPU)
lite ~80
full ~62
heavy ~20

→ full is the selected tier (comfortably ≥25 fps on CPU at this resolution; heavy drops below 25). Measured at 256×256; fps at 640×480 will be lower and should be re-measured against the real capture resolution. Evidence: .omo/evidence/task-5-webcam-kinect-emulator.log.

Blocked / not verified here [~]

  • Live webcam device: this headless WSL2 box has no camera; the pipeline was validated against a recorded video file (as the plan prescribes for determinism). Running against --source 0 on real hardware is unverified.
  • GPU inference tier: no GPU on this host; all fps numbers are CPU/XNNPACK.
  • fps at 640×480: measured at 256×480→256×256 only; re-measure at the host's requested capture/stream resolution before committing to the full tier.
  • libGLESv2.so.2: required a user-space deb-extraction workaround (above); a proper deploy should install the system libgles2 package.