Spaces:
Running on T4
Download data_ref/calibration/CALIBRATION_REPORT_hitting.md from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 14.6 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/data_ref/calibration/CALIBRATION_REPORT_hitting.md
- Command line
-
hf download hf://spaces/modventures/baseball-engine/data_ref/calibration/CALIBRATION_REPORT_hitting.md
-
curl -L -o CALIBRATION_REPORT_hitting.md https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/data_ref/calibration/CALIBRATION_REPORT_hitting.md
Hitting calibration report (OBP, 2D face-on projection)
Data: OpenBiomechanics Project hitting landmarks.csv (joint-centre positions, 360 Hz, 677 swings, 98 athletes), metadata.csv, poi_metrics.csv. 645 swings / 97 athletes were usable (32 dropped: no valid foot plant before contact or load start not before foot plant).
Scripts: scripts/compute_hitting_metrics.py (per swing), scripts/analyze_hitting_ranges.py (aggregation). Outputs: calibration/hitting_ranges.yaml (all numbers), calibration/analysis_hitting.json, calibration/work_hitting/*.csv (per-swing values, all camera configs).
Everything below was computed from the downloaded data. Licence is not addressed (per brief).
1. Method
Camera model. OBP lab frame: +x home->pitcher, +y toward the RH batter's box, +z up. A camera facing the hitter's chest looks along the lateral (y) axis, so the image horizontal axis is the pitcher-catcher axis (x) and the vertical axis is z. NOTE: the brief said "image x = lateral axis"; that cannot be right for a chest-facing camera (the stride would then be invisible), so image u = x, v = z was used. Left-handed swings are mirrored (y -> -y) so all hitters are right-handed equivalents and yaw sign is body-relative. Positions are smoothed with a 5-frame moving average. Distances are divided by session_height_in (metres).
Yaw +t: u = x cos t + y sin t (camera swung about the vertical axis; sign is a convention, the report gives both signs). Tilt p: v' = z cos p + depth sin p.
Landmark mapping. hips = left_hip/right_hip (hip joint centres); knees = lkjc/rkjc; ankles = lajc/rajc; shoulders = lsjc/rsjc; wrists = lwjc/rwjc; head = thorax_prox (top of thorax / neck base): OBP's landmark file has NO head, nose or ear point (head markers exist only in the c3d archives, not downloaded). Lead side = opposite of hitter_side (R hitter -> left leg lead). Note OBP joint centres are model-derived (inside the body), the app's keypoints are surface/visual landmarks; this causes small systematic offsets (hip centre, ankle).
Events.
- contact = OBP
contact_time(marker-derived bat/ball event, not the app's wrist-speed estimate). - foot_plant = OBP
fp_100_time(100% bodyweight on the lead force plate). OBP also givesfp_10_time(10% BW, first touch). I re-implemented the app's foot-plant rule (lead-ankle speed < 0.25 H/s for 67 ms after the stride started,events.py) on the lab data: it lands a median +8 ms from fp_100 but +53 ms after fp_10 (n=629), so fp_100 is the better match to the app and is the primary. 25 swings lacked fp_100 -> fp_10 + 47 ms (median gap). fp_10-based figures are quoted where they matter. - load_start, stance_set: OBP supplies NO first-move time. I re-implemented the app's own rules (
baseball-engine/baseball_mvp/events.py: swing_start from wrist speed, load_start = start of the last backward hand run ending at the most-loaded point, min with stride start; stance_set = last still run of 0.25 s before load) on the image-plane signals of the base camera. The hands-based rule fired for 93% of swings (rest: fallback to stride start / swing start); a still stance period was found for only 40% (fallback: stance_set = load_start). Events are computed once (face-on) and reused for the yaw/tilt configs to isolate geometry. - Metric definitions follow
baseball-engine/baseball_mvp/metrics.pyexactly: stride = |lead-ankle u(FP) - u(load_start)| / height; head = MAX distance of head from its stance_set position over stance_set..contact (the app uses max displacement, not path length; path length is also stored ashead_path_pct_height); knee = interior hip-knee-ankle angle in 2D; tilt = angle of the shoulder line, uses |du|, positive = lead shoulder higher; hip-shoulder separation = shoulder tilt - hip tilt at FP; com_drift = (hip-mid u - lead-ankle u) * sign(lead ankle - back ankle) / height.
Statistics. Median over each athlete's swings first, then percentiles (np.percentile, linear) / mean / SD across athlete medians. n_swings is the number of swings behind those athlete medians.
2. Validation against OBP and sanity checks
| Check | Result |
|---|---|
3D hip-knee-ankle angle from landmarks at FP vs OBP 180 - lead_knee_launchpos_x |
r = 0.67, bias -1.3 deg, SD 6.9, MAE 4.0 (means 133.5 vs 134.8). Landmarks and OBP angles agree. |
| 2D (face-on) knee angle at FP vs OBP | 2D mean 162.8 vs 3D 133.5; r = 0.01. The face-on view straightens the knee by ~28 deg: at FP the lead knee flexes mostly toward/away from the camera (out of image plane). The 2D metric is a poor proxy for knee flexion; it mostly reflects frontal-plane geometry. |
| 2D stride vs 3D ankle displacement along x | r = 0.997 (it is the same quantity; planar 3D travel is larger, 18.7% vs 14.8%, because of lateral ankle motion not seen in 2D). |
| OBP has stride length? | No stride-length field in poi_metrics (lead_knee_stride_max_x is a knee angle), so stride was validated only against the 3D landmark displacement. |
3D hip/shoulder line yaw difference at FP vs OBP x_factor_fp_z |
r = 0.56, bias -15 deg (my crude line-yaw differs from OBP's segment-based angle convention). |
| 2D hip-shoulder separation (app definition) vs OBP x-factor | r = 0.38 (vs my 3D version r = 0.10); 2D mean -3 vs OBP -18 deg. It is a weak proxy; the 3D twist is mostly invisible to this camera. |
| Sanity: knee 100-180 | 100% of swings. |
| Sanity: stride 15-80% of height | Only 48% of swings for the app's definition (ankle TRAVEL, median 14%). 100% for foot-to-foot separation at FP (median 49%). See Section 5: the PRD 43-51% number is a separation, not a travel. |
| Event timing | fp_100 -> contact median 128 ms; fp_10 -> contact median 175 ms. A few athletes have toe-tap style early fp_10 (gap to fp_100 up to 500 ms), so fp_10 timing is unstable for them. |
| Lateral trunk tilt | At contact the shoulder line is nearly edge-on (median horizontal extent 4.2 cm; 26% of swings < 2 cm). The 2D angle is ~76 deg (about 90 minus foreshortening noise); the true 3D shoulder-line elevation is ~37 deg. Not a usable trunk-tilt measurement from a chest-facing camera. |
Systematic 2D vs 3D gaps: (i) out-of-plane knee flexion is hidden; (ii) shoulders are edge-on at contact, so tilt/separation angles are ill-conditioned; (iii) hip joint centre vs visible hip landmark; (iv) the neck base is not the nose.
3. Sample sizes by OBP level (athletes / swings, all 677 swings)
| OBP level | athletes | swings | in this analysis |
|---|---|---|---|
| college | 74 | 517 | 73 / 493 |
| high_school | 12 | 83 | 12 / 75 |
| independent | 4 | 30 | pooled into pro_ref (12 / 77 with milb) |
| milb | 8 | 47 | |
| all | 98 | 677 | 97 / 645 |
Mapping proposed: high_school -> hs_varsity (OBP does not say varsity vs JV, ages mixed; treat as a proxy), college -> college, independent+milb -> pro_ref (reference only). There is no JV group: for hs_jv reuse the hs_varsity numbers with lower confidence (the YAML marks them so). The HS group has only 12 athletes (about 6 swings each): percentile bands there are crude; p5/p95 are essentially min/max-like.
Handedness: 70 R and 27 L athletes; medians differ little (e.g. college stride 15.8 vs 13.7, knee 167.3 vs 162.2, com_drift -25.1 vs -24.6, head 11.8 vs 11.6), so the bands are not split by hand (detail in analysis_hitting.json, hand).
4. Results (per-athlete medians; p10 / p50 / p90; full p5..p95, mean, SD in the YAML)
| Metric | hs_varsity (n=12) | college (n=73) | pro_ref (n=12) |
|---|---|---|---|
| stride_pct_height (ankle travel) | 5.0 / 8.2 / 17.0 | 5.7 / 15.1 / 23.5 | 4.0 / 13.0 / 26.1 |
| stride_sep_fp_pct_height (foot separation at FP) | 41.6 / 47.9 / 51.3 | 44.1 / 49.9 / 54.9 | 44.8 / 49.2 / 51.3 |
| foot_plant_to_contact_ms (fp_100) | 109 / 124 / 158 | 98 / 128 / 146 | 118 / 129 / 139 |
| load_tempo_s | 0.87 / 1.05 / 1.51 | 0.76 / 1.17 / 1.42 | 0.87 / 0.97 / 1.24 |
| load_launch_ratio | 6.0 / 8.6 / 12.2 | 5.9 / 9.1 / 13.6 | 6.2 / 8.0 / 10.2 |
| head_movement_pct_height (neck-base proxy, max displacement) | 8.6 / 11.2 / 15.2 | 9.0 / 11.7 / 17.2 | 8.0 / 10.6 / 17.0 |
| head_path_pct_height (path length) | 22.0 / 28.9 / 33.6 | 22.6 / 29.7 / 36.7 | 22.6 / 27.2 / 28.9 |
| lead_knee_angle_contact_deg (2D) | 154 / 169 / 179 | 153 / 166 / 178 | 161 / 168 / 177 |
| lateral_trunk_tilt_contact_deg (2D, unusable) | 63 / 76 / 85 | 62 / 78 / 85 | 70 / 79 / 84 |
| hip_shoulder_sep_fp_deg (2D estimate) | -18 / -8 / 5 | -10 / -3 / 8 | -11 / -7 / -1 |
| com_drift_pct_height | -25.9 / -22.4 / -19.1 | -29.5 / -25.0 / -20.2 | -27.2 / -22.4 / -20.8 |
(trunk_lean_toward_pitcher_ct_deg, a suggested replacement for lateral tilt = hip-mid->shoulder-mid axis from vertical at contact, negative = leaning back/away from pitcher in the image: college -23 / -12 / -2.)
Timing sensitivity to the foot-plant event: using fp_10 the college fp->contact median is 175 ms (roughly the PRD's 195-245 minus ~30 ms), using fp_100 128 ms. The PRD band is therefore compatible only with a "first touch" event and a later contact than OBP's; both in the app's heuristics are uncertain, so this metric must be recalibrated on app-detected events from real clips before the band is trusted.
5. Camera-error sensitivity (pooled athletes, shift vs face-on in median / p10 / p90 of athlete medians)
Per-swing tilt of 3 deg changes nothing material (all |shifts| < 0.4 units except hip-shoulder separation: -1.7 deg median). Yaw (both signs; timing metrics are independent of the camera):
| Metric | yaw +10 | yaw -10 | yaw +20 / -20 (median) |
|---|---|---|---|
| stride_pct_height | -2.2 / -1.5 / -1.3 | +1.3 / +1.3 / +1.7 | -4.4 / +2.0 |
| stride_sep_fp_pct_height | -1.3 / -1.7 / -0.5 | -0.4 / +0.7 / -0.9 | -3.8 / -2.4 |
| head_movement_pct_height | -0.3 / -0.3 / -1.1 | +0.2 / +0.1 / +0.4 | -0.6 / 0.0 |
| lead_knee_angle_contact_deg | +0.5 / +1.4 / -0.2 | -0.8 / -1.0 / -0.5 | +2.6 / -1.9 |
| lateral_trunk_tilt_contact_deg | +0.3 / -3.2 / -0.2 | -3.0 / -7.4 / -0.5 | -8.4 / -12.2 |
| hip_shoulder_sep_fp_deg | +0.1 / -0.7 / +1.6 | +0.1 / +0.3 / -1.0 | +0.4 / -0.3 |
| com_drift_pct_height | +1.1 / +0.6 / +0.9 | 0.0 / +0.5 / -0.4 | +2.7 / +1.0 |
| trunk_lean_toward_pitcher_ct_deg | -3.9 / -3.7 / -4.6 | +4.2 / +4.5 / +4.5 | -7.3 / +8.6 |
Proposed bands are widened by the largest |p10| / |p90| shift at +-10 deg yaw when that shift exceeds 10% of the p10-p90 width (flag proposed_band_widened_for_yaw in the YAML; applied to stride, stride_sep, head, com_drift, tilt; not applied to knee, separation, timing).
6. Comparison with the app's ranges and proposals
Proposed = p10-p90 of athlete medians (widened for yaw where flagged). current from ranges.yaml (all placeholders, unverified).
| Metric | level | current | proposed | n_ath | confidence | verdict |
|---|---|---|---|---|---|---|
| stride_pct_height (app def: ankle travel) | college | 44-52 | 4.2-25.2 | 73 | medium | current disagrees entirely (0% inside) |
| hs_varsity | 43-51 | 3.5-18.7 | 12 | low | same | |
| stride_sep_fp (foot separation, NOT the app metric) | college | 44-52 | 42.3-55.8 | 73 | medium | current agrees with this quantity (63% inside) |
| hs_varsity | 43-51 | 39.9-52.3 | 12 | low | agrees | |
| foot_plant_to_contact_ms | college | 195-245 | 98-146 | 73 | medium-low | shifted ~70-100 ms later than OBP |
| hs_varsity | 185-235 | 109-158 | 12 | low | shifted | |
| load_tempo_s | college | none | 0.76-1.41 | 73 | low | new, definition-dependent |
| hs_varsity | none | 0.87-1.51 | 12 | low | new | |
| load_launch_ratio | college | none | 5.9-13.6 | 73 | low | new |
| hs_varsity | none | 6.0-12.2 | 12 | low | new | |
| head_movement_pct_height | college | 0-5 | 8.7-18.3 (upper bound proxy) | 73 | low | data higher, but proxy exaggerates; cannot confirm 0-5 |
| lead_knee_angle_contact_deg | college | 150-180 | 153-178 | 73 | low | agrees (95% inside), but see 2D bias |
| hs_varsity | 150-180 | 154-179 | 12 | low | agrees | |
| lateral_trunk_tilt_contact_deg | all | none | 54-85 (not recommended) | 73 | low | metric ill-conditioned; do not enable |
| hip_shoulder_sep_fp_deg | college | -24..-4 | -10..+8 | 73 | low | shifted by ~+14 deg and low validity; reference only |
| hs_varsity | -23..-3 | -18..+5 | 12 | low | shifted | |
| com_drift_pct_height | college | -25..0 | -30.1..-19.3 | 73 | medium | current too wide (2.7x); upper bound 0 never approached |
| hs_varsity | -25..0 | -26.5..-18.3 | 12 | low | too wide (3.7x) |
hs_jv: no data; copy the hs_varsity proposal, confidence low.
7. Caveats and recommendations
- Stride definition mismatch (biggest finding). The PRD's 43-51% matches foot-to-foot separation at foot plant (OBP median 49.9%), not the ankle travel from load start that the app's code and spec compute (median 15%, p10-p90 6-24%). Either change the metric to separation at FP (band ~42-56 for college, with yaw widening) or change the band to the travel band. As defined today, a typical OBP hitter would be flagged "short stride" (0% of athlete medians fall in the current band).
- Timing: OBP fp_100->contact is ~128 ms (175 ms with first touch). The 185-245 ms PRD band is unsupported; re-derive using the app's own detected events on pilot videos. Load tempo/ratio depend wholly on the load_start rule (reconstructed, not OBP-given); values (about 1.1 s, ratio ~9) are plausible but low confidence.
- Head movement: no head landmark in OBP landmarks; the neck-base proxy overstates head motion. Keep the band unverified; the 0-5% placeholder cannot be confirmed or rejected here. The c3d archives (head markers) would fix this.
- Lead knee: band consistent with data, but the face-on 2D angle reads ~28 deg straighter than the real knee and 2D/3D correlation is ~0; do not coach knee flexion from it.
- Lateral trunk tilt and 2D hip-shoulder separation: not meaningful from a chest-facing camera (edge-on shoulders at contact). Do not enable a band; consider trunk lean toward/away from the pitcher instead.
- COM drift: tighten the band to about -30..-19 (college); OBP hip centres are inside the body, so expect an app offset.
- Yaw error of +-10 deg moves stride/com medians by up to ~2 points; +-20 deg up to ~4-5. Tilt of 3 deg is negligible.
- Limits: lab markers (no pose-estimation noise), machine-pitched ~65 mph, mostly college (74 of 98 athletes), HS only 12 athletes, no JV; "typical" is not "ideal" (no performance filtering); event heuristics are reconstructed; percentile bands from 12 athletes are unstable.