kinect-botandsisyphus-dev-ai 5157651cd7 fix(tracker): mirror the capture for pose inference, matching tracker-native
The in-game skeleton/cursor tracking was left/right reversed. Root cause:
tracker-native's win_main.cpp physically mirrors the captured frame
(pixel-level horizontal flip) before pose inference, but publishes the raw
unmirrored frame as the color stream, and runs its mapper with
cal_mapping_cfg.mirror=false (verified by reading win_main.cpp and
core/mapping.cpp directly). The shim's unconditional L/R joint swap
(fallback/windows-nui/src/sensor.cpp) then corrects MediaPipe's resulting
left/right mislabeling.

The Python tracker never physically mirrored the capture - it only applied a
coordinate-level flip (1-u) in joint_mapping.py, with FrameContractPublisher
defaulting mirror=True. That left joint identity already correct on its own
(no image mirror -> no MediaPipe mislabeling -> no swap needed), so the
shim's unconditional swap then flipped it backwards: the exact "tracking is
backwards" symptom.

Fix: Tracker._inference_worker now mirrors the frame (cv2.flip) before
handing it to the pose provider, exactly like win_main.cpp, while keeping
the raw frame for self._latest_frame (the published color stream).
FrameContractPublisher's mirror default changes to False to match
cal_mapping_cfg.mirror=false, so the physical flip isn't double-applied.

New regression test calls the real Tracker._inference_worker directly (not
a reimplementation) with an asymmetric synthetic frame and asserts the pose
provider receives the mirrored version while the stored/published frame
stays unmirrored. Updated test_publish_and_read_back_fake_pose to compute
its independent expectation with the publisher's actual mirror setting
instead of assuming it matches joint_mapping's own default. Full suite:
11/11 passing.

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

Webcam-driven virtual Kinect v1

Make an ordinary RGB webcam present itself as a genuine Microsoft Kinect v1 sensor, so unmodified Kinect apps run with no recompile. The primary proof target is DanceEvolution Arcade (DEA) on Windows. We emulate the device (the thing on USB), not the game's API, so the approach is OS-agnostic and the real host Kinect stack (MS NUI on Windows, OpenNI2/NiTE on Linux) computes the skeleton from webcam-derived synthetic depth.

Quickstart

  • Linux (verified path): build the core, run the tracker, see moving synthetic depth through a real OpenNI2 consumer. Follow docs/setup-linux.md.
  • Windows (DEA, verified path): download the player bundle, drop in the Kinect10.dll shim, run the native tracker, and play. Follow docs/setup-windows.md.
  • DEA under Wine on Linux: the native tracker can't run under Wine (Wine's Media Foundation stubs out video capture device enumeration), so this path runs the Linux Python tracker natively and bridges it to the Wine-hosted shim through a real file-backed shared-memory mapping. Follow docs/linux-wine.md.
  • Calibrate the cursor once: docs/calibration.md.
  • Something broken: docs/troubleshooting.md.
  • Limitations & requirements: docs/limitations.md.
  • Build details / toolchain: docs/build.md.
  • Native Windows tracker (current path): docs/native-tracker.md.
  • How DEA works inside + RE jump-start: docs/game-internals.md.

Architecture

The current Windows path uses the self-contained native tracker (tracker-native/, C++ Media Foundation capture + Win32 GUI + ONNX BlazePose), so no Python runtime is needed on the play machine. The original Python tracker (tracker/) remains the reference/Linux path. Both publish the same contract.

  webcam ─► tracker (native tracker-native/ on Windows, or Python tracker/)
                     │   MediaPipe/BlazePose pose + segmentation
                     │   publishes to the frozen shared-memory IPC contract
                     ▼
            core/ (OS-agnostic engine, libnui_core)
            contract · mapping · synth · protocol · calibration
                     │
        ┌────────────┴─────────────────────────────┐
        ▼                                            ▼
  attach/ (per-OS USB attach)              fallback/ (per-OS library surface)
  linux: usbip/vhci device                 linux: OpenNI2 "SynthKinect" driver
  windows: usbip-win VHCI                   windows: clean-room Kinect10.dll shim
                     │
                     ▼
     real host Kinect stack skeletonizes the synthetic depth
     (MS NUI on Windows, OpenNI2 + NiTE on Linux) ─► the game

The shared engine is the OS-agnostic core/, built into libnui_core and unit-tested on Linux. Only the thin attach/ and fallback/ layers are per-OS. One tracker feeds one contract; every surface is a consumer of that one producer, so skeleton and depth stay identical across paths.

