Spaces:
Running on T4
Running on T4
File size: 8,396 Bytes
ae2c68f 1c5e162 ae2c68f 1c5e162 ae2c68f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # Motion measurements and coaching: contract 1.1
The engine exports nine measurements across the four report groups. The receiver still accepts stored 1.0 payloads with exactly three measurements. It never invents missing measurements for an old payload. Report JSON remains version 1.0 with additive `value_interval` and `score_interval` fields on each measurement.
The three original metrics and their definitions are unchanged. All measurements derived from the current video pose models carry `model_accuracy_unvalidated` and are marked limited. A successful job or a passing geometry test does not establish physical accuracy of the reconstructed body.
## Measurements
| Group | Measurement | Exact definition |
| --- | --- | --- |
| Balance and Load | Torso inclination at stride start | Angle of hip-centre to shoulder-centre vector from fixed vertical |
| Balance and Load | Hip–shoulder separation at stride start | Wrapped signed horizontal shoulder heading minus hip heading |
| Stride | Hip–shoulder separation at foot down | Same heading difference at first visible ground touch |
| Stride | Relative stride length | Horizontal change of lead ankle relative to rear ankle between stride start and foot down, in centimetres |
| Power Move | Pelvis rotation to contact | Magnitude of net unwrapped horizontal hip rotation from foot down to contact |
| Power Move | Lead knee extension to contact | Change in 3D hip–knee–ankle angle between foot down and contact; positive means straightening |
| Contact and Follow-Through | Hip–shoulder separation at contact | Same signed heading difference at marked contact |
| Contact and Follow-Through | Torso inclination at contact | Same torso angle at contact |
| Contact and Follow-Through | Shoulder rotation after contact | Magnitude of net horizontal shoulder rotation from contact to the original sample nearest 100 ms later |
The group names are navigation labels. These measurements do not establish balance forces, energy transfer, bat speed, ball flight, or the quality of the entire follow-through. The last metric covers only an early shoulder turn. It requires a known physical capture clock and a clip extending at least 100 ms past contact.
## Events and quality
Usable 1.1 events include the exact zero-based `source_frame_index` into decoded original frames. Manual marks remain `manual_review` with `event_timing_uncertain`; they are not automatic detections or force-plate measurements. The derived follow-through event uses `derived_from_contact`. An unavailable event has null times, source and frame index, plus reasons.
The backend saves revised marks and the report together using these frame indices. It does not infer frames by multiplying timestamps by FPS, and it preserves existing marks for old payloads without frame indices.
The existing landmark, vertical-reference, interpolation, scale and camera checks still apply. Slow background drift is now checked against an anchor image as well as consecutive images. Three corroborating anchor displacements above the larger of 1% of image size or three times the adjacent-motion threshold contradict a fixed-camera declaration. Unsigned per-frame movement is never summed, so tracking noise cannot accumulate into a false drift estimate. This is an image-motion diagnostic, not camera calibration. A caller's original declaration is retained in the request; conflicting evidence changes the effective analysis status.
Lead-knee extension is an intrinsic 3D joint-angle change. It does not require a fixed camera or a vertical reference, because rotating or translating the coordinate frame does not change the angle between the thigh and lower leg. It still requires usable hip, knee and ankle positions and valid event marks, and remains a model estimate. Missing calibration therefore blocks the horizontal/world-oriented measurements without discarding this independent measurement.
## Scores and advice
The references describe recorded athletes, not ideal technique or guaranteed performance. Each metric uses the existing percentile-distance score. Group scores average rated metrics, including limited metrics; overall score averages rated groups. Limited inputs make their scores tentative. Missing groups are explicitly listed, and partial coverage adds a warning explaining the overall score's denominator.
Unrated group summaries explain shared causes such as an uncertain upright direction, camera/tracking instability, missing body points or missing event marks. A scored group with unavailable members states that it covers only part of the phase; missing values never count as zero.
Where neighboring samples are usable, `value_interval` spans evaluations with event marks shifted by one source frame in either direction. The coach computes `score_interval` across that range, including scoring breakpoints. These are event-sensitivity bounds, **not** confidence intervals or bounds on total model error. Missing neighboring evidence or a signed-angle wrap prevents publishing a misleading linear interval. A range that changes rating category or spans at least 20 score points cannot determine the corrective focus or a technique tip.
Unknown drill context and dry swings receive descriptions of the reference comparisons, without technique corrections. Their text is deterministic, so a language model cannot turn a walk-through drill into an instruction to shorten the stride. Conflicting profile and payload batting sides also suppress technique advice and add `batting_hand_conflict`; scores still identify which analysis side was used. The engine does not infer batting side from video.
For supported coaching contexts, generated wording is checked for measured scope, retained uncertainty, rating direction and unsupported physical claims. Rejected fields use deterministic text. A contact angle alone cannot justify a claim about follow-through; the early shoulder-turn metric cannot justify a claim about the whole finish.
## Reference data and reproducibility
The six added references come from [OpenBiomechanics dataset-v1](https://github.com/drivelineresearch/openbiomechanics/releases/tag/dataset-v1), using its 3D hitting landmarks and athlete metadata. Source attribution and licensing are described in the [OpenBiomechanics repository](https://github.com/drivelineresearch/openbiomechanics). Derived files retain that source's attribution and share-alike/noncommercial licensing terms.
`data_ref/scripts/compute_contract_v1_1_benchmarks.py` uses the same geometry functions as the engine, the existing five-sample smoothing and final still-ankle stride-start rule, first force-plate touch (`fp_10_time`), and recorded contact time. It calculates per-athlete medians before population percentiles, requires at least five athletes per reference cell, and records source file hashes. The present extraction contains 649 swings from 97 athletes. Matching formulas do not validate phone-video pose accuracy or eliminate laboratory-versus-video event differences.
From the repository root, with the official release landmarks and metadata available:
```sh
PYTHONPATH=. python data_ref/scripts/compute_contract_v1_1_benchmarks.py /path/to/landmarks.csv /path/to/metadata.csv data_ref/calibration/contract_v1_1
python AI-coach-agent/tools/build_benchmarks.py
python AI-coach-agent/tools/build_benchmarks.py --check
```
The generator requires pandas. Large raw landmark files and user videos are not checked into the repository. The [synthetic payload example](motion-coach-payload-v1.1.example.json) demonstrates shape and geometry, not a measured human swing.
## Delivery and deployment
Submission still consists of a `video` multipart part and one `options` JSON part. No new client options are required. `/v1/motion-analyses/{job_id}/coach-payload` returns the stored immutable bytes, so HTTP size and SHA-256 match the artifact manifest. Old payloads are returned unchanged rather than reserialized with new defaults.
Deploy the receiver that accepts both versions before serving 1.1 engine results. GitHub Actions deploys the backend and the Hugging Face Space from `main`; verify backend success before allowing the engine rollout to finish. Existing stored reports remain immutable for their analysis revision; higher revisions rebuild them under the new rules. The mobile app is outside this change.
|