chore(scaffold): project layout, cross-platform build, CI
ci / Linux C++ core (cmake + ctest) (push) Canceled after 0s
ci / Python tracker (pytest) (push) Canceled after 0s

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
kinect-botandsisyphus-dev-ai committed 2026-11-25 03:23:45 -05:00
commit b38c7bcd82
35 files changed
+1010

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
name: ci
on:
push:
branches: [main]
pull_request:
jobs:
linux-core:
name: Linux C++ core (cmake + ctest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install build tools
run: sudo apt-get update && sudo apt-get install -y cmake g++ ninja-build
- name: Configure
run: cmake -S . -B build/linux
- name: Build
run: cmake --build build/linux
- name: Test
run: ctest --test-dir build/linux --output-on-failure
python-tracker:
name: Python tracker (pytest)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pytest
run: python -m pip install --upgrade pip pytest
- name: Run pytest
run: pytest -q
+35
View File
@@ -0,0 +1,35 @@
# ---- C/C++ / CMake build output ----
/build/
build/
_deps/
*.o
*.obj
*.a
*.lib
*.so
*.dll
*.exe
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
CTestTestfile.cmake
Testing/
compile_commands.json
# ---- Python ----
.venv/
__pycache__/
*.pyc
.pytest_cache/
*.egg-info/
# ---- OS / editor ----
.DS_Store
*.swp
# ---- OMO orchestrator state ----
# Keep project docs (.omo/plans/ and .omo/design/) tracked; ignore volatile state.
.omo/boulder.json
.omo/drafts/
.omo/ulw-execute/
.omo/evidence/
+30
View File
@@ -0,0 +1,30 @@
# Architecture recommendation (referenced by the work plan as `architecture.md`)
Source: advisory architect consult. Grounded in the Kinect v1 NUI model, Windows DLL search order, and prior art (TinyTinni/KinectFaker proves a drop-in Kinect10.dll proxy works with no host recompile; spice2x's "Kinect bypass" patch only defeats the boot check, not gameplay data).
## Verdict
The DLL-shim + separate-tracker split is a sound boundary for the API-shim fallback, but the center of gravity is (a) matching the game's exact NUI call pattern and (b) producing depth/skeleton accurate enough for the scorer. De-risk by instrumenting the real game's calls first. NOTE for this plan: the PRIMARY approach is device-level (virtual Kinect USB device), where the real host stack computes the skeleton; the shim is the per-OS fallback. The split/testing/record-replay guidance below applies to both.
## Module boundaries
Shared cross-platform core (unit-testable off-Windows): joint mapping + coordinate transform + smoothing; depth/player-index/color synthesis; the frozen IPC data-contract structs. Thin OS-specific layers: the USB-attach shims (Linux usbip/vhci, Windows virtual bus) for the device path, and the NUI export/ABI layer + session/event state machine for the Windows NUI-shim fallback. Keep ABI shape separate from timing/behavior.
## Transport
Frame transport = lock-free single-slot (double/triple-buffered) shared memory, newest-wins, with a sequence counter; a named pipe/socket carries only control-plane (handshake, config, calibration, heartbeat). The game consumes the latest frame at its own cadence and never wants a stale queue; sub-ms reads, no blocking the NUI thread. Freeze/version the IPC struct contract from commit one (static_assert sizes/offsets) because post-split drift is silent corruption, not a compile error.
## Build/test around the Linux-dev / Windows-run split
Push logic into pure POD functions so "on Windows" shrinks to ABI + Win32 eventing + end-to-end QA. Off-Windows (Linux/WSL2 CI): mapping/transform/smoothing math, mask->depth packing/projection, IPC layout (static_assert), cross-toolchain struct-offset diff. On Windows: NUI ABI/export correctness, Win32 event/threading, end-to-end QA. Topology: a cross-platform static lib (synth+mapping+contract) unit-tested on Linux; a thin Windows DLL shell linking it with MSVC authoritative (MinGW/clang-cl for fast local cross-compile only - MinGW C++ ABI quirks around COM/SEH can bite). Build a record/replay harness (capture tracker output to a fixture, replay deterministically) and a mock NUI host early - the highest-leverage test assets; they let the DLL be tested with no webcam/tracker and reproduce any in-game failure frame-for-frame.
## Top risks
A. Wrong call pattern - kill first with a pass-through logging shim + dumpbin on gamekdm.dll (exact imports, init flags, streams, resolutions, event-vs-poll, bitness).
B. 32 vs 64-bit mismatch - project-ending; a 64-bit DLL won't load into a 32-bit game. Verify via dumpbin /headers on day one; SDK 1.8 ships both.
C. DLL search-order shadowing may not fire (fully-qualified path / SxS / KnownDLLs / COM-by-CLSID / spice2x loader hooks) - confirm with the logging shim that your module is the one loaded.
D. Skeleton coordinate accuracy vs the scorer (highest SILENT risk) - MediaPipe z is monocular, scale-ambiguous, Z-weak. Calibrate scale/floor/origin; derive the Kinect-only joints consistently; A/B real vs synthetic in-game via record/replay to measure the scorer's Z-sensitivity.
E. NUI event/threading fidelity - a dedicated producer thread at a fixed 30Hz must signal exactly the events the app registered; getting contents right but signaling wrong looks like an unrelated hang.
F. Depth/player-index vs skeleton-only need - the silhouette likely needs player-index packed depth; keep it behind a flag, ship skeleton-first, add depth per the spike.
G. ABI exactness - NUI C exports are __stdcall/WINAPI; match decoration, calling convention, struct packing, enum values, COM vtable order to SDK 1.8 headers bit-for-bit; static_assert struct sizes/offsets.
## Blast radius
Confined to the game's own directory (shim) or the virtual USB device (device path); nothing patches the game binary and nothing touches the OS Kinect install. Worst case is the game process, never the system. The riskiest coupling is the frozen IPC frame contract - version it from commit one.
## Sequencing (cheapest risk-retirement order)
1. Logging pass-through shim -> learn call pattern + bitness (A,B). 2. Record/replay harness + a golden reference capture (D baseline). 3. Skeleton-only replay in-game -> confirm scoring accepts synthetic skeletons (D/E early). 4. Live MediaPipe tracker behind the shared-memory contract. 5. Depth/player-index synthesis if the flags/QA require it (F). 6. Calibration + accuracy tuning.
+131
View File
@@ -0,0 +1,131 @@
# NUI contracts - detail design (referenced by the work plan as `nui-contracts.md §N`)
Source: detail-design consult (grounded in Kinect for Windows 1.8 NUI headers `NuiSkeleton.h`/`NuiImageCamera.h`/`NuiApi.h`, archived MS 1.8 reference pages, and MediaPipe Pose Landmarker docs). Confidence tags: [DOC]=primary source; [MATH]=formula executed & round-tripped; [CONV]=convention, verify in-game; [OPEN]=uncertain + the experiment that settles it. Clean-room note: enum values, struct layouts, packing constants, and the inline transform formulas are ABI/interoperability facts to reproduce; all synthesis logic is written fresh.
## §1 Joint mapping + coordinate transform
### §1.1 Decision
Build each Kinect joint `Vector4` by back-projecting the MediaPipe normalized landmark through Kinect's documented depth-camera inverse transform at a chosen per-joint depth, rather than rotating metric world-landmarks. Per joint j:
```
dx = round(u_j * W) // W=640; mirror -> dx = round((1-u_j)*W)
dy = round(v_j * H) // H=480
z_j = clamp(Z0 + depthGain*worldZ_j, 0.8, 4.0) // meters
(x_j,y_j,z_j) = NuiTransformDepthImageToSkeleton(dx, dy, pack(z_j))
```
Inverse transform [DOC] (`NuiSkeleton.h`):
```
fSkeletonZ = (packedDepth >> 3) / 1000.0
fSkeletonX = (dx - W/2) * (320/W) * 3.501e-3 * fSkeletonZ
fSkeletonY = -(dy - H/2) * (240/H) * 3.501e-3 * fSkeletonZ
w = 1.0
```
This makes skeleton and synthesized depth/player-index silhouette mutually consistent by construction (the skeleton reprojects onto the silhouette through Kinect's forward transform). Verified round-trip <1mm [MATH]: (0.5,0.3,2.5)->px(434,171)->(0.499,0.302,2.500). `depthGain=0` => flat billboard skeleton (full 2D fidelity) - the safe default; raise toward 1.0 (or above to exaggerate) only after the toward/away sign is confirmed (§4).
### §1.2 Landmark -> joint correspondence (all 20)
MediaPipe indices from the official 33-landmark table [DOC].
| Kinect NUI_SKELETON_POSITION_* (idx) | MediaPipe source | Rule |
|---|---|---|
| HIP_CENTER (0) | 23,24 | midpoint |
| SPINE (1) | HIP_CENTER, SHOULDER_CENTER | lerp(hipC, shC, 0.45) |
| SHOULDER_CENTER (2) | 11,12 | midpoint (neck base) |
| HEAD (3) | 7,8 ears (fallback 0 nose) | midpoint(ears) then push up along (earsMid-shC)*0.30 |
| SHOULDER_LEFT (4) | 11 | direct |
| ELBOW_LEFT (5) | 13 | direct |
| WRIST_LEFT (6) | 15 | direct |
| HAND_LEFT (7) | 19,17 (fallback 15) | midpoint(19,17) |
| SHOULDER_RIGHT (8) | 12 | direct |
| ELBOW_RIGHT (9) | 14 | direct |
| WRIST_RIGHT (10) | 16 | direct |
| HAND_RIGHT (11) | 20,18 (fallback 16) | midpoint(20,18) |
| HIP_LEFT (12) | 23 | direct (optional 10-15% toward hipC) |
| KNEE_LEFT (13) | 25 | direct |
| ANKLE_LEFT (14) | 27 | direct |
| FOOT_LEFT (15) | 31 | direct (toe) |
| HIP_RIGHT (16) | 24 | direct |
| KNEE_RIGHT (17) | 26 | direct |
| ANKLE_RIGHT (18) | 28 | direct |
| FOOT_RIGHT (19) | 32 | direct |
Synthesized joints: HIP_CENTER=0.5*(L23+L24); SHOULDER_CENTER=0.5*(L11+L12); SPINE=HIP_CENTER+0.45*(SHOULDER_CENTER-HIP_CENTER); HEAD=earsMid+0.30*(earsMid-SHOULDER_CENTER); HAND=0.5*(index_mcp+pinky_mcp). Keep MediaPipe L/R labels; mirror handled once globally (§1.4) - do not double-flip.
### §1.3 Coordinate system
Kinect skeleton space [DOC]: right-handed, origin at sensor, +X to sensor's left, +Y up, +Z out toward scene, meters; ranges x~[-2.2,2.2], y~[-1.6,1.6], z[0,4]. MediaPipe normalized: u,v in [0,1] (u right, v down); z hip-origin, smaller=closer. World landmarks meters, hip-origin. The inverse transform handles y-flip and perspective; only horizontal mirror is a free choice. FOV sanity [MATH]: frame corners at Z0=2.5 -> x in [-1.40,1.40], y in [-1.05,1.05]; full-frame figure ~1.79m tall, ~0.56m shoulders.
### §1.4 Mirror bit (highest-leverage single bit)
DEA expects the mirrored convention. A raw (non-selfie) webcam frame is NOT mirrored => likely need dx=(1-u_j)*W. Single config flag, default flip ON, confirm in-game (raise right arm -> on-screen right side responds). Wrong => every move scores as its mirror (total systematic failure that looks like model inaccuracy).
### §1.5 Depth placement
Root Z0: HIP_CENTER at 2.3-2.6m (default 2.5). Keep body z in ~[1.0,3.5]; near 0 or >4 reads as no-player. Per-joint relief z_j=Z0+depthGain*worldZ_j using world-landmark z; start depthGain=0, then 0.5-1.0 once sign confirmed. Optional T-pose calibration: choose Z0 so reconstructed shoulder width ~0.40m, removing single-camera scale ambiguity.
### §1.6 Smoothing (mimic NUI_TRANSFORM_SMOOTH_PARAMETERS)
Holt double-exponential + jitter-radius dampener + max-deviation clamp [DOC]. Defaults {fSmoothing,fCorrection,fPrediction,fJitterRadius(m),fMaxDeviationRadius(m)}={0.5,0.5,0.5,0.05,0.04}. Algorithm [MATH]:
```
if first: filtered=raw; trend=0; return raw
diff=|raw-filteredPrev|
rawDamped = diff<=jitterRadius ? raw*(diff/jitterRadius)+filteredPrev*(1-diff/jitterRadius) : raw
filtered = rawDamped*(1-smoothing)+(filteredPrev+trendPrev)*smoothing
trend = (filtered-filteredPrev)*correction+trendPrev*(1-correction)
predicted = filtered+trend*prediction
dev=|predicted-raw|; if dev>maxDeviationRadius: predicted=raw+(predicted-raw)*(maxDeviationRadius/dev)
output=predicted
```
For dance use a slightly stronger set {0.6,0.4,0.4,0.04,0.07} (cuts jitter, ~2-frame latency). Keep prediction <=0.5; total latency <~3 frames. Expose all five.
### §1.7 Per-joint/per-skeleton state
eSkeletonPositionTrackingState[j]=TRACKED when visibility>=~0.5, else INFERRED (still emit a best-guess position), NOT_TRACKED only if nothing. eTrackingState=NUI_SKELETON_TRACKED for active player; Position=HIP_CENTER. dwTrackingID stable nonzero per player (IDs from 1), same player keeps the same SkeletonData[] slot across frames; player-index pixels = slot+1. w=1.0. dwQualityFlags: set CLIPPED_* near frame edges. vFloorClipPlane zero acceptable, or synthesize (0,1,0,-cameraHeight). Bone orientations: not needed (game calls NuiSkeletonCalculateBoneOrientations which derives from positions).
## §2 Depth + player-index synthesis
### §2.1 Decision
Rasterize the MediaPipe segmentation mask into a depth buffer at the resolution the game requests in NuiImageStreamOpen (query eResolution; do NOT hardcode 640x480 - see §5 open item), packing each body pixel as Kinect's 16-bit format, carrying the active player's index so silhouette is co-located with skeleton.
### §2.2 Packed format [DOC]
```
pixel = ((depth_mm & 0x1FFF) << 3) | (playerIndex & 0x7)
NuiDepthPixelToDepth(p)=p>>3 ; NuiDepthPixelToPlayerIndex(p)=p&0x7
```
Round-trip verified [MATH]: mm=2500,player=1 -> 0x4E21 -> (2500,1). Player index 0=no player; 1-6 map to SkeletonData[] 0-5. Body pixels of active player => index=skeletonSlot+1; background=0. Overflow sentinels only with DISTINCT_OVERFLOW flag (too-near 0x0000, too-far 0x0FFF<<3, unknown 0x1FFF<<3); else overflow=0. Also support unpacked NUI_DEPTH_IMAGE_PIXEL {USHORT playerIndex; USHORT depth;} via NuiImageFrameGetDepthImagePixelFrameTexture.
### §2.3 Rasterization
Threshold mask (>~0.5) -> binary body mask; resize to requested res; morphological close + keep largest connected component. Depth tiers: Flat (all body=Z0*1000); Billboard-gradient (recommended: interpolate depth across body from nearest joints' z_j - keeps silhouette/skeleton depth consistent); Full (add world-landmark relief). Background=0. Joints reproject into this buffer via NuiTransformSkeletonToDepthImage exactly onto the silhouette.
### §2.4 Minimum fidelity
Correct packed layout + resolution matching request; body depth in ~800-4000mm, 0 elsewhere; player index slot+1 on body co-located with skeleton; single filled human-shaped temporally-stable blob. NOT needed: accurate per-pixel gradients, finger detail, crisp edges, background geometry.
### §2.5 Failure modes
All-zero/out-of-band depth -> no-player/too-close/far gate. Player index absent -> player-gating games see no player. Silhouette<->skeleton misalignment -> intermittent rejection (guard: shared-intrinsics §1.1/§2.3). Flat depth -> depth gestures dead, silhouette/skeleton fine. Fragmented/flickering mask -> player-lost flaps (guard: largest-component+close+temporal hold). Wrong reported resolution -> buffer overrun (guard: report exact NUI_SURFACE_DESC/pitch).
## §3 NUI event/timing/buffer contract
### §3.1 Decision
One producer thread generates frames on a steady ~30Hz clock and signals the app's manual-reset events; consumer calls are fast copies/pointer-handoffs under a lock. Never block the producer on camera/MediaPipe; never call MediaPipe inside GetNextFrame.
### §3.2 Init sequence
NuiInitialize(flags) with USES_DEPTH_AND_PLAYER_INDEX|USES_COLOR|USES_SKELETON. Then NuiSkeletonTrackingEnable(hSkelEvent,flags) and NuiImageStreamOpen(type,res,flags,dwFrameLimit=2,hImgEvent,&hStream). Store the three app-supplied event handles; honor re-open resetting an existing stream.
### §3.3 Event cadence
Skeleton event [DOC]: manual-reset, SET when a new skeleton frame is available, RESET when the latest is returned. Producer SetEvent(hSkelEvent) per new frame; inside NuiSkeletonGetNextFrame, after handing over newest and none newer queued, ResetEvent. Image event: fired per new frame; the APP resets it before ReleaseFrame. Steady 33.33ms tick; if MediaPipe slower, still tick at 30Hz republishing the latest pose; keep stalls <~100ms.
### §3.4 NuiSkeletonGetNextFrame contract [DOC]
NULL frame -> E_POINTER. Fresh frame (or arrives within timeout) -> copy whole NUI_SKELETON_FRAME, S_OK. Timeout no data -> E_NUI_FRAME_NO_DATA unless SUPPRESS_NO_FRAME_DATA (block) or TITLE_SETS_TRACKED_SKELETONS (S_FALSE). Honor dwMillisecondsToWait (0 poll, N wait, INFINITE block) via WaitForSingleObject on an internal frame-ready event. Caller allocates the struct. Stamp per §3.6; run §1.6 smoothing before publishing.
### §3.5 Image stream + INuiFrameTexture lifetime [DOC]
NuiImageStreamGetNextFrame returns a DLL-owned NUI_IMAGE_FRAME; pFrameTexture is your INuiFrameTexture, valid until NuiImageStreamReleaseFrame. Ring of dwFrameLimit buffers; overwrite oldest on wrap. INuiFrameTexture is a COM object: LockRect->NUI_LOCKED_RECT{INT Pitch; int size; BYTE* pBits}, plus UnlockRect/BufferLen/Pitch/IUnknown. ReleaseFrame NULL texture -> E_NOINTERFACE; NULL args -> E_INVALIDARG. Pitch/size match reported eResolution (640x480 packed depth => pitch 640*2, size 640*480*2; color BGRA => pitch 640*4).
### §3.6 Frame numbers + timestamps [DOC]
dwFrameNumber: one global counter per depth tick; depth, color, skeleton all carry the most-recent depth frame's number. liTimeStamp: ms since NuiInitialize, steady (QPC), monotonic. Skeleton timestamp = the depth frame it derived from.
### §3.7 Threading
One producer (camera->MediaPipe->§1->§2->smoothing->publish under lock->SetEvent). Consumers call GetNextFrame/LockRect/ReleaseFrame. Guard published frame + image ring with a mutex, or lock-free double/triple buffer (pointer-swap publish). GetNextFrame never does heavy work.
## §4 Fidelity risk (MediaPipe skeletons vs scorer)
Lateral (x,y) strong; absolute depth/toward-away (z) weak (monocular, scale-ambiguous, noisy). 2D choreography scores well; depth-axis moves miss. Wrong global scale rescales limbs (angle-based scoring survives; position-threshold may not); keep joints in documented ranges or the skeleton is discarded. Mirror bit (§1.4) is binary make-or-break.
### §4.2 Mitigations (priority)
1. Lead with 2D (depthGain=0). 2. Calibrate at start (T-pose fixes Z0+scale+mirror). 3. Exaggerate depth (depthGain>1) when used. 4. Confidence-gate via visibility (INFERRED holds last). 5. Match the Kinect filter (§1.6). 6. Stay in-range + consistent (§2).
### §4.3 Cheap de-risk experiments
Confirm mirror bit (raise right arm). Confirm world-z sign (reach toward camera -> Kinect z should DECREASE; else negate depthGain). Confirm player-index gating (index 0 vs slot+1 - which the game accepts).
## §5 Open questions
1. [OPEN] depth+player-index at 640x480: 1.8 docs list 640/320/80; an older header lists only 320/80; native segmentation is 320x240. Do NOT hardcode - read eResolution; settle by logging DEA's request.
2. [OPEN] MediaPipe world-z sign/handedness - settle with the reach-toward-camera test (§4.3) before enabling depth relief.
3. [OPEN] DEA scoring internals / which streams it gates on - instrument the shim, selectively degrade each stream.
4. [OPEN] Does the game read bone orientations - log whether it calls NuiSkeletonCalculateBoneOrientations.
+326
View File
@@ -0,0 +1,326 @@
# webcam-kinect-emulator - Work Plan
## TL;DR (For humans)
<!-- Fill this LAST, after the detailed plan below is written, so it summarizes the REAL plan. -->
<!-- Plain English for a non-engineer: NO file paths, NO todo numbers, NO wave/agent/tool names. -->
**Who this is for and what changes for them:** You - someone who wants to play DanceEvolution Arcade (and other Kinect games) on your PC using just a normal webcam, with no Kinect sensor. Today the game won't even start without real Kinect hardware; after this, your webcam stands in for the Kinect and you can dance and be scored.
**What you'll get:** A "virtual Kinect" - software that makes your ordinary webcam look like a genuine Kinect sensor to the computer, so the real Kinect software tracks your body and the game plays normally. It's built to work on both Linux and Windows from one shared engine, with the game itself proven on your Windows machine.
**Why this approach:** We emulate the Kinect *device itself* (the thing plugged into USB), not the game's software - so it's operating-system-independent and any Kinect app works, and the real, unmodified Kinect software does the hard body-tracking from webcam-derived "depth." The one make-or-break unknown (will the real tracker accept webcam depth?) is tested first, cheaply, before heavy work.
**What it will NOT do:** It won't support the newer Kinect v2; it won't match arcade-perfect scoring (a single webcam judges depth less precisely than a real Kinect); and it won't bundle Microsoft's Kinect software or the game - you supply those.
**Effort:** XL
**Risk:** High - the core bet is that the real Kinect tracker accepts synthetic webcam depth, plus a self-built Windows USB driver (needs test-signing); both are front-loaded into early spikes.
**Decisions to sanity-check:** device-level emulation over faking the game's API; Windows needs test-signing (+ Secure Boot off) to load the virtual driver; the Linux skeleton-check tool (NiTE2) is abandonware you must supply, so the authoritative tracking proof is on Windows.
Your next move: run the default-on high-accuracy review (in progress), then execute with `/ulw-execute webcam-kinect-emulator`. Full execution detail follows below.
---
> TL;DR (machine): effort=XL risk=High; device-level virtual Kinect v1 (OS-agnostic USB emitter + webcam/MediaPipe synthetic-depth) with usbip-Linux/virtual-bus-Windows attach + API-shim fallback; 18 impl todos / 11 waves / F1-F5; proof target DanceEvolution Arcade.
## Scope
### Affected user and ideal state
<!-- From the draft ledger: who this touches and how they use the result, then one IS row per property with its reason, then one GAP row per difference with its reason. Every todo below closes a GAP row; ## Success criteria proves every IS row. -->
**Affected user:** The person who wants to play DanceEvolution Arcade (DEA) on Windows, and run other Kinect v1 apps, using only a normal RGB webcam - no Kinect hardware. Today: they cannot (DEA refuses to run without a real Kinect v1 sensor + the MS Kinect v1.8 runtime). After: a webcam presents as a virtual Kinect device, the real host Kinect stack skeletonizes the webcam-derived depth, and DEA (and other Kinect apps) play. Secondary consumer: the real host Kinect runtime (MS NUI on Windows, OpenNI2+NiTE on Linux), which must accept the virtual device and its synthetic depth. The emulator is OS-agnostic at its core; only a thin per-OS USB-attach shim differs.
| Row | Statement | Reason |
| --- | --- | --- |
| IS-1 | With only a webcam, the OS + the real Kinect runtime enumerate and initialize a "Kinect" as if hardware were attached | the core goal: the webcam presents as the device itself |
| IS-2 | Real-time body tracking at ~30 fps, low latency: the real host tracker skeletonizes the synthetic depth and the app sees moving joints | a dance game is unplayable if tracking lags/drops |
| IS-3 | The app's player-visible rendering (silhouette / depth / color image) shows the real player, not a blank/garbage frame | DEA and most Kinect apps display the player from depth/color |
| IS-4 | Move scoring is directionally correct: right moves score well, wrong moves don't (playable, not arcade-perfect) | scoring is the core loop; it depends on skeleton quality derived from our depth |
| IS-5 | The virtual Kinect is OS-agnostic: the same device core runs on Linux and Windows; only the per-OS USB-attach shim differs | the user's explicit architecture goal |
| IS-6 | Reproducible setup: attach the virtual device, start the generator, calibrate once, play - documented (incl. the Windows driver-signing step) | usable by the user, not a lab demo |
| IS-7 | Validated against REAL third-party Kinect apps: a Linux OpenNI2 app (enumeration + depth/color stream correctness; skeleton too IF the user supplied NiTE2), and DEA on Windows as the AUTHORITATIVE skeleton/fidelity proof | proves fidelity, not just "it enumerates"; Linux skeleton tracking is optional because NiTE2 is non-redistributable |
| IS-8 | Degrades gracefully (player leaves frame, poor light, mask noise) without crashing the host app | robustness in real play |
| IS-9 | An arbitrary unmodified third-party Kinect v1 app (beyond the validation sample) enumerates + tracks - proving general-purpose, not DEA-only | the user chose a general emulator; proven by a Kinect SDK sample (Windows, enumerate+track) + an OpenNI2 app (Linux, enumerate+depth; skeleton if NiTE2) distinct from the e2e harness |
| GAP-1 | No virtual Kinect device exists; nothing emits the Kinect v1 USB protocol | greenfield; closed by todos 1,3,8,9,12 |
| GAP-2 | No synthetic Kinect-data generator (webcam -> metric articulated depth + player-index + color) | greenfield; closed by todos 5,6,7 - the fidelity crux |
| GAP-3 | No per-OS USB attach (Linux vhci / Windows virtual bus) | greenfield; closed by todos 9,12 |
| GAP-4 | Unknown: will real host trackers (NiTE / NUI) skeletonize synthetic depth? exact USB descriptors/control? DEA bitness/streams? | closed by the spikes, todos 3,4 (gate the rest) |
| GAP-5 | No calibration/config (mount, floor, scale, mirror) | greenfield; closed by todo 11 |
| GAP-6 | No library-layer fallback where device-level attach is impractical | greenfield; closed by todos 14,15 (spike-gated) |
| GAP-7 | No end-to-end validation path, robustness handling, packaging or docs | greenfield; closed by todos 10,13,16,17,18 |
### Must have
- An OS-agnostic virtual Kinect v1 device core emitting the real Kinect USB streams (depth + color + IR + minimal audio + control/descriptors), driven by a webcam + MediaPipe synthetic-depth generator, so the real host Kinect stack computes the skeleton and unmodified Kinect apps (DEA first) work.
- Per-OS virtual-USB attach: USB/IP (vhci) on Linux (primary dev + validation), virtual USB bus driver on Windows (DEA target).
- Synthetic-depth generator: articulated metric depth + packed player-index + color passthrough from webcam + MediaPipe 3D pose + segmentation.
- Joint mapping + coordinate intrinsics + Holt smoothing (for depth/skeleton consistency and the fallback shim).
- Calibration + config; frozen/versioned IPC data contract; record/replay test harness.
- Per-OS library-layer fallback (OpenNI2 virtual driver on Linux / clean-room Kinect10.dll NUI shim on Windows) reusing the generator, where device-level attach is impractical.
- Linux end-to-end validation against a real OpenNI/NiTE app; real in-game DEA QA on the user's Windows box; setup docs incl. the Windows signing step.
### Must NOT have (guardrails, anti-slop, scope boundaries)
- No Kinect v2 (libfreenect2) support - v1 only (DEA uses Kinect for Windows 1.8).
- No high-level SDK add-ons DEA does not use: Face Tracking SDK, Kinect Fusion, Kinect Interactions/gesture DB. (Core NUI audio-source enumeration is in scope; beamforming/DMO is not.)
- No productized/WHQL-signed driver distribution - personal-use test-signing only.
- No non-Kinect input emulation (no keyboard/gamepad mapping of dance moves); no networked/online/e-amusement/card-server features.
- No pursuit of arcade-perfect scoring parity - target is playable + directionally-correct, bounded by monocular-depth fidelity.
- Do NOT add retries, sleeps, timeouts, caps, or locks without an evidenced cause named in the todo; async waits subscribe to the exact event, never a fixed delay.
## Verification strategy
> Agent-executed wherever the platform allows; a small, explicitly-named set of Windows/in-game steps require the user's Windows box and are human-assisted acceptance (the one unavoidable manual surface - the game is a closed Windows binary).
- Test decision: **tests-after for integration/protocol todos, TDD for the pure math todos** (coordinate transform, smoothing, depth packing - golden-vector unit tests). Frameworks: GoogleTest/CTest (C++ core) run on Linux CI; pytest (Python tracker); CTest harness replay for DLL/device.
- Linux is the primary automated-QA environment for ENUMERATION + depth/color STREAM correctness (OpenCV, MediaPipe, usbip/vhci, OpenNI2 - all FOSS and runnable here). NiTE2 (the Linux skeleton tracker) is EOL/abandonware and NOT redistributable: it is used only if the USER already supplies an install, and is NEVER bundled. Therefore the skeleton-from-synthetic-depth CRUX is proven AUTHORITATIVELY on Windows (the real MS NUI runtime, todo 13/F5); the Linux skeleton check (via user-supplied NiTE2) is best-effort de-risking, not the gate.
- WSL2 caveat: usbip/`vhci-hcd` are often absent from the default WSL2 kernel. Spike 3's FIRST action checks this; if absent, the Linux attach path needs a custom WSL kernel or a native-Linux host (flagged, not silently assumed).
- The automated end-to-end Linux run uses a PRE-RECORDED dance video injected as the webcam via `v4l2loopback` (or the tracker's file input) - NEVER a live human - so it is deterministic and agent-executable. A moving human is required only for the final Windows DEA playability acceptance (F5).
- Windows-only, human-assisted steps (flagged per-todo): loading the virtual-USB bus driver (needs test-signing + Secure Boot off), the MS Kinect SDK sample tracking, and DEA launch/playability/scoring. Agent-executable parts of those todos (cross-compiled build success, `dumpbin` output, logging-shim capture, packaged artifacts) still produce evidence; only the in-game acceptance needs the user.
- Determinism: time/faults driven by a fake clock + injected faults + recorded fixtures (record/replay harness, todo 16); NO real sleeps/waits in tests; async waits subscribe to the exact frame-ready event with a bounded timeout.
- Evidence root: `.omo/evidence/task-<N>-webcam-kinect-emulator.<ext>` (logs, test output, pcap/usbmon captures, screenshots/recordings for in-game steps).
## Execution strategy
### Parallel execution waves
> Two todos share a wave unless one reads what the other produces or both write the same file/artifact/port. Linux-first: enumeration + stream correctness is validated on this Linux box (waves 2-8) before the Windows waves (9-10). **The depth-fidelity crux is a KILL-GATE, tested by spike 3 (Linux, IF NiTE2 is user-supplied) OR spike 4 (Windows MS NUI runtime): if neither confirms that a real host tracker can skeletonize synthetic depth, HALT and re-plan the depth model (e.g. a monocular-depth net) before committing waves 4-11.** Spike 4 also gates the Windows device-vs-shim decision. The two fallbacks (14,15) are UNCONDITIONALLY in scope (general-purpose goal); the spikes set their PRIORITY/order, not whether they are built.
- Wave 1: 1 (scaffold + build system - shared setup, blocks all)
- Wave 2: 2 (IPC contract), 3 (Linux spike), 4 (Windows/DEA spike)
- Wave 3: 5 (tracker), 6 (mapping+smoothing), 16 (record/replay harness)
- Wave 4: 7 (synth depth/player-index/color rasterizer)
- Wave 5: 8 (Kinect v1 USB protocol emitter)
- Wave 6: 9 (Linux USB attach), 15 (Linux OpenNI2 fallback)
- Wave 7: 10 (Linux end-to-end validation)
- Wave 8: 11 (calibration/config), 17 (robustness/graceful degradation)
- Wave 9: 12 (Windows USB attach), 14 (Windows NUI shim fallback)
- Wave 10: 13 (Windows integration + DEA playability)
- Wave 11: 18 (packaging + docs)
### Dependency matrix
| Todo | Writes (files, shared state) | Depends on (reason) | Blocks |
| --- | --- | --- | --- |
| 1 | repo layout, CMake, Python env, CI | - | all |
| 2 | core/contract/*.h (frozen IPC structs) | 1 | 5,6,7,8,14,15,16 (shared data contract) |
| 3 | spike report: Linux USB descriptors + NiTE-accepts-synthetic-depth | 1 | 8 (exact protocol), 15 (fallback decision) |
| 4 | spike report: DEA bitness/streams/flags, usbip-win binding, Windows synthetic-depth skeletonization | 1 | 7 (crux gate if NiTE2 absent), 12,13,14 (Windows path + fallback scope) |
| 5 | tracker/ (Python MediaPipe->IPC) | 2 | 7,10,13,17 (provides pose+mask) |
| 6 | core/mapping/ (transform+Holt smoothing) | 2 | 7,14 (depth/skeleton math) |
| 7 | core/synth/ (depth+player-index+color raster) | 5,6 (+ soft crux-gate: spike 3 if NiTE2 else spike 4) | 8,14,15 (frame data) |
| 8 | core/protocol/ (Kinect USB emitter) | 3,7 | 9,12 (device byte stream) |
| 9 | attach/linux (usbip/vhci) | 8,3 | 10 |
| 10 | Linux e2e validation + evidence | 9,5 | 11,17 (proven device) |
| 11 | core/calibration + config | 10 | 13 (needs calibrated device) |
| 12 | attach/windows (usbip-win/bus driver) | 8,4 | 13 |
| 13 | Windows integration + DEA QA evidence | 12,5,7,11 | 18 |
| 14 | fallback/windows-nui (Kinect10.dll shim) | 6,7,4 | 13 (fallback path) |
| 15 | fallback/linux-openni2 (OpenNI2 module) | 7,2 | - (fallback + general emulator) |
| 16 | tools/record-replay + mock host | 2 | 10,13 (test infra) |
| 17 | robustness handling across tracker+synth | 5,7,10 | 18 |
| 18 | docs/ + packaging | 10,13 | - |
## Todos
> Implementation + Test = ONE todo. Never separate.
<!-- APPEND TASK BATCHES BELOW THIS LINE WITH edit/apply_patch - never rewrite the headers above. -->
- [ ] 1. Repo scaffold, cross-platform build system, CI
What to do / Must NOT do: Create the project layout (`core/` {protocol,synth,mapping,contract}, `tracker/`, `attach/{linux,windows}`, `fallback/{linux-openni2,windows-nui}`, `tools/{logging-shim,record-replay,mock-nui-host}`, `tests/`, `docs/`). CMake for the C/C++ core with three targets: Linux-native (GCC/Clang), Windows cross (MinGW-w64/clang-cl) for fast local builds, and an MSVC build profile (authoritative, run on the user's Windows box). Scaffold BOTH x86 and x64 Windows targets; the SHIPPING Windows arch (DEA is likely x86) is confirmed from spike 4's `dumpbin` bitness before todos 12/14 build the real driver/shim. Treat MinGW-w64 CI builds as a SMOKE signal only - MSVC on the user's box is authoritative for shim/driver ABI acceptance. Python project (pyproject/requirements) for the tracker. `git init`. GitHub-Actions-or-local CI running the Linux C++ unit tests + pytest. Add a clean-room notice (public NuiApi.h + libfreenect protocol are interface facts; all synthesis code written fresh). Must NOT: vendor GPLv3 KinectFaker/NiVirtualCam source into the tree (reference only).
Closes: GAP-1 (foundation)
Parallelization: Wave 1 | Blocked by: none | Blocks: all
References: draft `.omo/drafts/webcam-kinect-emulator.md` (Decisions D5,D6); libfreenect build layout github.com/OpenKinect/libfreenect; CMake cross-compile with MinGW-w64 toolchain file.
Acceptance criteria (agent-executable): `cmake -S core -B build/linux && cmake --build build/linux` exits 0; `cmake -S core -B build/win --toolchain cmake/mingw-w64.cmake && cmake --build build/win` exits 0 producing a `.dll`; `pytest -q` collects 0 tests without error; CI config present and green on Linux.
QA scenarios: happy - fresh clone builds both targets (capture `cmake --build` logs). failure - break a CMake target on purpose, confirm CI fails red, then revert. Evidence `.omo/evidence/task-1-webcam-kinect-emulator.log`
Commit: Y | chore(scaffold): project layout, cross-platform build, CI
Recommended task executor category: unspecified-high - multi-file build/CI setup across languages.
- [ ] 2. Frozen, versioned IPC data contract
What to do / Must NOT do: Define the shared-memory frame contract in `core/contract/` (C header + a generated Python mirror): a triple-buffered, newest-wins frame slot with a monotonic sequence counter, plus fields for the skeleton (20 joints Vector4 + per-joint tracking state + tracking id + quality flags), a depth+player-index buffer descriptor, a color buffer descriptor, frame number, and a QPC-derived timestamp; and a control-plane message schema (handshake/version, config push, calibration, heartbeat) over a named pipe / unix socket. `static_assert` every struct size and field offset; embed a contract version constant; forbid implicit padding (explicit `#pragma pack` or manual padding). Must NOT: put per-frame data on the control channel; allow the Python mirror to drift (generate/check it against the C header in CI).
Closes: GAP-2 (shared substrate)
Parallelization: Wave 2 | Blocked by: 1 | Blocks: 5,6,7,8,14,15,16
References: `.omo/design/architecture.md` (Transport: lock-free newest-wins + frozen contract); `.omo/design/nui-contracts.md` §3.6 (frame number + timestamp semantics), §1.7 (per-joint state fields); Kinect `NUI_SKELETON_FRAME`/`NUI_SKELETON_DATA` field list.
Acceptance criteria (agent-executable): C++ unit test asserting `sizeof`/`offsetof` for every contract struct matches a golden table; a CI check that the Python mirror's struct layout equals the C header (ctypes sizeof/offset comparison) exits 0.
QA scenarios: happy - layout test passes on Linux + Windows-cross builds. failure - change one field type, confirm the static_assert/layout test fails. Evidence `.omo/evidence/task-2-webcam-kinect-emulator.log`
Commit: Y | feat(contract): frozen versioned IPC frame + control schema
Recommended task executor category: unspecified-low - contained, single-module, well-specified.
- [ ] 3. Spike - Linux USB protocol + "does NiTE skeletonize synthetic depth"
What to do / Must NOT do: FIRST verify this host can do USB/IP at all - `modprobe vhci-hcd && lsmod | grep vhci` (on WSL2 this module is frequently absent; if so, RECORD that the Linux attach path needs a custom WSL kernel or a native-Linux host, and proceed with what can be probed). Then stand up a MINIMAL usbip/vhci virtual device that replays a canned libfreenect-format depth+color stream (no webcam yet) and attach it so `freenect-glview` / OpenNI2 (OpenNI2-FreenectDriver) enumerates it. Capture the exact USB descriptors, control transfers, EEPROM/register reads, iso/bulk framing, the **composite-device interface topology (camera + audio + motor)**, and the **firmware-upload handshake** the host performs to init a Kinect v1 (usbmon/wireshark). Then, IF the user supplied NiTE2 (EOL/non-redistributable - do not bundle), feed a RECORDED real-person depth sequence and a SYNTHETIC articulated-depth sequence and record whether NiTE produces a stable skeleton from each. Output a spike report (findings + the minimal descriptor/control set; and - only if NiTE2 was available - a go/no-go on "synthetic depth is skeletonizable") into `docs/spike-linux.md`. If NiTE2 is NOT available, this spike proves enumeration + stream correctness only, and the skeletonization crux is evaluated by spike 4 on the real Windows MS NUI runtime instead (the crux KILL-GATE is satisfied by whichever of spike 3 or spike 4 can first test it; if NEITHER can before build waves, that is itself a HALT-and-re-plan condition). Must NOT: build the full emitter here - this is a throwaway probe to de-risk todo 8 and the GAP-4 fidelity crux.
Closes: GAP-4 (Linux half)
Parallelization: Wave 2 | Blocked by: 1 | Blocks: 8,15
References: libfreenect USB protocol (github.com/OpenKinect/libfreenect `src/`), OpenNI2-FreenectDriver; usbip/vhci-hcd kernel docs; NiTE2 skeleton sample.
Acceptance criteria (agent-executable): `docs/spike-linux.md` exists with the descriptor/control dump + the vhci capability result + (if NiTE2 available) a recorded skeleton result for synthetic depth; `freenect-glview` (or OpenNI SimpleViewer) renders the virtual device's depth (screenshot/log captured).
QA scenarios: happy - virtual device enumerates and its depth renders in an OpenNI2 viewer (+ a skeleton app tracks from synthetic depth if NiTE2 available). failure - document the failure mode if the tracker rejects synthetic depth, or if vhci is unavailable, with the gap that caused it (scopes todo 7 / Linux-attach feasibility). Evidence `.omo/evidence/task-3-webcam-kinect-emulator.*`
Commit: Y | chore(spike): linux usb protocol + synthetic-depth skeletonization probe
Recommended task executor category: deep-high - protocol reverse-engineering + the central feasibility uncertainty.
- [ ] 4. Spike - Windows/DEA behavior + bitness
What to do / Must NOT do: On the user's Windows box: build a pass-through logging `Kinect10.dll` (forwards every NUI call to the real one, logs name/args/flags/resolution/return + which events it waits on), place it beside `gamekdm.dll`, and capture DEA's exact NUI call sequence: `NuiInitialize` flags, which image streams it opens (depth/player-index? color?), resolutions, skeleton-vs-poll model. Run `dumpbin /headers /imports gamekdm.dll` to record 32- vs 64-bit and the exact `Kinect10.dll` imports. Also probe WINDOWS DEVICE-LEVEL viability: attach a minimal usbip-win virtual device with the Kinect VID/PID + composite topology and verify the real `kinectsensor.inf` driver + MS NUI runtime enumerate and bind to it (this gates todo 12), recording what the MS driver requires BEYOND libfreenect's Linux init (firmware/composite/power). THEN - the Windows half of the depth-fidelity CRUX - extend that minimal virtual device to replay a canned SYNTHETIC articulated-depth sequence (NO physical Kinect) into the real MS NUI runtime and capture whether a Kinect SDK sample (SkeletonBasics / KinectExplorer) produces a MOVING skeleton from it. This is the executable synthetic-depth skeletonization test that unblocks Waves 4-11 when NiTE2 is unavailable on Linux; if it fails, HALT and re-plan the depth model. If a real Kinect is available, also A/B real vs. synthetic depth to gauge the scorer's z-sensitivity. Output `docs/spike-windows.md` with bitness, the required import surface, the stream/flag list, the usbip-win binding result, the synthetic-depth skeletonization result, and a go/no-go per OS for device-level vs. the NUI-shim fallback. Must NOT: modify the game binary; this only shadows the DLL; claim the crux passed without captured skeleton output.
Closes: GAP-4 (Windows half + the Windows synthetic-depth skeletonization crux)
Parallelization: Wave 2 | Blocked by: 1 | Blocks: 7 (crux gate when NiTE2 absent),12,13,14
References: `.omo/design/architecture.md` (Top risks A/B + Sequencing: logging shim + dumpbin); `.omo/design/nui-contracts.md` §3.2 (init sequence), §5 (open questions the log resolves); P3dro200 install (spice2x + Kinect v1.8).
Acceptance criteria (agent-executable on Windows, hardware-free): `docs/spike-windows.md` records DEA bitness, the `Kinect10.dll` import list, the `NuiInitialize` flags, and the opened streams/resolutions, each backed by a captured log line; `dumpbin` output archived; AND a captured moving-joint skeleton output from the real MS NUI runtime fed the minimal virtual device's synthetic-depth replay (no physical Kinect), proving synthetic depth is skeletonizable - or a documented HALT if it is not.
QA scenarios: happy - logging shim loads into DEA (DllMain attach logged) and captures the call sequence through to gameplay (with the spice2x Kinect-bypass to boot). failure - if the shim is not the loaded module (search-order/COM), document how the real DLL is resolved and the workaround. Evidence `.omo/evidence/task-4-webcam-kinect-emulator.*`
Commit: Y | chore(spike): windows/DEA nui call-pattern + bitness capture
Recommended task executor category: deep-high - behavioral RE of a closed binary, gates the Windows design.
- [ ] 5. Webcam tracker (MediaPipe pose + segmentation -> IPC)
What to do / Must NOT do: Python tracker: OpenCV webcam capture -> MediaPipe Pose (Full/Heavy, GPU if available else CPU) producing 33 normalized landmarks + 33 world-landmarks (meters) + per-landmark visibility + the segmentation mask, published to the shared-memory contract (todo 2) at the newest-wins slot each frame, plus control-plane handshake/heartbeat. MEASURE actual fps for each model tier (Lite/Full/Heavy) on this box (CPU, and GPU if present) and SELECT the tier from measured evidence to hit >= ~25 fps (30 target); if no tier reaches it on CPU, record a GPU requirement rather than asserting throughput. If inference is slower than the cadence, still publish at a steady rate by re-publishing the latest pose (todo 17 refines held-frame behavior). Must NOT: block on inference inside the publish path; add fixed sleeps - pace with a monotonic frame clock; assert fps without a measurement.
Closes: GAP-2 (capture half)
Parallelization: Wave 3 | Blocked by: 2 | Blocks: 7,10,13,17
References: MediaPipe Pose Landmarker docs (33-landmark table, world-landmark + mask output); draft Findings (MediaPipe stack); contract header (todo 2).
Acceptance criteria (agent-executable): `pytest tracker/` passes; a smoke run against a recorded video file (not a live cam, for determinism) publishes frames whose landmark/mask fields parse per the contract; measured publish rate >= 25 fps on CPU for the recorded input.
QA scenarios: happy - replay a fixture video, assert N published frames with plausible landmark ranges + non-empty mask. failure - feed a frame with no person, assert the tracker publishes a "no body" frame (visibility low) rather than crashing. Evidence `.omo/evidence/task-5-webcam-kinect-emulator.log`
Commit: Y | feat(tracker): mediapipe pose+segmentation to IPC
Recommended task executor category: unspecified-high - standard multi-file CV pipeline.
- [ ] 6. Joint mapping + coordinate intrinsics + Holt smoothing (pure, TDD)
What to do / Must NOT do: In `core/mapping/`, implement (clean-room, from the documented formulas) the Kinect depth<->skeleton intrinsics (`NuiTransformDepthImageToSkeleton` inverse + `NuiTransformSkeletonToDepthImage` forward), the MediaPipe-33 -> Kinect-20 joint map incl. synthesized joints (HIP_CENTER/SPINE/SHOULDER_CENTER/HEAD/HAND per `.omo/design/nui-contracts.md` §1.2), a global mirror bit, per-joint depth placement (Z0 + depthGain*worldZ), per-joint tracking-state from visibility, and the Holt double-exponential smoothing with the 5 NUI_TRANSFORM_SMOOTH_PARAMETERS fields. TDD: golden-vector unit tests (projection round-trips <1mm; smoothing step matches reference sequence). Must NOT: double-flip left/right (mirror handled once, globally); emit joints outside documented ranges (x+-2.2, y+-1.6, z 0-4).
Closes: GAP-2 (math half)
Parallelization: Wave 3 | Blocked by: 2 | Blocks: 7,14
References: `.omo/design/nui-contracts.md` §1.1-1.6 (exact formulas, mapping table, smoothing algorithm + params {0.6,0.4,0.4,0.04,0.07} recommended), §1.7 (state fields); Kinect `NuiSkeleton.h` inline transforms (interface facts).
Acceptance criteria (agent-executable): `ctest -R mapping` passes: forward/inverse round-trip < 1mm on a vector set; a 33-landmark fixture maps to 20 joints matching golden positions; smoothing output matches a precomputed golden sequence; out-of-range inputs are clamped per spec.
QA scenarios: happy - golden-vector suite green. failure - feed a landmark set with an occluded (visibility 0) wrist, assert it is marked INFERRED and holds its last position (no snap to origin). Evidence `.omo/evidence/task-6-webcam-kinect-emulator.log`
Commit: Y | feat(mapping): nui intrinsics, 33->20 map, holt smoothing
Recommended task executor category: deep-low - math-heavy but fully settleable from the cited contracts.
- [ ] 7. Synthetic depth + player-index + color rasterizer
What to do / Must NOT do: In `core/synth/`, turn the tracker's mask + 3D pose (via todo 6) into Kinect image frames: a packed depth buffer (`(mm&0x1FFF)<<3 | player&0x7`) at the resolution the host requests, body pixels = articulated metric depth (bone capsules at their z, silhouette-masked; billboard-gradient default per `.omo/design/nui-contracts.md` §2.3), background = 0; player-index = skeletonSlot+1 on body pixels; color = webcam passthrough (BGRA at requested res); optional IR. Largest-connected-component + morphological close + temporal hold for a stable blob. Must NOT: hardcode 640x480 - synthesize at the requested `eResolution`; leave body depth at 0 or out of ~[800,4000]mm (reads as no player).
Closes: GAP-2 (synthesis half)
Parallelization: Wave 4 | Blocked by: 5,6 (soft-gated by the crux test - spike 3 if NiTE2 available, else spike 4 Windows MS NUI: if synthetic depth is NOT skeletonizable, HALT and re-plan the depth model before building this todo) | Blocks: 8,14,15
References: `.omo/design/nui-contracts.md` §2.1-2.5 (packing, rasterization tiers, min fidelity, failure modes); spike-linux findings (todo 3) for the fidelity bar the host tracker needs.
Acceptance criteria (agent-executable): `ctest -R synth` passes - pack/unpack round-trips, a fixture mask+pose yields a depth buffer whose body pixels are in-band and carry player index, whose projected joints (todo 6 forward transform) land inside the silhouette.
QA scenarios: happy - fixture produces a human-shaped in-band blob; projected skeleton overlays it. failure - feed a fragmented mask, assert largest-component + close yields a single stable blob (not multiple/flicker). Evidence `.omo/evidence/task-7-webcam-kinect-emulator.*`
Commit: Y | feat(synth): packed depth+player-index+color rasterizer
Recommended task executor category: deep-low - format + raster math from cited contracts.
- [ ] 8. Kinect v1 USB protocol emitter (device core)
What to do / Must NOT do: In `core/protocol/`, implement the OS-agnostic virtual Kinect: respond to the USB descriptors/control transfers/EEPROM-register reads the host driver needs to enumerate+init a Kinect v1 (per the todo-3 spike + libfreenect), and emit depth/color (+IR, + minimal audio-interface enumeration) over the device's iso/bulk endpoints, pulling frame data from the synth rasterizer (todo 7) via the contract. Expose a transport-agnostic "USB device backend" interface so the Linux (todo 9) and Windows (todo 12) attach shims plug in. Must NOT: emit a skeleton (the device never does - the host computes it); block the emit loop on the generator (use the newest-wins slot).
Closes: GAP-1 (device byte stream)
Parallelization: Wave 5 | Blocked by: 3,7 | Blocks: 9,12
References: libfreenect protocol source (descriptors, modes, framing); draft Finding (device outputs depth/color/IR/audio, skeleton is host-side); spike-linux.md (exact control set).
Acceptance criteria (agent-executable): a host-side libfreenect client (or the OpenNI2-FreenectDriver) opened against the emitter (via the Linux attach, todo 9) reads the expected depth+color stream at ~30fps with correct frame geometry; unit tests for descriptor/control responses pass.
QA scenarios: happy - libfreenect `freenect-glview` shows live synthetic depth+color through the emitter. failure - request an unsupported mode/resolution, assert a correct USB-level stall/error rather than a crash. Evidence `.omo/evidence/task-8-webcam-kinect-emulator.*`
Commit: Y | feat(protocol): kinect v1 virtual usb device emitter
Recommended task executor category: deep-high - protocol fidelity is central and failure-prone.
- [ ] 9. Linux USB attach (usbip/vhci)
What to do / Must NOT do: In `attach/linux/`, bind the todo-8 emitter as a virtual USB device via USB/IP (userspace server speaking the Kinect descriptors) attached through `vhci-hcd`, or raw-gadget if simpler; provide attach/detach lifecycle + a CLI. Must NOT: require out-of-tree kernel modules beyond stock usbip/vhci.
Closes: GAP-3 (Linux half)
Parallelization: Wave 6 | Blocked by: 8,3 | Blocks: 10
References: usbip tools + vhci-hcd; spike-linux.md; Linux raw-gadget docs.
Acceptance criteria (agent-executable): after `attach/linux` brings the device up, `lsusb` shows the Kinect VID/PID and `freenect-micview`/OpenNI enumerates it; detach cleanly removes it.
QA scenarios: happy - attach -> device present -> OpenNI opens it. failure - kill the emitter mid-session, assert the attach shim detaches cleanly (no stuck vhci port). Evidence `.omo/evidence/task-9-webcam-kinect-emulator.log`
Commit: Y | feat(attach-linux): usbip/vhci virtual kinect attach
Recommended task executor category: deep-low - integration against a known mechanism.
- [ ] 10. Linux end-to-end validation (the fidelity proof)
What to do / Must NOT do: Wire tracker (5) -> synth (7) -> emitter (8) -> Linux attach (9), driving the webcam path with a PRE-RECORDED dance video via `v4l2loopback` (or the tracker's file input) - NOT a live human - for determinism and agent-executability. Point a host skeleton tracker at the virtual Kinect: OpenNI2 + NiTE2 IF the user supplied NiTE2 (EOL/not redistributable - never bundled), else validate ENUMERATION + depth/color stream correctness on Linux only. The skeletonization crux is proven UPSTREAM (spike 3 if NiTE2 present, else spike 4's Windows synthetic-depth test) - this todo does NOT carry it and does NOT defer it to any post-gate work. Capture a recorded session as evidence. Must NOT: use a live human for this automated run; claim the crux proven here.
Closes: GAP-7 (Linux validation), proves IS-1,7 on Linux (and IS-2's Linux half only if NiTE2 supplied; otherwise IS-2 is proven by spike 4 + todo 13)
Parallelization: Wave 7 | Blocked by: 9,5 | Blocks: 11,17
References: NiTE2 UserViewer/skeleton sample; todos 5,7,8,9.
Acceptance criteria (agent-executable): with the recorded video as input, either (a) NiTE2 (if user-supplied) tracks a skeleton that follows the recorded subject, OR (b) an OpenNI2 depth consumer shows correct per-pixel depth+player-index and the device enumerates - with end-to-end latency + fps logged. The skeletonization crux is NOT carried here (proven upstream by spike 3 or spike 4).
QA scenarios: happy - the recorded subject's arm-raise is reflected in the tracked skeleton (NiTE) or in the depth silhouette (OpenNI2). failure - the recorded subject leaves frame, assert player-lost then recovery on return (no crash). Evidence `.omo/evidence/task-10-webcam-kinect-emulator.*`
Commit: Y | test(e2e-linux): webcam->virtual kinect stream+skeleton validation
Recommended task executor category: deep-low - end-to-end integration debugging on Linux.
- [ ] 11. Calibration + config
What to do / Must NOT do: In `core/calibration/`, add a one-time calibration (T-pose) fixing Z0 (root depth / scale via shoulder-width target), floor plane, camera mirror bit, and player-space scaling; persist a config file (resolutions, depthGain, smoothing params, mirror, Z0). Add a confirm step for the mirror bit (raise-right-arm check). Must NOT: bake machine-specific constants into source - keep them in config.
Closes: GAP-5
Parallelization: Wave 8 | Blocked by: 10 | Blocks: 13
References: `.omo/design/nui-contracts.md` §1.4 (mirror bit), §1.5 (Z0/scale calibration), §4.2 (calibrate at start).
Acceptance criteria (agent-executable): a calibration run on a recorded T-pose fixture writes a config whose Z0 yields reconstructed shoulder width within tolerance of the target; reloading config reproduces identical transforms.
QA scenarios: happy - calibrate from fixture, verify skeleton scale correct. failure - calibrate with no person in frame, assert a clear error + no corrupt config written. Evidence `.omo/evidence/task-11-webcam-kinect-emulator.log`
Commit: Y | feat(calibration): T-pose scale/floor/mirror config
Recommended task executor category: unspecified-high - contained feature with real edge cases.
- [ ] 12. Windows USB attach (virtual bus driver)
What to do / Must NOT do: In `attach/windows/`, present the todo-8 emitter to Windows via usbip-win (or a UMDF/KMDF virtual USB bus driver) so the real MS Kinect driver (kinectsensor.inf) + `Kinect10.dll` see a Kinect. Document the test-signing / signature-enforcement steps. Must NOT: ship an unsigned driver as if production-ready - personal-use test-signing only, clearly documented.
Closes: GAP-3 (Windows half)
Parallelization: Wave 9 | Blocked by: 8,4 | Blocks: 13
References: usbip-win project; Windows UMDF/KMDF virtual-bus samples; WDK; spike-windows.md.
Acceptance criteria (on the user's Windows box, human-assisted): Device Manager shows the Kinect under the MS Kinect driver; the Kinect SDK's `KinectExplorer`/`SkeletonBasics` sample enumerates the sensor. Agent-executable part: the driver + usbip-win artifacts build (cross/MSVC).
QA scenarios: happy - attach -> SkeletonBasics tracks a skeleton from the webcam. failure - detach while an app holds the sensor, assert graceful device-removal (app sees sensor-unplugged, no BSOD). Evidence `.omo/evidence/task-12-webcam-kinect-emulator.*` (screenshots/logs)
Commit: Y | feat(attach-windows): virtual usb bus attach + signing docs
Recommended task executor category: deep-high - Windows driver work + signing, high risk.
- [ ] 13. Windows integration + DanceEvolution Arcade playability
What to do / Must NOT do: On the user's Windows box, verify DEA via the DEVICE path: tracker -> synth -> emitter -> Windows virtual-USB attach (todo 12). This DEVICE path is what proves IS-1 (the OS/runtime enumerates the sensor) and IS-2 (the real MS NUI runtime skeletonizes synthetic depth) in addition to gameplay (silhouette, tracked moves, directionally-correct scoring). SEPARATELY, the NUI-shim (todo 14) is an independent path that proves ONLY playability (IS-3/IS-4) via direct injection - it does NOT satisfy IS-1 or IS-2. If the DEVICE path (todo 12) cannot be achieved, HALT and re-plan rather than accepting shim gameplay as proof of IS-1/IS-2. Capture a gameplay recording for whichever path(s) run. Must NOT: claim IS-1/IS-2 proven from the shim path; claim playable without a recorded scoring session.
Closes: GAP-7 (Windows validation), proves IS-1,2,3,4,7 on Windows
Parallelization: Wave 10 | Blocked by: 12,5,7,11 (or 14) | Blocks: 18
References: spike-windows.md (streams DEA needs); `.omo/design/nui-contracts.md` §4 (fidelity mitigations, mirror/z-sign checks); P3dro200 install steps.
Acceptance criteria (human-assisted on Windows): DEVICE path - Device Manager shows the sensor (IS-1) and DEA plays via the real NUI runtime skeletonizing synthetic depth (IS-2), recorded showing silhouette + tracked moves + a score that rises for correct dancing and not wrong; mirror-bit + z-sign checks (`.omo/design/nui-contracts.md` §4.3) pass. SHIM path (if run) - DEA plays via injected skeleton, recorded, explicitly labelled NOT evidence for IS-1/IS-2.
QA scenarios: happy - play a song, correct moves score. failure - stand still during a step, assert the game registers misses (not false hits), proving the skeleton reflects reality. Evidence `.omo/evidence/task-13-webcam-kinect-emulator.*` (gameplay capture)
Commit: Y | test(e2e-windows): DEA playable via webcam virtual kinect
Recommended task executor category: deep-high - cross-stack integration + the decisive feasibility proof.
- [ ] 14. Windows NUI-shim fallback (clean-room Kinect10.dll)
What to do / Must NOT do: In `fallback/windows-nui/`, a clean-room drop-in `Kinect10.dll` implementing the NUI surface the spike (todo 4) found DEA imports: `NuiInitialize/Shutdown`, `NuiGetSensorCount`, `NuiCreateSensorByIndex/Id`, `INuiSensor`, `NuiSkeletonTrackingEnable/GetNextFrame`, `NuiImageStreamOpen/GetNextFrame/ReleaseFrame`, `INuiFrameTexture` COM object, `NuiTransformSmooth`, coordinate mappers - injecting skeleton (from todo 6) + depth/color (from todo 7) directly, honoring the ~30Hz event model. This fallback is UNCONDITIONALLY in scope (general-purpose goal); spike 4 sets whether it is the PRIMARY Windows path or the secondary surface, not whether it is built. Must NOT: fake fewer exports than DEA imports; get `__stdcall` decoration / struct packing / COM vtable order wrong (bit-for-bit per public NuiApi.h); open GPLv3 source (KinectFaker) while implementing - clean-room firewall.
Closes: GAP-6 (Windows fallback)
Parallelization: Wave 9 | Blocked by: 6,7,4 | Blocks: 13 (fallback path)
References: `.omo/design/nui-contracts.md` §3 (full event/timing/COM-texture contract, GetNextFrame semantics, frame numbers/timestamps), §1-2 (skeleton+depth it serves). The NUI export surface is derived SOLELY from the public NuiApi.h (Kinect SDK 1.8 headers) + spike-4's observed import list; the implementing executor MUST NOT read KinectFaker's GPLv3 source (clean-room firewall).
Acceptance criteria: the mock NUI host (todo 16) drives the full call sequence against the shim and receives correctly-timed skeleton+image frames; on Windows, placing the DLL beside a Kinect SDK sample makes it track without a sensor.
QA scenarios: happy - mock host gets 30Hz skeleton frames with correct frame numbers/timestamps. failure - app calls an unimplemented export, assert `E_NOTIMPL` (not a crash) and log it for coverage. Evidence `.omo/evidence/task-14-webcam-kinect-emulator.*`
Commit: Y | feat(fallback-nui): clean-room kinect10.dll shim
Recommended task executor category: deep-high - ABI-exact Windows DLL, large cohesive surface.
- [ ] 15. Linux OpenNI2 virtual-device fallback / general emulator
What to do / Must NOT do: In `fallback/linux-openni2/`, an OpenNI2 device-driver module exposing the synth streams (depth/color + the mask) as an OpenNI2 device, so OpenNI/NiTE apps work even without the usbip path; doubles as the Linux general-emulator surface (IS-9). UNCONDITIONALLY in scope (general-purpose goal); spike 3 sets priority/order, not whether it is built. Must NOT: duplicate synth logic - consume `core/synth`; bundle NiTE2 (EOL/not redistributable).
Closes: GAP-6 (Linux fallback)
Parallelization: Wave 6 | Blocked by: 7,2 | Blocks: none
References: OpenNI2 driver API (OniDriverApi), OpenNI2-FreenectDriver structure; NiVirtualCam (reference).
Acceptance criteria (agent-executable): registering the module, an OpenNI2 app (`SimpleViewer`) opens the virtual device and reads correct depth; and (only if the user supplied NiTE2) NiTE tracks a skeleton from it.
QA scenarios: happy - SimpleViewer shows synthetic depth via OpenNI2. failure - open two consumers, assert correct multi-open handling or a clean busy error. Evidence `.omo/evidence/task-15-webcam-kinect-emulator.log`
Commit: Y | feat(fallback-openni2): linux openni2 virtual device
Recommended task executor category: deep-low - adapter against a documented API.
- [ ] 16. Record/replay harness + mock NUI host
What to do / Must NOT do: In `tools/`, a record/replay harness (capture tracker/synth output to a fixture file, replay deterministically into the emitter/shim) and a Windows mock NUI host (links the SDK headers, drives the full NUI call sequence) for testing the shim (todo 14) without the game. Must NOT: use wall-clock sleeps - replay on a fake clock.
Closes: GAP-7 (test infra)
Parallelization: Wave 3 | Blocked by: 2 | Blocks: 10,13 (as supporting infra)
References: `.omo/design/architecture.md` (Build/test: record/replay + mock host as top test asset); KinectFaker's record/replay pattern (reference only, GPLv3 - do not open its source).
Acceptance criteria (agent-executable): record a fixture from a recorded video, replay it, assert byte-identical frames out; mock host builds (cross/MSVC) and runs a scripted session.
QA scenarios: happy - record then replay reproduces the exact frame sequence. failure - truncate a fixture, assert the replayer errors cleanly. Evidence `.omo/evidence/task-16-webcam-kinect-emulator.log`
Commit: Y | feat(tools): record/replay harness + mock nui host
Recommended task executor category: unspecified-high - test infrastructure across both deliverables.
- [ ] 17. Robustness / graceful degradation
What to do / Must NOT do: Harden the tracker+synth path for IS-8: player leaves frame (publish player-lost, hold last good briefly, recover), poor lighting / low-visibility joints (mark INFERRED, hold), mask fragmentation/flicker (largest-component + temporal hold already in 7 - verify under stress), tracker process crash (emitter keeps serving last frame or a safe no-player frame; heartbeat-driven). Must NOT: add fixed-delay reconnection - use event/heartbeat-driven recovery; no silent exception swallowing.
Closes: IS-8
Parallelization: Wave 8 | Blocked by: 5,7,10 | Blocks: 18
References: `.omo/design/nui-contracts.md` §2.5 (failure modes), §1.7 (inferred joints); contract heartbeat (todo 2).
Acceptance criteria (agent-executable): fault-injection tests - subject-exits, all-low-visibility, fragmented-mask, tracker-kill - each yields the specified graceful behavior without host-app crash (verified against the NiTE e2e / mock host).
QA scenarios: happy - subject exits & returns, tracking recovers. failure - kill the tracker mid-stream, assert the host app sees a safe no-player state, not garbage/crash. Evidence `.omo/evidence/task-17-webcam-kinect-emulator.log`
Commit: Y | feat(robust): graceful degradation + fault recovery
Recommended task executor category: unspecified-low - contained hardening with fault tests.
- [ ] 18. Packaging + setup documentation
What to do / Must NOT do: `docs/` + packaging: a Linux setup guide (deps, usbip attach, run) and a Windows setup guide (test-signing + driver install, attach, run, DEA config per P3dro200), a calibration how-to, and a troubleshooting section (mirror bit, player-lost, depth out-of-range). The Windows signing docs MUST cover enabling test-signing (`bcdedit /set testsigning on`), disabling Secure Boot, the test-mode desktop watermark, and potential interaction with spice2x anti-tamper. LINK to Microsoft's official Kinect 1.8 runtime/SDK download. Package the tracker + core + attach shims into a runnable bundle per OS. Must NOT: redistribute/bundle the MS Kinect 1.8 runtime, NiTE2, or any DEA game asset (link to official sources only); document steps not actually verified in todos 10/13.
Closes: GAP-7 (docs), proves IS-5,6
Parallelization: Wave 11 | Blocked by: 10,13 | Blocks: none
References: todos 9,11,12,13 outcomes; P3dro200 DEA install steps.
Acceptance criteria (agent-executable): following the Linux guide from a clean checkout reproduces the todo-10 result; the docs cover every manual Windows step from todos 12/13; a `--help`/README smoke check passes.
QA scenarios: happy - a fresh Linux run from docs reaches correct depth enumeration in an OpenNI2 viewer (+ a tracked skeleton if NiTE2 supplied). failure - omit the signing step and confirm the troubleshooting section catches the resulting Windows failure. Evidence `.omo/evidence/task-18-webcam-kinect-emulator.log`
Commit: Y | docs(setup): linux + windows setup, calibration, troubleshooting
Recommended task executor category: writing - documentation + packaging.
## Final verification wave
> Runs in parallel after ALL todos. ALL must APPROVE. Surface results and wait for the user's explicit okay before declaring complete.
- [ ] F1. Plan compliance audit - every todo delivered as specified; scope boundaries (Must NOT) respected; spike findings actually drove the device-vs-fallback decisions.
Recommended task executor category: unspecified-high
- [ ] F2. Code quality review - clean-room discipline (no GPLv3 vendored source), frozen contract intact (static_asserts), no fixed sleeps/blind retries, pure-math modules test-covered.
Recommended task executor category: unspecified-high
- [ ] F3. Real QA (Linux, agent-run) - the full recorded-video -> virtual Kinect -> real OpenNI2 chain yields correct depth/player-index enumeration (and a tracked skeleton IF NiTE2 is user-supplied); record/replay reproduces; robustness faults handled. The authoritative skeleton/gameplay proof is F5 (Windows).
Recommended task executor category: deep-low
- [ ] F4. Ideal-state fidelity - delivered behavior vs every IS row 1:1; any shortfall becomes new `- [ ] N.` rows, never a note.
Recommended task executor category: unspecified-high
- [ ] F5. DanceEvolution playability proof (Windows, human-assisted) - DEA launches via the webcam virtual Kinect, shows the player, tracks moves, and scores directionally-correctly, captured as a gameplay recording; mirror-bit + z-sign checks pass.
Recommended task executor category: deep-high
## Commit strategy
- One commit per todo (the `Commit:` line on each), conventional-commit style, scoped to that todo's component; no cross-todo mega-commits.
- Spikes (3,4) commit their reports under `docs/` so later waves reference durable findings.
- No commit is created unless the user runs execution (the planner never commits); the executor commits per todo. Use the `git-master` skill for any history work.
- Keep the worktree clean per wave; the frozen IPC contract (todo 2) changes only via an explicit contract-version bump commit.
## Success criteria
| IS | Delivering todo(s) | Proving QA scenario | Evidence |
| --- | --- | --- | --- |
| IS-1 (enumerates as a Kinect) | 8,9,12 | device enumerates in OpenNI (Linux) / Device Manager + SkeletonBasics (Windows) - DEVICE path only, NOT the NUI shim | `.omo/evidence/task-9-...`, `.omo/evidence/task-12-webcam-kinect-emulator.*` |
| IS-2 (real-time tracking, >= ~25 fps / 30 target) | 5,6,7,8,10,13 | real host tracker (Windows MS NUI; Linux NiTE2 if supplied) skeletonizes synthetic depth and follows the subject at the measured tier's fps - DEVICE path, NOT the shim | `.omo/evidence/task-10-...`, `.omo/evidence/task-13-webcam-kinect-emulator.*` |
| IS-3 (player-visible rendering) | 7,13 | DEA shows the player silhouette from synthetic depth/player-index | `.omo/evidence/task-13-webcam-kinect-emulator.*` |
| IS-4 (directionally-correct scoring) | 6,7,11,13 | correct dancing scores, standing still registers misses | `.omo/evidence/task-13-webcam-kinect-emulator.*` |
| IS-5 (OS-agnostic core) | 1,2,8,9,12 | same `core/` builds for Linux + Windows; only attach differs | `.omo/evidence/task-1-...`, `.omo/evidence/task-8-webcam-kinect-emulator.log` |
| IS-6 (reproducible setup) | 11,18 | fresh Linux run from docs reaches correct depth enumeration (+ skeleton if NiTE2 supplied); Windows steps documented | `.omo/evidence/task-18-webcam-kinect-emulator.log` |
| IS-7 (validated vs real apps) | 10,13 | a real OpenNI2 app (Linux: enumerate+depth; skeleton if NiTE2) + DEA (Windows: authoritative skeleton proof) both accept the device | `.omo/evidence/task-10-...`, `.omo/evidence/task-13-webcam-kinect-emulator.*` |
| IS-8 (graceful degradation) | 17 | subject-exit/low-light/mask-noise/tracker-crash handled without host crash | `.omo/evidence/task-17-webcam-kinect-emulator.log` |
| IS-9 (general-purpose, not DEA-only) | 12,15 | a Kinect SDK sample (Windows, enumerate+track) + an OpenNI2 app (Linux, enumerate+depth; skeleton if NiTE2), distinct from the e2e harness | `.omo/evidence/task-12-webcam-kinect-emulator.*`, `.omo/evidence/task-15-webcam-kinect-emulator.log` |
+44
View File
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 3.20)
project(virtual_kinect_core LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# ---------------------------------------------------------------------------
# libnui_core: OS-agnostic static library aggregating the pure core modules.
# Real logic arrives per plan todos 2 (contract), 6 (mapping), 7 (synth);
# these sources are compile/link placeholders today.
# ---------------------------------------------------------------------------
add_library(libnui_core STATIC
core/contract/contract.cpp
core/mapping/mapping.cpp
core/synth/synth.cpp
)
# Keep the on-disk name libnui_core.a (not liblibnui_core.a).
set_target_properties(libnui_core PROPERTIES PREFIX "" OUTPUT_NAME "libnui_core")
target_include_directories(libnui_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/core)
# ---------------------------------------------------------------------------
# Tests: GoogleTest via FetchContent + CTest. One trivial passing test today.
# ---------------------------------------------------------------------------
option(NUI_CORE_BUILD_TESTS "Build libnui_core unit tests" ON)
if(NUI_CORE_BUILD_TESTS)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.tar.gz
URL_HASH SHA256=7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
# Honour the parent project's C runtime selection on Windows/MSVC.
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_executable(libnui_core_tests tests/test_core.cpp)
target_link_libraries(libnui_core_tests PRIVATE libnui_core GTest::gtest_main)
include(GoogleTest)
gtest_discover_tests(libnui_core_tests)
endif()
+26
View File
@@ -0,0 +1,26 @@
Virtual Kinect v1 — license / clean-room notice
================================================
This repository is a clean-room, personal-use project. All code herein is written
fresh by the project authors.
Clean-room discipline
---------------------
- The Kinect v1 NUI API (public NuiApi.h / Kinect for Windows SDK 1.8 headers) and the
libfreenect USB protocol are used only as interface facts (ABI shapes, descriptors,
wire formats), the way any program linking an API uses its headers.
- No GPLv3 (or otherwise copyleft) source — including KinectFaker, NiVirtualCam, and
NiTE2 — is read, copied, or vendored into this repository. Observed behavior and
public protocol documentation are the only references.
Third-party components (NOT included)
-------------------------------------
- Microsoft Kinect for Windows Runtime/SDK 1.8 — obtain from Microsoft's official site.
- OpenNI2 / NiTE2 — user-supplied; NiTE2 is EOL and not redistributable, never bundled.
- DanceEvolution Arcade and any game assets — user-supplied.
No warranty. Windows driver components require personal-use test-signing and are not
WHQL-signed or distributed as production-ready.
A formal open-source license for the project's own code may be chosen later; until then
all rights are reserved to the authors for the project's own source.
+50
View File
@@ -0,0 +1,50 @@
# Webcam-driven virtual Kinect v1
Make an ordinary RGB webcam present itself as a genuine **Microsoft Kinect v1** sensor so
unmodified Kinect apps — primary proof target **DanceEvolution Arcade (DEA)** on Windows —
run with no recompile. 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.
## Clean-room notice
All synthesis, mapping, protocol, and shim code in this repository 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 (todo 2) |
| `core/mapping/` | NUI intrinsics, MediaPipe-33 -> Kinect-20 map, Holt smoothing (todo 6) |
| `core/synth/` | Packed depth + player-index + color rasterizer (todo 7) |
| `core/protocol/` | Kinect v1 virtual USB device emitter (todo 8) |
| `tracker/` | Python webcam -> MediaPipe pose/segmentation -> IPC (todo 5) |
| `attach/linux/` | Linux USB attach via usbip/vhci (todo 9) |
| `attach/windows/` | Windows virtual USB bus attach + signing docs (todo 12) |
| `fallback/linux-openni2/` | OpenNI2 virtual device fallback / general emulator (todo 15) |
| `fallback/windows-nui/` | Clean-room `Kinect10.dll` NUI shim (todo 14) |
| `tools/logging-shim/` | Pass-through logging shim for the Windows spike (todo 4) |
| `tools/record-replay/` | Deterministic record/replay harness (todo 16) |
| `tools/mock-nui-host/` | Mock NUI host driving the shim (todo 16) |
| `tests/` | Cross-cutting C++ (CTest) + Python (pytest) smoke tests |
| `docs/` | Build, setup, calibration, troubleshooting, spike reports |
The shared engine is the OS-agnostic `core/` (built into `libnui_core`, unit-tested on
Linux); only the thin `attach/` and `fallback/` layers are per-OS.
## Build
See **[docs/build.md](docs/build.md)**. Quick start (Linux):
```sh
cmake -S . -B build/linux && cmake --build build/linux
ctest --test-dir build/linux --output-on-failure
.venv/bin/pytest -q
```
The full plan lives in `.omo/plans/webcam-kinect-emulator.md`; the architecture and NUI
contract notes in `.omo/design/`.
+5
View File
@@ -0,0 +1,5 @@
# attach/linux/ — Linux USB attach via usbip/vhci (todo 9)
Binds the `core/protocol` emitter as a virtual USB device through USB/IP + `vhci-hcd`
(or raw-gadget), with attach/detach lifecycle + CLI. No out-of-tree kernel modules
beyond stock usbip/vhci. Placeholder until todo 9.
+6
View File
@@ -0,0 +1,6 @@
# attach/windows/ — Windows virtual USB bus attach (todo 12)
Presents the `core/protocol` emitter to Windows via usbip-win (or a UMDF/KMDF virtual
USB bus driver) so the real MS Kinect driver (`kinectsensor.inf`) + `Kinect10.dll` see a
Kinect. Documents the test-signing / Secure-Boot steps (personal-use only). Placeholder
until todo 12.
+32
View File
@@ -0,0 +1,32 @@
# MinGW-w64 cross-compilation toolchain for the Windows build of libnui_core.
#
# Status (todo 1): x86_64-w64-mingw32 is NOT installed on this build host and cannot be
# added without sudo, so the Windows cross target is DOCUMENTED-SKIPPED (see docs/build.md).
# The MSVC build on the user's Windows box is authoritative for shim/driver ABI acceptance;
# MinGW-w64 would only ever be a fast local SMOKE signal.
#
# Usage once a MinGW-w64 toolchain is available:
# cmake -S . -B build/win --toolchain cmake/mingw-w64.cmake && cmake --build build/win
#
# ---- Target architecture (scaffolded for BOTH; pick one) --------------------
# x64 (64-bit): set(NUI_WIN_ARCH x86_64) -> x86_64-w64-mingw32-{gcc,g++}
# x86 (32-bit): set(NUI_WIN_ARCH i686) -> i686-w64-mingw32-{gcc,g++}
# The SHIPPING Windows arch (DEA is likely x86/32-bit) is CONFIRMED from spike 4's
# `dumpbin /headers gamekdm.dll` bitness BEFORE todos 12/14 build the real driver/shim.
# Default here is x64 for the local smoke build; override with -DNUI_WIN_ARCH=i686.
if(NOT DEFINED NUI_WIN_ARCH)
set(NUI_WIN_ARCH x86_64)
endif()
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR ${NUI_WIN_ARCH})
set(_nui_mingw_prefix ${NUI_WIN_ARCH}-w64-mingw32)
set(CMAKE_C_COMPILER ${_nui_mingw_prefix}-gcc)
set(CMAKE_CXX_COMPILER ${_nui_mingw_prefix}-g++)
set(CMAKE_RC_COMPILER ${_nui_mingw_prefix}-windres)
set(CMAKE_FIND_ROOT_PATH /usr/${_nui_mingw_prefix})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+14
View File
@@ -0,0 +1,14 @@
# core/ — OS-agnostic virtual Kinect engine
Pure, cross-platform C/C++ that compiles and unit-tests off-Windows. No OS-specific
USB or Win32 code lives here; the thin per-OS layers live under `attach/` and `fallback/`.
| Subdir | Role (filled by plan todo) |
| --- | --- |
| `contract/` | Frozen, versioned IPC frame + control schema shared by C++ core and Python tracker (todo 2). |
| `mapping/` | NUI depth<->skeleton intrinsics, MediaPipe-33 -> Kinect-20 joint map, Holt smoothing (todo 6). |
| `synth/` | Packed depth + player-index + color rasterizer from mask + 3D pose (todo 7). |
| `protocol/` | Kinect v1 virtual USB device emitter — descriptors, control transfers, iso/bulk framing (todo 8). |
Built into the `libnui_core` static library (see top-level `CMakeLists.txt`). Current
contents are compile/link placeholders; real logic arrives in the todos noted above.
+8
View File
@@ -0,0 +1,8 @@
# core/contract/ — frozen, versioned IPC data contract (todo 2)
Shared-memory frame contract (C header + generated Python mirror): triple-buffered
newest-wins slot with a monotonic sequence counter, skeleton + depth/player-index +
color buffer descriptors, frame number, QPC timestamp, and a named-pipe/socket control
schema. `static_assert` on every struct size/offset; embedded contract-version constant.
Placeholder only until todo 2.
+10
View File
@@ -0,0 +1,10 @@
#include "contract/contract.h"
namespace nui::contract {
int contract_version() {
// v0: scaffold placeholder; frozen layout defined in todo 2.
return 0;
}
} // namespace nui::contract
+14
View File
@@ -0,0 +1,14 @@
#ifndef NUI_CORE_CONTRACT_H
#define NUI_CORE_CONTRACT_H
// Placeholder for the frozen, versioned IPC data contract (plan todo 2).
// The real triple-buffered frame structs + static_asserts arrive there.
namespace nui::contract {
// Contract schema version. Bumped only via an explicit contract-version commit (todo 2).
int contract_version();
} // namespace nui::contract
#endif // NUI_CORE_CONTRACT_H
+8
View File
@@ -0,0 +1,8 @@
# core/mapping/ — NUI intrinsics, joint map, Holt smoothing (todo 6)
Clean-room implementation (from documented formulas in `.omo/design/nui-contracts.md`)
of the Kinect depth<->skeleton intrinsics, the MediaPipe-33 -> Kinect-20 joint map with
synthesized joints, a global mirror bit, per-joint depth placement + tracking state, and
Holt double-exponential smoothing. Pure math, TDD with golden-vector tests.
Placeholder only until todo 6.
+10
View File
@@ -0,0 +1,10 @@
#include "mapping/mapping.h"
namespace nui::mapping {
int kinect_joint_count() {
// Kinect v1 NUI skeleton has 20 joints; real mapping logic lands in todo 6.
return 20;
}
} // namespace nui::mapping
+14
View File
@@ -0,0 +1,14 @@
#ifndef NUI_CORE_MAPPING_H
#define NUI_CORE_MAPPING_H
// Placeholder for NUI intrinsics + MediaPipe-33 -> Kinect-20 map + Holt smoothing
// (plan todo 6). Pure, TDD with golden vectors.
namespace nui::mapping {
// Returns the number of Kinect v1 skeleton joints this module will map to (20).
int kinect_joint_count();
} // namespace nui::mapping
#endif // NUI_CORE_MAPPING_H
+10
View File
@@ -0,0 +1,10 @@
# core/protocol/ — Kinect v1 USB device emitter (todo 8)
OS-agnostic virtual Kinect: answers the USB descriptors / control transfers /
EEPROM-register reads the host driver needs to enumerate + init a Kinect v1, and
emits depth/color/IR (+ minimal audio-interface enumeration) over iso/bulk endpoints,
pulling frames from `core/synth` via the frozen contract. Exposes a transport-agnostic
"USB device backend" interface so the Linux (`attach/linux`) and Windows
(`attach/windows`) shims plug in. **Never emits a skeleton** — the host computes it.
Placeholder only until todo 8.
+7
View File
@@ -0,0 +1,7 @@
# core/synth/ — synthetic depth + player-index + color rasterizer (todo 7)
Turns the tracker's segmentation mask + 3D pose (via `core/mapping`) into Kinect image
frames: packed depth `(mm&0x1FFF)<<3 | player&0x7`, player-index on body pixels, color
passthrough, optional IR. Synthesizes at the resolution the host requests.
Placeholder only until todo 7.
+9
View File
@@ -0,0 +1,9 @@
#include "synth/synth.h"
namespace nui::synth {
uint16_t pack_depth(uint16_t depth_mm, uint8_t player_index) {
return static_cast<uint16_t>(((depth_mm & 0x1FFF) << 3) | (player_index & 0x7));
}
} // namespace nui::synth
+17
View File
@@ -0,0 +1,17 @@
#ifndef NUI_CORE_SYNTH_H
#define NUI_CORE_SYNTH_H
#include <cstdint>
// Placeholder for the packed depth + player-index + color rasterizer (plan todo 7).
namespace nui::synth {
// Packs a depth value (mm) and player index into the Kinect v1 depth word layout:
// (mm & 0x1FFF) << 3 | (player & 0x7). Provided now so the library has a real symbol;
// the full rasterizer arrives in todo 7.
uint16_t pack_depth(uint16_t depth_mm, uint8_t player_index);
} // namespace nui::synth
#endif // NUI_CORE_SYNTH_H
+5
View File
@@ -0,0 +1,5 @@
# docs/ — setup, build, spike reports
- `build.md` — toolchain + build instructions (cmake, venv, cross-compile status).
- `spike-linux.md`, `spike-windows.md` — spike reports (todos 3, 4).
- Setup/calibration/troubleshooting guides land in todo 18.
+56
View File
@@ -0,0 +1,56 @@
# Build guide
## Toolchain status (recorded at scaffold / plan todo 1)
| Tool | Status on the build host | Notes |
| --- | --- | --- |
| `cmake` | **Installed via `pip install --user --break-system-packages cmake`** (v4.4.5) | System pip is PEP-668 externally-managed and `cmake` was not preinstalled; the `--break-system-packages` flag targets the per-user site only. `cmake` lands in `~/.local/bin` — ensure that is on `PATH`. |
| `g++` | Installed (system) | Native Linux build + test. |
| `python3` | 3.14.4 (system) | `venv`/`ensurepip` unavailable, so the dev venv is created with `virtualenv` (also `pip install --user --break-system-packages virtualenv`). |
| Python dev venv | `.venv/` (created with `virtualenv`, `pytest` installed) | gitignored. |
| `x86_64-w64-mingw32-g++` | **NOT installed; cannot be added without sudo** | Windows cross target is skipped here (see below). |
## Linux build + test (authoritative for the OS-agnostic core)
```sh
export PATH="$HOME/.local/bin:$PATH" # if cmake was pip-installed to the user site
cmake -S . -B build/linux
cmake --build build/linux
ctest --test-dir build/linux --output-on-failure
```
GoogleTest is fetched via CMake `FetchContent` at configure time (needs network once; it
is then cached under `build/linux/_deps`).
## Python tracker tests
```sh
.venv/bin/pytest -q
```
The tracker's runtime deps (opencv-python, mediapipe, numpy) are **declared** in
`tracker/pyproject.toml` but intentionally not installed at scaffold time — they arrive
with the tracker implementation (plan todo 5).
## Windows builds
Two Windows build paths are planned:
1. **MSVC (authoritative).** Built on the user's Windows box; this is the ABI-authoritative
build for the `Kinect10.dll` shim and the virtual USB driver. The shipping architecture
(**x86 vs x64 — DEA is likely x86/32-bit**) is confirmed from spike 4's
`dumpbin /headers gamekdm.dll` bitness before todos 12/14 build the real artifacts.
2. **MinGW-w64 cross (fast local smoke only).** A toolchain file exists at
`cmake/mingw-w64.cmake` scaffolding **both** `x86_64` and `i686` targets
(`-DNUI_WIN_ARCH=x86_64|i686`). **This build host has no MinGW-w64 toolchain and it
cannot be installed without sudo, so the Windows cross target is skipped for now.** When
a toolchain is available:
```sh
cmake -S . -B build/win --toolchain cmake/mingw-w64.cmake
cmake --build build/win
```
MinGW C++ ABI quirks around COM/SEH mean MinGW is only ever a smoke signal; MSVC remains
authoritative for shim/driver ABI acceptance.
+6
View File
@@ -0,0 +1,6 @@
# fallback/linux-openni2/ — OpenNI2 virtual device fallback (todo 15)
An OpenNI2 device-driver module (OniDriverApi) exposing the `core/synth` streams as an
OpenNI2 device, so OpenNI/NiTE apps work without the usbip path; doubles as the Linux
general-emulator surface. Consumes `core/synth` (never duplicates it); never bundles
NiTE2. Placeholder until todo 15.
+6
View File
@@ -0,0 +1,6 @@
# fallback/windows-nui/ — clean-room Kinect10.dll NUI shim (todo 14)
A clean-room drop-in `Kinect10.dll` implementing the NUI surface DEA imports, injecting
skeleton (`core/mapping`) + depth/color (`core/synth`) directly on the ~30Hz event model.
**Clean-room firewall: derived solely from the public NuiApi.h + spike-4's observed
import list — never from KinectFaker's GPLv3 source.** Placeholder until todo 14.
+7
View File
@@ -0,0 +1,7 @@
# tests/ — cross-cutting test targets
- `test_core.cpp` — GoogleTest smoke test linked against `libnui_core`, run via CTest.
- `test_smoke.py` — pytest smoke test proving collection + a passing case.
Per-module unit tests (mapping golden vectors, synth pack/unpack, contract layout) are
added alongside their todos.
+15
View File
@@ -0,0 +1,15 @@
#include <gtest/gtest.h>
#include "contract/contract.h"
#include "mapping/mapping.h"
#include "synth/synth.h"
// Scaffold smoke test: proves libnui_core compiles, links, and its placeholder
// symbols are callable. Real per-module suites replace/extend this in todos 2/6/7.
TEST(ScaffoldSmoke, CoreSymbolsLinkAndReturnPlaceholders) {
EXPECT_EQ(nui::contract::contract_version(), 0);
EXPECT_EQ(nui::mapping::kinect_joint_count(), 20);
// Depth packing layout sanity: 1000mm, player 1 -> (1000<<3)|1.
EXPECT_EQ(nui::synth::pack_depth(1000, 1),
static_cast<uint16_t>((1000 << 3) | 1));
}
+19
View File
@@ -0,0 +1,19 @@
"""Scaffold smoke test for the Python side of the project.
Proves pytest collects and runs at least one passing test. The real tracker suite
(MediaPipe pose/segmentation -> IPC) arrives in plan todo 5.
"""
def test_scaffold_collects_and_passes():
assert True
def test_depth_packing_matches_core_layout():
# Mirror of nui::synth::pack_depth so the Python tracker and C++ core agree on the
# Kinect v1 depth word layout. The frozen contract (todo 2) replaces this with a
# generated mirror of the C header.
def pack_depth(depth_mm: int, player: int) -> int:
return ((depth_mm & 0x1FFF) << 3) | (player & 0x7)
assert pack_depth(1000, 1) == (1000 << 3) | 1
+5
View File
@@ -0,0 +1,5 @@
# tools/logging-shim/ — pass-through logging Kinect10.dll (spike, todo 4)
Forwards every NUI call to the real `Kinect10.dll` and logs name/args/flags/resolution/
return + which events DEA waits on, to capture DEA's exact NUI call sequence. Placeholder
until the todo-4 Windows spike.
+4
View File
@@ -0,0 +1,4 @@
# tools/mock-nui-host/ — mock NUI host (todo 16)
Windows mock host that links the SDK headers and drives the full NUI call sequence to test
the `fallback/windows-nui` shim without the game. Placeholder until todo 16.
+4
View File
@@ -0,0 +1,4 @@
# tools/record-replay/ — record/replay harness (todo 16)
Captures tracker/synth output to a fixture file and replays it deterministically into the
emitter/shim on a **fake clock** (no wall-clock sleeps). Placeholder until todo 16.
+8
View File
@@ -0,0 +1,8 @@
# tracker/ — webcam pose + segmentation tracker (todo 5)
Python: OpenCV webcam capture -> MediaPipe Pose (Full/Heavy) -> 33 landmarks +
world-landmarks + visibility + segmentation mask, published to the shared-memory
contract at the newest-wins slot each frame, plus control-plane handshake/heartbeat.
Dependencies are declared in `pyproject.toml` but **not installed by todo 1** — the
OpenCV/MediaPipe install and the real pipeline arrive in todo 5.
+12
View File
@@ -0,0 +1,12 @@
"""Webcam -> virtual Kinect tracker package (plan todo 5).
Currently a package placeholder. Runtime dependencies (opencv-python, mediapipe, numpy)
are declared in pyproject.toml but intentionally NOT installed by todo 1.
"""
__version__ = "0.0.1"
def tracker_info() -> dict:
"""Return static metadata about the tracker package (placeholder for todo 5)."""
return {"name": "virtual-kinect-tracker", "version": __version__, "stage": "scaffold"}
+23
View File
@@ -0,0 +1,23 @@
[project]
name = "virtual-kinect-tracker"
version = "0.0.1"
description = "Webcam -> MediaPipe pose/segmentation tracker publishing Kinect-style frames over the IPC contract."
readme = "README.md"
requires-python = ">=3.9"
# Declared for todo 5; NOT installed by todo 1 (scaffold).
dependencies = [
"opencv-python>=4.9",
"mediapipe>=0.10",
"numpy>=1.26",
]
[project.optional-dependencies]
dev = ["pytest>=8"]
[build-system]
requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
packages = ["tracker"]
package-dir = { tracker = "." }