Skip to content

feat: add SPEED mode with gated homography (PR 3)#61

Draft
AlexBodner wants to merge 6 commits into
feat/soccer-pr2-directionfrom
feat/soccer-pr3-speed
Draft

feat: add SPEED mode with gated homography (PR 3)#61
AlexBodner wants to merge 6 commits into
feat/soccer-pr2-directionfrom
feat/soccer-pr3-speed

Conversation

@AlexBodner

@AlexBodner AlexBodner commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds SPEED analytics mode: per-player ground-speed badges (m/s), direction dots, and a translucent radar minimap.
  • Pitch keypoint detection (detection.py), keypoint cache, and homography replay gating for stable m/s metrics.
  • m/s computation and display smoothing live in examples/soccer/speed.py; shared motion primitives stay in kinematics.py.

Stack: PR 1 → PR 2 (base) → this PR

Demo

SPEED mode — m/s badges + radar minimap (08fd33_0.mp4, truncated preview).

Download full demo clip

Homography design

  • fit_pitch_homography — ungated per-frame fit (minimap).
  • replay_gated_transforms — temporal reproj + jump gating for speed badges (loop-local state, no gate class).
  • gap_fill_speed_transforms — gated H where accepted, else ungated minimap H for badge display.

Scope

  • Pitch CLI flags (--pitch-detector, --pitch-model-path, --pitch-model-id)
  • Lazy homography maps on VideoTrackingSession (gap_filled_transforms_by_frame, minimap_transforms_by_frame)
  • Speed badge / chip drawing in motion.py (shared with PR4 distance labels)

Not included: distance traces, goal shading, defender locks, ball/possession/pass analytics.

Test plan

  • Merge PR 2 first (rebase if PR 2 changes during review)
  • python main.py --source_video_path data/2e57b9_0.mp4 --target_video_path data/renders/speed-test.mp4 --mode SPEED --max-frames 90 --tracker bytetrack
  • Verify pitch keypoint cache hit on second run (--cache)
  • Confirm m/s badges and minimap render; DIRECTION mode unchanged

AlexBodner and others added 6 commits July 1, 2026 20:49
Introduce pitch detection cache, speed badges, plain minimap, and
Mode.SPEED. Sequence gating lives on fit_pitch_homography via
HomographyGateState instead of a separate tracker class.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pitch detector options belong in PR3 where keypoint cache and
homography-backed speed are wired.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep m/s computation in speed.py, dedupe model and min-speed constants,
reuse minimap transforms for gap-fill, drop unused homography helper,
and document SPEED in the soccer README.

Co-authored-by: Cursor <cursoragent@cursor.com>
fit_pitch_homography is ungated per-frame fit only. Temporal reproj and
jump gating uses local locked/last_was_accept vars in the replay loop.

Co-authored-by: Cursor <cursoragent@cursor.com>
Reuse DEFAULT_*_MODEL_ID in main.py, align pitch detector threshold
API with player detector, document gate/sprint constants, and type
_speed_by_tid transformer.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore local PITCH_DETECTION_MODEL_PATH for legacy modes and use
inline analytics model-id defaults instead of library constants.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant