Files

110 lines
7.1 KiB
Markdown

# 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](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](docs/setup-windows.md)**.
- **Calibrate the cursor once:** **[docs/calibration.md](docs/calibration.md)**.
- **Something broken:** **[docs/troubleshooting.md](docs/troubleshooting.md)**.
- **Limitations & requirements:** **[docs/limitations.md](docs/limitations.md)**.
- **Build details / toolchain:** **[docs/build.md](docs/build.md)**.
- **Native Windows tracker (current path):** **[docs/native-tracker.md](docs/native-tracker.md)**.
- **How DEA works inside + RE jump-start:** **[docs/game-internals.md](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](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](packaging/README.md).
The full plan lives in `.omo/plans/webcam-kinect-emulator.md`; the architecture and NUI contract
notes in `.omo/design/`.