Turn any video into a Mixamo-rig animation - GVHMR estimator, spec-driven retarget, FK apply in Blender via MCP. Works with any Mixamo character; built to be operated end-to-end by an AI agent.
arm_pose: correct arms by rigid rotation, targets in metres
Sacha9642ac3e5492
diff --git a/action_specs/spin.json b/action_specs/spin.jsonindex a3a4d4d..5e93687 100644--- a/action_specs/spin.json+++ b/action_specs/spin.json@@ -103,50 +103,6 @@"comment": "owner pass-4: punches don't travel far enough. Reference reaches 87-98% of arm length; restore extension on already-extending arms only."}],- "nudges": [- {- "src": [- 138,- 206- ],- "ramp_src": 6,- "side": "both",- "offset": [- 0,- 0,- -0.13- ],- "comment": "owner pass-7: hands sat at face level from the kick landing to the end; the performer holds them at chest level. One continuous window - two abutting windows cancel during their handover."- },- {- "src": [- 158,- 204- ],- "ramp_src": 6,- "side": "both",- "offset": [- 0,- 0,- -0.1- ],- "comment": "owner pass-7: the flurry needs more than the post-kick guard, and it must be at full strength BEFORE 7.0 s (src 168) - the owner judged the punches wrong 'from the start'."- },- {- "src": [- 168,- 204- ],- "ramp_src": 5,- "side": "right",- "offset": [- 0.035,- -0.05,- -0.03- ],- "comment": "owner pass-3/7: right chain off the shoulder, tucked toward the midline, level with the left."- }- ],"_head_look_note": "pass-6: no manual gaze correction needed any more. The estimator now emits the performer's real gaze (mesh nose vs ears) and the apply orients the head to it, clamped to gaze_max_offset_deg from the chest.","gaze_max_offset_deg": 70,"qa_src_frames": [@@ -165,5 +121,18 @@192,220,241+ ],+ "arm_pose": [+ {+ "src": [+ 138,+ 206+ ],+ "ramp_src": 6,+ "side": "both",+ "drop_m": 0.145,+ "widen_m": 0.085,+ "comment": "owner pass-8: hands sat ~15 cm above the reference (head-relative) and slightly too close from the kick landing to the end. Rigid rotation about each shoulder, solved per frame to hit the drop/widen targets in metres - preserves elbow bend, wrist alignment and hand separation."+ }]}\ No newline at end of filediff --git a/docs/PIPELINE.md b/docs/PIPELINE.mdindex c7ecbd4..52cf30a 100644--- a/docs/PIPELINE.md+++ b/docs/PIPELINE.md@@ -134,16 +134,21 @@ where fast flurries read staccato:"smooth": [ { "src": [172, 204], "window": 9 } ]```-Two more windowed correctors for systematic estimator bias in a phase-(both ramped, both leave the rest of the clip untouched):+Windowed correctors for systematic estimator bias inside a phase (all+ramped; they leave the rest of the clip untouched):```jsonc-// Offset an arm chain in the hip basis (x=left, y=back, z=up, meters);-// segment lengths are re-normalized from the shoulder socket.-// "arms too high" -> negative z; "shoulder pulls back" -> negative y.-"nudges": [- { "src": [172, 204], "ramp_src": 5, "side": "both", "offset": [0, 0, -0.08] },- { "src": [172, 204], "ramp_src": 5, "side": "right", "offset": [0, -0.05, 0] }+// Rotate a whole arm rigidly about its shoulder socket. Targets are in+// METRES and the angle is solved per frame, because a fixed angle over-+// or under-shoots as the arm swings. Rigid rotation preserves elbow+// bend, wrist alignment and the distance between the hands — offsetting+// the joints instead (and re-normalizing bone lengths) collapses the+// hands together and folds the wrists at anything beyond ~2 cm.+"arm_pose": [+ { "src": [138, 206], "ramp_src": 6, "side": "both",+ "drop_m": 0.145, // + lowers the hands along an arc+ "widen_m": 0.085 } // + opens the hands apart+ // also accepts raw "pitch_deg" / "yaw_deg" if you prefer angles],// Restore strike extension. Scales the hand's distance from its@@ -153,9 +158,23 @@ Two more windowed correctors for systematic estimator bias in a phase"reach": [{ "src": [172, 204], "ramp_src": 4, "side": "both","factor": 1.22, "max_fraction": 0.97, "min_extension": 0.30 }+],++// Authored targets for a beat the estimator got wrong (occluded arm).+// Positions in metres in the hip basis (x=left, y=back, z=up).+"arm_overrides": [+ { "side": "right", "src": [76, 163], "ramp_src": 6,+ "wrist_local": [-0.17, -0.12, 0.33], "elbow_local": [-0.25, 0.05, 0.12] }]```+**Sizing a correction:** measure, don't guess. Compare the retarget+against the reference on quantities the eye actually reads — hand height+relative to the HEAD, distance between the hands, hand distance from the+chest — and remember to subtract the part that is proportion rather than+pose (a character whose head sits lower on its shoulders will always+read "hands high" at identical joint angles).+### GazeThe head follows the estimator's real gaze by default — no spec entrydiff --git a/docs/PITFALLS.md b/docs/PITFALLS.mdindex b982fc8..e64df56 100644--- a/docs/PITFALLS.md+++ b/docs/PITFALLS.md@@ -99,18 +99,24 @@ touching a clip a human has partially signed off.fast flurry (9 frames) also averages away its extension peaks —punches visibly shrink. Keep flurry windows narrow (5) and restoreamplitude with `reach`.-19. **Judge limb height against the HEAD, not the shoulders.** A- hand height that looks correct relative to the shoulder line can sit- at face level on a character whose head/shoulder proportions differ- from the performer's — the eye reads hands against the face. A- guard measured "3 cm off" shoulder-relative was 10-19 cm off- head-relative, which is what the owner saw.-20. **Abutting correction windows cancel at the handover.** Two- `nudges` windows that meet (138-171, 168-204) each ramp through the- junction, so the total correction dips exactly where they meet — a- visible defect at that instant. Use one continuous window plus a- smaller overlapping one, and make a correction reach full strength- BEFORE the beat it is meant to fix.+19. **Judge limb height against the HEAD, and check proportions before+ correcting.** The eye reads hands against the face, so a guard that+ measures fine relative to the shoulders can still sit at face level+ on a character whose head/shoulder proportions differ from the+ performer's. Measure both, and split the error: on one clip 4.6 cm+ of a 14.8 cm gap was pure proportion (the character's head sits+ lower on its shoulders) and only the remainder was pose worth+ correcting.+20. **Correct a limb by ROTATING the chain, never by translating its+ joints.** Offsetting elbow/wrist/hand and re-normalizing bone+ lengths is fine for a centimetre or two and destroys the pose at ten:+ the re-normalization drags the hands toward the midline and folds the+ wrists (measured: hand separation 0.25 m -> 0.08 m, wrist bend 7° ->+ 123°). A rigid rotation about the shoulder socket cannot distort the+ chain — it preserves elbow bend, wrist alignment and the distance+ between the hands. Express the target in metres (`arm_pose.drop_m` /+ `widen_m`) and solve the angle per frame; a fixed angle over- or+ under-shoots as the arm swings.21. **A "Hand" bone's world position is the WRIST.** Blender reports abone's head; `mixamorig:*Hand` sits at the wrist, so dividing itsdistance-from-shoulder by (arm+fore+hand) understates extension bydiff --git a/pipeline/lift_to_mixamo.py b/pipeline/lift_to_mixamo.pyindex 4d052e9..1f01571 100644--- a/pipeline/lift_to_mixamo.py+++ b/pipeline/lift_to_mixamo.py@@ -411,32 +411,72 @@ def main():rec[f"{s}_elbow"], rec[f"{s}_wrist"] = e, wrec[f"{s}_hand"] = w + unit(w - e) * LEN[f"{s}_hand"]- # Windowed arm-chain nudges (spec "nudges"): offset elbow/wrist/- # hand in the hip basis and re-normalize segment lengths from the- # socket. Fixes systematic estimator bias in a phase (arms too- # high, a shoulder pulled back) without authoring the motion.- for nd in spec.get("nudges", []):+ # Windowed arm-chain rotation (spec "arm_pose"): rotate a whole+ # arm rigidly about its shoulder socket. `pitch_deg` lowers (+)+ # or raises (-) the hand along an arc; `yaw_deg` swings it toward+ # the midline (+) or outward. A rigid rotation preserves elbow+ # bend, wrist alignment and the distance between the two hands —+ # translating the joints instead and re-normalizing bone lengths+ # distorts the chain, drags the hands together and folds the+ # wrists, which is exactly what it did at 20 cm of offset.+ for ap in spec.get("arm_pose", []):amt = window_amount(f,- [nd["src"][0], nd["src"][0] + nd.get("ramp_src", 5)],- [nd["src"][1] - nd.get("ramp_src", 5), nd["src"][1]],+ [ap["src"][0], ap["src"][0] + ap.get("ramp_src", 6)],+ [ap["src"][1] - ap.get("ramp_src", 6), ap["src"][1]],src2dest,)if amt <= 1e-4:continue- bx, by, bz = rec["basis_x"], rec["basis_y"], rec["basis_z"]- ox, oy, oz = nd["offset"]- off = (bx * ox + by * oy + bz * oz) * amt- sides = ("l", "r") if nd.get("side", "both") == "both" else (nd["side"][0],)+ pitch = np.radians(float(ap.get("pitch_deg", 0.0))) * amt+ yaw = np.radians(float(ap.get("yaw_deg", 0.0))) * amt+ drop = float(ap.get("drop_m", 0.0)) * amt+ widen = float(ap.get("widen_m", 0.0)) * amt+ if abs(pitch) < 1e-5 and abs(yaw) < 1e-5 and abs(drop) < 1e-4 and abs(widen) < 1e-4:+ continue+ lat = np.asarray(rec["basis_x"], float) # character left+ up = np.asarray(rec["basis_z"], float)+ sides = ("l", "r") if ap.get("side", "both") == "both" else (ap["side"][0],)for s in sides:sock = np.asarray(rec[f"{s}_arm"], float)- e = np.asarray(rec[f"{s}_elbow"], float) + off- w = np.asarray(rec[f"{s}_wrist"], float) + off- h = np.asarray(rec[f"{s}_hand"], float) + off- e = sock + unit(e - sock) * LEN[f"{s}_arm"]- w = e + unit(w - e) * LEN[f"{s}_fore"]- h = w + unit(h - w) * LEN[f"{s}_hand"]- rec[f"{s}_elbow"], rec[f"{s}_wrist"], rec[f"{s}_hand"] = e, w, h+ sign = 1.0 if s == "l" else -1.0 # mirror the lateral sense per side+ wrist0 = np.asarray(rec[f"{s}_wrist"], float)++ # `drop_m` / `widen_m` are targets in METERS — the angle+ # that achieves them depends on where the arm points, so+ # solve it per frame instead of guessing a fixed angle.+ def solve(axis, want, comp):+ lo, hi = 0.0, np.radians(75.0)+ base = comp(wrist0 - sock)+ if abs(want) < 1e-4:+ return 0.0+ s_dir = 1.0+ if comp(rodrigues(wrist0 - sock, axis, 0.05)) - base > 0:+ s_dir = -1.0 if want < 0 else 1.0+ else:+ s_dir = 1.0 if want < 0 else -1.0+ for _ in range(24):+ mid = 0.5 * (lo + hi)+ got = comp(rodrigues(wrist0 - sock, axis, mid * s_dir)) - base+ if abs(got) < abs(want):+ lo = mid+ else:+ hi = mid+ return 0.5 * (lo + hi) * s_dir++ a_pitch = pitch+ if abs(drop) > 1e-4:+ a_pitch += solve(lat, -abs(drop), lambda v: float(np.dot(v, up)))+ a_yaw = yaw * sign+ if abs(widen) > 1e-4:+ a_yaw += solve(up, abs(widen) * sign, lambda v: float(np.dot(v, lat)))+ for k in (f"{s}_elbow", f"{s}_wrist", f"{s}_hand"):+ v = np.asarray(rec[k], float) - sock+ if abs(a_pitch) > 1e-5:+ v = rodrigues(v, lat, a_pitch)+ if abs(a_yaw) > 1e-5:+ v = rodrigues(v, up, a_yaw)+ rec[k] = sock + v# Windowed reach scaling (spec "reach"): push the hand further# from the shoulder socket along its own direction and re-place