Skip to content

feat: add exclude_missing_ball_frames option for all tracking providers - #600

Open
aleks-drozy wants to merge 1 commit into
PySport:masterfrom
aleks-drozy:explore/exclude-missing-ball-frames
Open

feat: add exclude_missing_ball_frames option for all tracking providers#600
aleks-drozy wants to merge 1 commit into
PySport:masterfrom
aleks-drozy:explore/exclude-missing-ball-frames

Conversation

@aleks-drozy

Copy link
Copy Markdown

Closes #528.

Adds an exclude_missing_ball_frames: bool = False parameter to every tracking provider (PFF, Second Spectrum, SkillCorner, Sportec, StatsPerform, Tracab), threaded through TrackingDataDeserializer.__init__ and stored as self.exclude_missing_ball_frames. When enabled, frames where ball_coordinates is None after parsing are skipped, matching the design agreed on in the #523 discussion (which only covered Second Spectrum).

Additionally, for Second Spectrum specifically, I found the deserializer was not parsing the provider's own missing-ball sentinel: it uses a ball z-coordinate of -10 to mean "not tracked", but the code was previously constructing a literal Point3D(x, y, -10) for those frames instead of None. That's fixed so ball_coordinates is None for sentinel frames regardless of whether exclude_missing_ball_frames is set — this seemed like the correct fix rather than working around it, since otherwise the new flag would have nothing to filter on Second Spectrum data containing the sentinel.

For the other five providers, missing-ball frames come from data that's simply absent/null in the source (no numeric sentinel), so no equivalent sentinel-parsing fix was needed there — just the new opt-in filter.

Testing:

  • New regression test test_missing_ball_sentinel_parsed_as_none for Second Spectrum, using a small fixture file with one normal frame and one sentinel (z=-10) frame, asserting the sentinel frame parses to ball_coordinates=None.
  • New test_exclude_missing_ball_frames test per provider, verifying the flag actually filters out None-ball frames.
  • Full affected test suite: 81 passed.
  • ruff check / ruff format --check: clean.

Happy to adjust naming/scope if you'd prefer a different API shape than what #523 converged on.

…iders

Adds an exclude_missing_ball_frames parameter (default False) to the
tracking deserializers for PFF, Second Spectrum, SkillCorner, Sportec,
StatsPerform, and Tracab. When enabled, frames with sentinel/missing
ball coordinates are parsed with ball_coordinates=None instead of
being silently dropped or producing bogus values, matching the design
converged on in PySport#523 discussion.

Sportec has no native missing-ball sentinel, so the flag is accepted
as a documented no-op there for interface consistency.

Addresses PySport#528.
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.

Adding exclude_missing_ball_frames for all tracking data providers

1 participant