Status: what is verified vs blocked

Mirrors the plan's [x]/[~] state. "Verified" means executed and observed in the Linux/WSL2 build environment. [~] means the code is complete but the runtime proof is gated on hardware or an OS this environment lacks (no Windows, no WDK, no usbip userspace, no loaded vhci-hcd).

Capability Surface Status
OS-agnostic core (contract, mapping, synth, protocol, calibration) builds + unit-tests core/ verified (CTest green)
Webcam -> MediaPipe pose/segmentation -> frozen IPC contract tracker/ verified against a recorded video; live --source 0 needs a real camera
Articulated synthetic depth through a real OpenNI2 stack (moving, in-band, spread > 100 mm) fallback/linux-openni2/ + e2e harness verified (depth + enumeration; VERDICT: PASS)
Robustness: player-lost, low-light, mask noise, tracker-crash without host crash tracker/ + core/ verified (fault-injection)
Linux USB device-attach (OS enumerates a Kinect) attach/linux/ [~] blocked: no usbip userspace / loaded vhci-hcd here. Compiles + unit-tests; needs a native-Linux host
Linux skeleton tracking (NiTE2) OpenNI2 + NiTE2 out of scope: NiTE2 is non-redistributable; supply it yourself
Windows device-attach (IS-1 enumerate, IS-2 MS NUI skeletonizes synthetic depth) attach/windows/ [~] blocked: no Windows/WDK. Scripts + topology + signing fully specified
Windows Kinect10.dll NUI shim (IS-3/IS-4 playability only) fallback/windows-nui/ verified loaded in DEA on the user's Windows box (real PE32/PE32+, 21 exports); the game renders our skeleton + menu cursor
Native Windows tracker (MF capture + Win32 GUI + ONNX BlazePose, remembers last camera/resolution) tracker-native/ verified on the user's Windows box
DEA in-game skeleton rendering + menu hand-cursor Windows + fallback/windows-nui/ verified on the user's Windows box (skeleton renders; one-arm cursor covers the screen). See docs/game-internals.md

The authoritative skeleton/fidelity proof is DEA on Windows; the Linux OpenNI2 path proves the depth/synthesis fidelity. The Kinect10.dll shim proves playability only and does not satisfy IS-1 (OS enumeration) or IS-2 (real-runtime skeletonization).

Clean-room notice

All synthesis, mapping, protocol, and shim code here is written fresh. The public Kinect NuiApi.h headers and the libfreenect USB protocol are treated as interface facts only. No GPLv3 source (KinectFaker, NiVirtualCam, NiTE2, etc.) is read or vendored. The MS Kinect 1.8 runtime, NiTE2, and any game assets are never bundled; the docs link to their official sources.

Module map

Path Role
core/contract/ Frozen, versioned IPC frame + control schema
core/mapping/ NUI intrinsics, MediaPipe-33 -> Kinect-20 map, Holt smoothing
core/synth/ Packed depth + player-index + color rasterizer
core/protocol/ Kinect v1 virtual USB device emitter
core/calibration/ One-time T-pose + mirror calibration
tracker/ Python webcam -> MediaPipe pose/segmentation -> IPC (reference/Linux path)
tracker-native/ Native Windows tracker: MF capture + Win32 GUI + ONNX BlazePose -> IPC
attach/linux/ Linux USB attach via usbip/vhci
attach/windows/ Windows virtual USB bus attach + signing scripts
fallback/linux-openni2/ OpenNI2 virtual device / Linux general emulator
fallback/windows-nui/ Clean-room Kinect10.dll NUI shim
tools/e2e_linux_validation/ Recorded-video -> tracker -> OpenNI2 depth e2e harness
tools/record-replay/, tools/mock-nui-host/ Deterministic record/replay + mock NUI host
packaging/ Per-OS runnable-bundle assembly script
tests/ Cross-cutting C++ (CTest) + Python (pytest) tests
docs/ Setup, calibration, troubleshooting, build, native tracker, DEA game internals + RE jump-start

Packaging

packaging/build_bundle.sh assembles a per-OS runnable bundle from the built artifacts. See packaging/README.md.

The full plan lives in .omo/plans/webcam-kinect-emulator.md; the architecture and NUI contract notes in .omo/design/.

S
Description
No description provided
Readme
86 MiB
0 Stars 1 Watchers 0 Forks
Languages
C++ 60.8%
Python 25.4%
Shell 3.4%
PowerShell 3.3%
CMake 2.5%
Other 4.6%