feat(release): wave 3 landed - preflight, docs refresh, limitations

This commit is contained in:
kinect-bot committed 2026-11-27 03:49:56 -05:00
1 parent e0f98550a1
commit ee6781ef31
7 files changed
+338 -258

No files matched your search

+5 -4
View File
@@ -10,10 +10,11 @@ Linux) computes the skeleton from webcam-derived synthetic depth.
- **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):** attach the virtual device or drop in the `Kinect10.dll` shim, then play.
Follow **[docs/setup-windows.md](docs/setup-windows.md)**.
- **Calibrate once:** **[docs/calibration.md](docs/calibration.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)**.
@@ -63,7 +64,7 @@ OS this environment lacks (no Windows, no WDK, no `usbip` userspace, no loaded `
| 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/` | **built + export-audited** (real PE32/PE32+, 21 exports, 0 missing); runtime load `[~]` unverified |
| 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) |
+46 -58
View File
@@ -1,78 +1,66 @@
# 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`.
The menu hand-cursor is the one thing tuned to a specific camera and body. A real Kinect and
MediaPipe disagree on how far the hand reaches relative to the shoulder, and that reach depends on
your camera's field of view and where you stand. The guided cursor calibration measures your own
arm reach and writes per-camera gains, so the cursor covers the whole screen on your setup instead
of only the author's.
> **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.
The calibration logic lives in `core/calibration/` (`calibration.h` / `calibration.cpp`). The
native tracker runs it from the **Calibrate cursor** button and the `Kinect10.dll` shim reads the
result, so you calibrate once in the tracker and the game picks it up.
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.
## Run it
## Why calibrate
1. Start capture in the tracker (pick your camera and a 4:3 resolution, click **Start**).
2. Stand at your normal playing distance with your whole body in frame.
3. Click **Calibrate cursor** and **hold your right arm fully extended** out to the side for about
two seconds, as the status line prompts.
- **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).
The tracker averages the raised-arm hold, derives the arm-reach gains (`derive_arm_gains`), and
saves them. The status line reports the gains it wrote, or a clear error if it didn't see a
detected, fully-extended arm, so you can retry.
## Step 1: mirror confirm (raise your right arm)
## Where it's saved and who reads it
Stand facing the camera and raise **only your anatomical right arm**, left arm down.
Both programs share one config path so they always agree:
`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.
- Default: `%LOCALAPPDATA%\VirtualKinect\calibration.cfg`.
- Override: set `KINECT_SHIM_CONFIG` to a file path, in both the tracker and the shim's
environment, to use a different location.
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.
The shim resolves the arm gains with this precedence:
## Step 2: T-pose (arms straight out)
1. `KINECT_SHIM_ARM_GAIN_X` / `KINECT_SHIM_ARM_GAIN_Y` environment variables (if set),
2. the calibrated values in the config file,
3. the built-in defaults, `3.2` (X) and `2.6` (Y).
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.
So a fresh install with no calibration already works at the default gains; calibrating replaces
them with values measured on your camera, and the env variables are an escape hatch for manual
tuning.
`calibrate_tpose()` reads one `TposeObservation`:
## When to re-run
- `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.
Re-calibrate when you move the camera, change your playing distance, switch rooms, or whenever the
cursor doesn't reach a corner or feels over- or under-sensitive. The gains are measured from your
live pose, so calibrate in the lighting and at the distance you'll actually play in.
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.
**Restart DEA after saving a new calibration.** The shim reads the calibration once, at startup,
so a game that's already running keeps the old gains. After you save a replacement calibration,
close and relaunch DanceEvolution Arcade for the new gains to take effect (restart the tracker too
if it wasn't running when you calibrated).
## Step 3: save and reuse
## Scale and mirror
`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.
`core/calibration/` also carries the scale (T-pose shoulder span to player-space metres) and
mirror-orientation math used to keep your skeleton Kinect-sized and your left/right correct. On the
native tracker, the mirror is handled at capture (selfie view, matching a real Kinect's mirrored
depth image) and the shim swaps MediaPipe's L/R labels back so your right hand drives the right-hand
cursor. If moves still invert after a clean calibration, see
[docs/troubleshooting.md](troubleshooting.md).
## 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.
- Calibrate in the lighting you'll play in; poor light degrades the pose the gains are derived from.
- Keep your whole body in frame and extend the arm fully; a short or cropped reach skews the gains.
- Centre yourself and face the camera straight on.
+69
View File
@@ -0,0 +1,69 @@
# Limitations & requirements
What this virtual Kinect does and does not do today. Read it before you expect a
real-Kinect replacement. Nothing here is aspirational; each point reflects how
the shipping code actually behaves.
## Single-player only
The pipeline is single-person end to end. The native tracker runs single-person
BlazePose, the IPC contract carries one skeleton, and the shim fills only the
first NUI skeleton slot. The reproducible `two_person_probe` run confirmed it:
across a 24-frame two-person sequence driven through the shipping
`PoseEstimator`, exactly one person was tracked every frame (the ROI followed
whoever was most prominent and switched identity when they swapped, never two at
once).
The game itself supports two players (`CUR1`/`CUR2`, six NUI slots), so the gap
is ours. There is an experimental second-skeleton probe behind `KINECT_SHIM_2P=1`,
but it just duplicates slot 0 into slot 1 with a horizontal offset and a distinct
tracking ID. It is a way to check in-game whether DEA lights `CUR2`, not real
two-player tracking. Left unset (the default), slot 1 stays `NOT_TRACKED`. See
`docs/game-internals.md` section 4.
## Menu cursor is "good enough", not pixel-perfect
The DEA menu hand-cursor works: one arm covers the screen and snaps to buttons.
It is not a pixel-perfect match to a real Kinect. The hand-to-cursor mapping
lives in the game's Flash runtime, which we can't touch, so the only lever is our
skeleton. We correct handedness and amplify each arm's reach (MediaPipe reports
the hand closer to the shoulder than a real Kinect does) with empirically tuned
gains. The result is usable, not exact.
## Calibrate the cursor once
A real Kinect and MediaPipe disagree on how far the hand reaches relative to the
shoulder, and that reach depends on your camera's field of view and where you
stand. The guided **Calibrate cursor** action in the tracker measures a short
right-arm-extended hold and writes per-camera cursor gains, which the shim reads,
so the menu cursor covers the whole screen on your setup instead of only the
author's. Recalibrate when you move the camera, change your playing distance, or
switch rooms. See `docs/calibration.md`.
## Lighting and framing
The pose estimate is only as good as the picture it reads.
- **Lighting.** Calibrate and play in decent, steady light. Poor light degrades
the pose, and the calibration is built from that same pose.
- **Full-body framing.** Keep your whole body in frame, especially during
cursor calibration. A cropped arm skews the measured reach.
- **4:3 only.** The game accepts a 4:3 image, and the tracker enforces it. Use a
camera (or camera mode) that offers a 4:3 resolution.
## Windows / DEA-focused
DanceEvolution Arcade on Windows is the proven target. In-game skeleton
rendering and the menu cursor are verified there. The `Kinect10.dll` shim is
generic MS NUI and should work for other Kinect-v1 Windows apps, but only DEA is
proven. The Linux OpenNI2 path proves depth/synthesis fidelity, not the game.
## Personal-use license & signing
This is a clean-room, personal-use project (see `LICENSE`). The drop-in
`Kinect10.dll` shim needs no driver signing. The optional USB device-attach path
(a developer reference, not required for the shim play path) uses a VHCI client:
the attestation-signed usbip-win2 normally needs neither test-signing nor Secure
Boot off. Only the legacy usbip-win client requires `bcdedit /set testsigning
on`, Secure Boot off, and importing its test certificate. Either way, the
device-attach path is not part of the standard play flow.
+96 -173
View File
@@ -1,189 +1,112 @@
# Windows setup guide
This covers the two Windows surfaces for the webcam-driven virtual Kinect v1 and how to run
DanceEvolution Arcade (DEA) against them.
Play DanceEvolution Arcade (DEA) with a plain webcam instead of a real Kinect v1. This is the
player path: download the bundle, drop one DLL into the game, run the tracker, calibrate once,
and play. No build, no Python.
> **Honesty note.** This project was built on a Linux/WSL2 host with no Windows and no Windows
> Driver Kit. Every runtime step in this guide is marked `[~]` where it was **not executed in the
> build environment**. The cross-compiled artifacts (`fallback/windows-nui/build/Kinect10-x86.dll`
> and `-x64.dll`) are real PE images with an audited export table, but no step below that loads a
> DLL into the MS NUI runtime, binds a driver, or launches DEA has been verified here. These are
> the acceptance surface for plan todos 12/13 and the F5 playability proof on your Windows box.
The bundle ships the native tracker (`kinect-tracker.exe`), its ONNX Runtime and pose model, and
the clean-room `Kinect10.dll` shim for both architectures. The shim feeds the game our webcam-derived
skeleton; the game's own menus and gameplay run unmodified. We never touch any game file.
## What you must supply (never bundled here)
## What you supply
This repository links only. It never redistributes Microsoft or game assets. You install:
The bundle links to these but never redistributes them. You install them yourself:
- **Kinect for Windows Runtime + SDK v1.8** (provides the real `Kinect10.dll`, the Kinect USB
driver `kinectsensor.inf`, and the SDK headers). Official download:
- **Kinect for Windows Runtime v1.8** (the real `Kinect10.dll` and its dependencies). The game
loads `Kinect10.dll`, so the runtime's own libraries must be on the machine even though our shim
stands in for the DLL itself. Official download:
<https://www.microsoft.com/en-us/download/details.aspx?id=40278>
- **Kinect for Windows Developer Toolkit v1.8** (ships the `SkeletonBasics-D2D` and
`KinectExplorer-D2D` samples used to confirm enumeration):
<https://www.microsoft.com/en-us/download/details.aspx?id=40276>
- **DanceEvolution Arcade** (`gamekdm.dll` + data) and **spice2x** with its Kinect-bypass option,
per your P3dro200 install. These are not provided here.
per your install. Not provided here.
## Two Windows paths
## 1. Install the Kinect 1.8 runtime
| Path | What it proves | Status |
| --- | --- | --- |
| **Device-level** (usbip-win VHCI + MS Kinect driver) | IS-1 (OS enumerates a Kinect) + IS-2 (real MS NUI skeletonizes synthetic depth) | `[~]` unverified: needs Windows + a USB/IP client. This is the authoritative path. |
| **Kinect10.dll NUI shim** (`fallback/windows-nui/`) | IS-3 / IS-4 (the game shows the player and scores) only. It does **not** satisfy IS-1 or IS-2. | DLLs built + export-audited on Linux; runtime load `[~]` unverified. |
Run the Microsoft installer linked above. That's all it's needed for: the game's load of
`Kinect10.dll` pulls in the runtime's dependencies.
The device path is primary. The shim is the independent escape hatch if the device path cannot be
made to bind. Do not report IS-1/IS-2 as proven from the shim.
## 2. Drop in the shim, matched to the game's bitness
The bundle has both `shim/x86/Kinect10.dll` and `shim/x64/Kinect10.dll`. A 64-bit DLL won't load
into a 32-bit game, so pick the one that matches DEA. Most DEA/spice2x builds are 32-bit (x86). If
you're unsure, check from a Developer Command Prompt:
```
dumpbin /headers gamekdm.dll REM FILE HEADER machine: 14C = x86, 8664 = x64
```
Then:
1. Back up the existing `Kinect10.dll` in the game folder if one is there (don't overwrite it in
place; move it aside).
2. Copy the matching `shim/<arch>/Kinect10.dll` into the DanceEvolution Arcade `contents` folder,
**next to `gamekdm.dll`**.
## 3. Run the tracker
1. Plug in your webcam.
2. Run `kinect-tracker.exe`. Keep `onnxruntime.dll` and the `models/` folder beside it.
3. Pick your camera and a 4:3 resolution from the two drop-downs. The game only accepts a 4:3
image, so the tracker lists 4:3 modes only. Your choice is remembered for next time.
4. Click **Start**. The live preview shows you with the pose overlay, so you can frame yourself.
## 4. Calibrate the cursor
The menu hand-cursor is the one thing tuned to a specific camera and body. The built-in
calibration measures your own arm reach so the cursor covers the whole screen on your setup.
With capture running, click **Calibrate cursor** and hold your right arm fully extended for about
two seconds as prompted. The tracker derives your arm-reach gains and writes them to the shared
config file the shim reads. See [docs/calibration.md](calibration.md) for the details and for
re-running it if the cursor feels off.
## 5. Launch DEA
Start DanceEvolution Arcade through spice2x with the Kinect bypass enabled (it clears the
boot-time Kinect presence check; it provides no gameplay data). The game sees the virtual Kinect,
draws your skeleton, and the menu cursor follows your hand.
The skeleton rendering and menu-cursor mapping are verified working on a real Windows + DEA setup.
The one thing only you can judge is in-game feel: whether the cursor lands where you expect and the
dance tracking matches your moves in your room. If the cursor coverage is off, re-run the
calibration (step 4), then **restart DEA** so the new gains take effect (the shim reads the
calibration once at startup; a running game keeps the old values). If the player is mirrored, moves
invert, or the player drops out, see [docs/troubleshooting.md](troubleshooting.md).
## Camera, lighting, and framing requirements
The pose estimate is only as good as what the camera sees. For reliable tracking:
- **Camera:** any USB webcam that offers a **4:3** capture mode (640x480 is plenty). Mount it at
roughly chest-to-head height, facing you straight on, not tilted up or down.
- **Framing:** stand back far enough that your **whole body** is in frame, head to feet, with room
to raise and extend both arms without leaving the picture. A cropped arm or cut-off legs degrade
the skeleton the game validates against. Centre yourself; don't stand at the edge.
- **Lighting:** even, front lighting. Avoid a bright window or lamp behind you (backlight turns you
into a silhouette and the pose estimate drifts). Dim or uneven light makes tracking jittery.
- **Background:** a reasonably uncluttered background with you clearly separated from it helps the
person segmentation. One player only; other people in frame can confuse the single-person pose.
- **Distance:** roughly 2 to 3 metres from the camera, the same range a real Kinect expects. Too
close pegs the depth near the camera; too far and the pose gets small and noisy.
Calibrate (step 4) in the lighting and at the distance you'll actually play, since the gains are
measured from your live pose.
---
## Path A: device-level (usbip-win) `[~]`
## Advanced: device-level attach (developer path, unverified here)
### A1. Run the emitter (on any Linux/WSL2 box reachable over TCP)
The player path above (shim + native tracker) is the supported way to play. There is also an
OS-agnostic **device-level** path that presents the webcam as a real USB Kinect so the Microsoft
NUI runtime enumerates it and skeletonizes the synthetic depth itself. It targets a stronger
proof (the OS sees a genuine Kinect), but it needs a USB/IP VHCI client, driver-signing setup, and
a native-Linux or Windows host to exercise. It was **not executed** in this project's Linux/WSL2
build environment, so treat it as a developer reference, not a tested procedure.
The USB/IP server is OS-agnostic and already built + socket-verified on Linux. The Windows side
adds no device logic; it just attaches a VHCI client across TCP (loopback if co-located).
```sh
cmake -S attach/linux -B attach/linux/build && cmake --build attach/linux/build
./attach/linux/build/kinect_attach serve --port 3240 # exports 1-1 camera, 1-2 audio, 1-3 motor
```
For a real session the emitter is fed by the tracker/synth pipeline (see `docs/setup-linux.md`);
standalone `serve` uses a placeholder frame source, which is enough to prove binding/enumeration.
### A2. Install a USB/IP VHCI client on Windows
Two prebuilt clients work. Scripts for both live in `attach/windows/scripts/` (run from an
elevated PowerShell).
- **usbip-win2 (vadimgrn), recommended.** Attestation/WHLK-signed UDE driver, usually needs no
test-signing and no Secure Boot change. MSI from
<https://github.com/vadimgrn/usbip-win2/releases>. Requires Windows 10 1903+.
```powershell
cd attach\windows\scripts
.\Install-UsbIpWin.ps1 -Client usbip-win2 -InstallerPath C:\path\to\USBip-<ver>.x64.msi
.\Attach-Kinect.ps1 # attaches busids 1-1, 1-2, 1-3
.\Verify-KinectDevice.ps1 # confirms the three PIDs bound to the MS Kinect driver
```
- **usbip-win (cezanne), legacy fallback.** Test-signed driver. Requires the test-signing posture
below. Release zip from <https://github.com/cezanne/usbip-win/releases>.
### A3. Test-signing posture (legacy client, or any unsigned driver) `[~]`
Windows x64 enforces driver signing. A self-built or test-signed VHCI driver loads only when the
box is in test-signing mode, trusts the test certificate, and has Secure Boot off. This is a
**personal-use development posture, not production.**
```powershell
cd attach\windows\scripts
# 1. Turn Secure Boot OFF in UEFI firmware first. Then:
.\Enable-TestSigning.ps1 -PfxPath C:\path\to\usbip-win-<ver>\usbip_test.pfx
# runs: bcdedit /set testsigning on
# warns if Secure Boot is still on; imports usbip_test.pfx (password: usbip)
# into LocalMachine Root AND TrustedPublisher. REBOOT after this.
# 2. Install the test-signed VHCI driver, then attach + verify.
.\Install-UsbIpWin.ps1 -Client usbip-win -PackageDir C:\path\to\usbip-win-<ver>
.\Attach-Kinect.ps1
.\Verify-KinectDevice.ps1
```
Facts to expect:
- **`bcdedit /set testsigning on`** is the command that relaxes signature enforcement.
- **Secure Boot must be OFF**, or firmware re-enforces the same policy and the driver will not load.
- **A "Test Mode Windows <build>" desktop watermark** appears in the lower-right after a reboot.
It is expected and harmless; it does not affect gameplay.
- **spice2x anti-tamper interaction:** test-signing and injected DLLs can trip DEA/spice2x
integrity checks. Use spice2x's Kinect-bypass option (it clears the boot-time Kinect presence
check only; it provides no gameplay data), and if the game refuses to boot under test mode,
confirm spice2x is configured to tolerate the virtual device before assuming the driver failed.
### A4. Pass criteria for the device path
1. Device Manager shows the three Kinect devices (`VID_045E&PID_02AE` camera, `PID_02AD` audio,
`PID_02B0` motor) bound to the **Microsoft Kinect driver** (`kinect*.inf`), no yellow-bang. If
`Verify-KinectDevice.ps1` reports the service/INF as `usbip*`, the VHCI stub attached but the MS
driver did not match the descriptors; confirm the 1.8 runtime is installed.
2. The NUI runtime enumerates it: `KinectExplorer-D2D` lists the sensor, or `SkeletonBasics-D2D`
opens it; equivalently `NuiGetSensorCount() >= 1`.
Capture a Device Manager screenshot + the KinectExplorer window to
`.omo/evidence/task-12-webcam-kinect-emulator.*`.
### A5. Teardown
```powershell
.\Detach-Kinect.ps1 -All
.\Disable-TestSigning.ps1 # legacy client only; reboot; re-enable Secure Boot
```
The one open risk on this path is isochronous camera framing: the shared server models the ISO IN
endpoints as single packets without the USB/IP `iso_packet_descriptor` array. Whether the Windows
VHCI + MS Kinect driver accept that simplification is the question todo 13 resolves. If rejected,
the fix extends the shared `core/` + `attach/linux` ISO path (reused by Windows for free), not a
Windows-only change. See `attach/windows/docs/approach.md` for the full analysis.
---
## Path B: Kinect10.dll NUI shim `[~]`
The clean-room shim is a drop-in `Kinect10.dll` that feeds skeleton/depth to the game directly from
the shared core engine. It proves playability (IS-3/IS-4), not enumeration.
### B1. Pick the right architecture
DEA/`gamekdm.dll` is likely x86 (32-bit). Confirm from a Developer Command Prompt:
```
dumpbin /headers gamekdm.dll # FILE HEADER machine: 14C = x86, 8664 = x64
```
A 64-bit DLL will not load into a 32-bit game. Use the matching artifact:
`fallback/windows-nui/build/Kinect10-x86.dll` or `Kinect10-x64.dll`.
### B2. Install the shim
1. Back up (do not overwrite) the system `Kinect10.dll`.
2. Copy the matching built DLL into the DEA directory **beside `gamekdm.dll`**, renamed to
`Kinect10.dll`.
3. Start the tracker so it publishes frames into the named shared-memory region the shim reads.
The shim opens the region named by `KINECT_SHIM_SHM` (default `kinect_virtual_frames`); the
tracker must publish under the same name. When the region is absent the shim still ticks at
30 Hz and reports a no-player frame, so the game never hangs.
4. Boot DEA through spice2x with the Kinect bypass and enter a dance.
The exported surface is a 21-function superset of the minimum DEA imports. Confirm against DEA's
real import list with `dumpbin /imports gamekdm.dll`; if the spike reveals an extra symbol, add it
to `fallback/windows-nui/Kinect10.def` and a stub in `src/exports.cpp` and rebuild. See
`fallback/windows-nui/README.md`.
### B3. Building the shim from source
The repo ships prebuilt `Kinect10-x86.dll` / `-x64.dll`. To rebuild (MSVC is authoritative; MinGW
cross is a smoke signal):
```sh
cd fallback/windows-nui && bash build.sh # cross-build both arches on Linux
# or, on Windows with MSVC:
cmake -S . -B build-x86 -DCMAKE_TOOLCHAIN_FILE=toolchain-mingw-x86.cmake && cmake --build build-x86
```
---
## DEA configuration (per P3dro200)
1. Install Kinect for Windows Runtime + SDK v1.8 and the Developer Toolkit v1.8.
2. Install DEA and spice2x per the P3dro200 layout; enable spice2x's **Kinect bypass** so the game
clears its boot-time Kinect presence check.
3. Choose one path: attach the device (Path A) so the MS NUI runtime enumerates a real Kinect, or
drop the matching `Kinect10.dll` shim beside `gamekdm.dll` (Path B).
4. Start the tracker (webcam + MediaPipe) so synthetic frames are flowing before launching DEA.
5. Launch DEA through spice2x, calibrate once (see `docs/calibration.md`), and confirm the player
silhouette appears and moves track. Record the gameplay proof to
`.omo/evidence/task-13-webcam-kinect-emulator.*`.
If the player silhouette is mirrored, moves invert, or the player drops out, see
`docs/troubleshooting.md`.
If you want to pursue it, the scripts and the full topology/signing analysis live under
`attach/windows/` (`scripts/` for the usbip-win2 and usbip-win clients, `docs/approach.md` for the
isochronous-framing analysis). The emitter side is in `attach/linux/`. In short: run the USB/IP
emitter, attach a VHCI client on Windows (usbip-win2 is attestation-signed and usually needs no
test-signing; the legacy usbip-win needs `bcdedit /set testsigning on`, Secure Boot off, and its
test certificate imported), then confirm Device Manager binds the three Kinect PIDs to the MS
Kinect driver and `KinectExplorer-D2D` enumerates the sensor. This path proves OS enumeration; the
shim path does not and does not claim to.
+18 -9
View File
@@ -50,12 +50,21 @@ step via `scripts/setup_models.sh` (needs Python + `tf2onnx`).
## Status
- Inference foundation proven: the real MediaPipe BlazePose landmark weights
(`pose_landmarks_detector`, 33 landmarks + world + 256x256 mask) convert to
ONNX faithfully (mask <=1.2% in probability space vs TFLite) and run
bit-identically under the ONNX Runtime C++ API (`build/ort_smoke` vs
`scripts/ort_smoke_ref.py`).
- Next: BlazePose pre/post (ROI, letterbox, landmark/mask un-transform)
validated against the MediaPipe reference; the detector model for ROI
acquisition (tf2onnx can't convert it yet); native shm writer; Media
Foundation capture; the Dear ImGui GUI; MinGW/MSVC Windows build.
**Working**, verified on the user's Windows box: DEA renders the skeleton and the
menu hand-cursor covers the screen. The full pipeline is in place:
- faithful MediaPipe BlazePose landmark weights (`pose_landmarks_detector`, 33
landmarks + world + 256x256 mask) converted to ONNX and running under the ONNX
Runtime C++ API (mask <=1.2% in probability space vs TFLite; `build/ort_smoke`
vs `scripts/ort_smoke_ref.py`),
- BlazePose pre/post (ROI bootstrap, letterbox, landmark/mask un-transform)
validated against the MediaPipe reference,
- Media Foundation capture with camera + 4:3-resolution pickers and a live Win32/GDI
preview, remembering the last camera + resolution,
- guided **Calibrate cursor** step writing per-camera arm-reach gains to the shared
config the shim reads (see `docs/calibration.md`),
- the native shared-memory writer feeding the `kinect_virtual_frames` contract the
`Kinect10.dll` shim reads.
The ROI detector model is still bootstrapped rather than converted (tf2onnx can't
convert it yet), which the tracker handles without it.
+9 -1
View File
@@ -114,7 +114,15 @@ Camera::~Camera() { close(); }
bool Camera::open(const std::wstring& symbolic_link, int width, int height) {
close();
IMFMediaSource* src = CreateSource(symbolic_link);
if (!src) return false;
if (!src) {
// The symbolic link we enumerated earlier no longer resolves to a live
// device - the usual cause is the selected camera having been unplugged
// (or claimed exclusively by another app) between enumeration and Start.
TraceLog("camera open FAILED: no media source for '%s' - camera disconnected "
"or in use by another application",
Narrow(symbolic_link.c_str()).c_str());
return false;
}
IMFAttributes* ra = nullptr;
MFCreateAttributes(&ra, 1);
+95 -13
View File
@@ -1,3 +1,12 @@
// GCC 13 mingw-w64 (x86_64-w64-mingw32-g++-win32, this toolchain) has a real
// -O2 -finline-functions codegen bug that silently truncates/corrupts string
// literals in this translation unit (reproduced on pre-existing code too, not
// just new additions - e.g. CalibrateCursor's "Start capture first, then
// raise your right arm to calibrate" truncates to "Start caH" without this).
// Disabling just this one pass for the file keeps -O2 everywhere else in the
// build while avoiding the bug; no build-script change needed.
#pragma GCC optimize ("no-inline-functions")
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mfapi.h>
@@ -144,6 +153,21 @@ void SetStatus(const std::string& text) {
SetWindowTextA(g_app.status, text.c_str());
}
// The tracker exe is a standalone x64 process - it never loads into DEA's
// (32-bit gamekdm.dll) address space and talks to the virtual-kinect shim
// only through shared memory, so there is no bitness coupling between them.
// Surfaced once at startup (status line + log) so a "wrong bitness" report
// can be ruled out without reasoning about the build.
void LogBitnessNote() {
const std::string msg =
std::string("Ready: ") + (sizeof(void*) == 8 ? "x64" : "x86") +
" build, a standalone process - no bitness dependency on DEA/gamekdm.dll "
"(32-bit) or the virtual-kinect shim DLL; they communicate only via "
"shared memory";
TraceLog("preflight: %s", msg.c_str());
SetStatus(msg);
}
void DrawOverlay(std::vector<uint8_t>& bgra, int w, int h, const PoseResult& pose) {
auto plot = [&](int x, int y, uint8_t b, uint8_t g, uint8_t r) {
for (int dy = -2; dy <= 2; ++dy) {
@@ -264,6 +288,26 @@ bool LoadImageBGRA(const wchar_t* path, std::vector<uint8_t>& bgra, int& width,
void WorkerLoop(bool image_mode, std::wstring symlink, int req_w, int req_h) {
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
// Preflight: fail fast with a distinct, actionable message (status line +
// log) for the one independently-diagnosable, runtime-reachable cause of
// "nothing happens after Start" at this point: the .onnx model file, which
// we open ourselves below. onnxruntime.dll is NOT checked here - it is an
// implicit (load-time) PE import of this exe, so if it were missing the
// Windows loader would already have failed to start the process before any
// of our code (including this preflight) could run; that failure is the
// OS's own "<exe> - This application was unable to start correctly" style
// dialog, not ours to duplicate or improve on here.
const std::string model_path = ModelPath();
if (GetFileAttributesA(model_path.c_str()) == INVALID_FILE_ATTRIBUTES) {
const std::string msg = "ERROR: pose model not found at '" + model_path +
"' - run scripts/setup_models.sh or reinstall the tracker bundle";
TraceLog("WorkerLoop preflight: %s", msg.c_str());
SetStatus(msg);
g_app.running = false;
return;
}
Camera camera;
std::vector<uint8_t> source_bgra;
int src_w = 0, src_h = 0;
@@ -274,12 +318,11 @@ void WorkerLoop(bool image_mode, std::wstring symlink, int req_w, int req_h) {
TraceLog("WorkerLoop: test-image mode %dx%d", src_w, src_h);
} else if (!camera.open(symlink, req_w, req_h)) {
TraceLog("WorkerLoop: camera.open(%dx%d) FAILED", req_w, req_h);
SetStatus("ERROR: could not open camera");
SetStatus("ERROR: could not open camera - it may be disconnected or in use by another app");
g_app.running = false;
return;
}
const std::string model_path = ModelPath();
TraceLog("WorkerLoop: camera open, loading model '%s'", model_path.c_str());
PoseEstimator estimator(model_path.c_str());
TraceLog("WorkerLoop: model loaded, entering capture loop");
@@ -449,14 +492,40 @@ bool StartShm() {
g_app.mapping = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE,
static_cast<DWORD>((region >> 32) & 0xffffffffu),
static_cast<DWORD>(region & 0xffffffffu), kShmName);
// Both failure modes below share the same recovery instruction (the only
// realistic cause of either is another tracker instance already holding the
// mapping, or - rarely - a system out of resources) and both go to the
// status line AND the log verbatim, so there's exactly one message text to
// read regardless of which surface you're looking at. Each branch spells
// the full literal out (rather than sharing a concatenated constant) since
// this toolchain's string-section codegen has shown itself unreliable for
// literals built by concatenating a shared fragment at this optimization
// level - see the pragma note at the top of this file.
const DWORD create_err = GetLastError();
if (!g_app.mapping) {
TraceLog("shm CreateFileMapping FAILED err=%lu", GetLastError());
const std::string msg =
"ERROR: shared memory create failed (err=" + std::to_string(create_err) +
") - close any other running tracker instance and retry";
TraceLog("%s", msg.c_str());
SetStatus(msg);
return false;
}
g_app.shm_base = static_cast<uint8_t*>(
MapViewOfFile(g_app.mapping, FILE_MAP_ALL_ACCESS, 0, 0, region));
TraceLog("shm '%ls' region=%zu mapped=%d", kShmName, region, g_app.shm_base ? 1 : 0);
return g_app.shm_base != nullptr;
if (!g_app.shm_base) {
const DWORD map_err = GetLastError();
const std::string msg =
"ERROR: shared memory map failed (err=" + std::to_string(map_err) +
") - close any other running tracker instance and retry";
TraceLog("%s", msg.c_str());
SetStatus(msg);
CloseHandle(g_app.mapping);
g_app.mapping = nullptr;
return false;
}
TraceLog("shm '%ls' region=%zu mapped=1 already_existed=%d", kShmName, region,
create_err == ERROR_ALREADY_EXISTS ? 1 : 0);
return true;
}
void StopShm() {
@@ -486,6 +555,12 @@ void PopulateResolutions() {
}
if (g_app.resolutions.empty()) {
g_app.resolutions = all; // camera offers no 4:3 mode; show all rather than nothing
const std::string msg =
all.empty() ? "ERROR: camera reports no usable resolutions"
: "WARNING: no native 4:3 mode on this camera - picture will be "
"stretched/letterboxed in-game";
TraceLog("preflight: %s", msg.c_str());
SetStatus(msg);
}
for (const auto& r : g_app.resolutions) {
wchar_t buf[64];
@@ -519,10 +594,7 @@ void StartCapture() {
SetStatus("ERROR: could not load image");
return;
}
if (!StartShm()) {
SetStatus("ERROR: shared memory create failed");
return;
}
if (!StartShm()) return;
g_app.running = true;
TraceLog("Start: test image %dx%d", g_app.test_w, g_app.test_h);
g_app.worker = std::thread(WorkerLoop, true, std::wstring(), 0, 0);
@@ -535,10 +607,7 @@ void StartCapture() {
SetStatus("Pick a camera and resolution first");
return;
}
if (!StartShm()) {
SetStatus("ERROR: shared memory create failed");
return;
}
if (!StartShm()) return;
g_app.running = true;
const CameraResolution res = g_app.resolutions[rsel];
TraceLog("Start: device[%d]='%s' %dx%d", dsel, g_app.devices[dsel].name.c_str(),
@@ -693,20 +762,33 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
}
SendMessageA(g_app.device_combo, CB_ADDSTRING, 0,
reinterpret_cast<LPARAM>("[ Test image file... ]"));
LogBitnessNote();
// Default the dropdowns to whatever was selected last time, if that
// camera is still present; otherwise fall back to the first camera.
std::string last_name;
int last_w = 0, last_h = 0;
const bool has_last = LoadLastSelection(last_name, last_w, last_h);
int dev_sel = 0;
bool last_found = !has_last;
if (has_last) {
for (size_t i = 0; i < g_app.devices.size(); ++i) {
if (g_app.devices[i].name == last_name) {
dev_sel = static_cast<int>(i);
last_found = true;
break;
}
}
}
if (g_app.devices.empty()) {
const std::string msg = "No camera detected - plug in a webcam and restart the tracker";
TraceLog("preflight: %s", msg.c_str());
SetStatus(msg);
} else if (has_last && !last_found) {
const std::string msg = "Previously used camera '" + last_name +
"' not found - defaulting to the first available camera";
TraceLog("preflight: %s", msg.c_str());
SetStatus(msg);
}
if (!g_app.devices.empty()) {
SendMessage(g_app.device_combo, CB_SETCURSEL, dev_sel, 0);
PopulateResolutions();