-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hawk-Eye Innovations #324
Comments
I'm not aware of anyone planning to add support for Hawk-Eye but a deserializer for Hawk-Eye tracking data would certainly be welcome. |
I have an implementation at https://github.com/probberechts/kloppy/tree/feat/hawkeye. I didn't create a PR yet because I only did some very limited testing on a single game, but it should be functional. Below is an example of how to use the API: from pathlib import Path
from kloppy import hawkeye
hawkey_data_dir = Path(...)
season_id = 2024
league_id = 2
match_id = 1234
period_id = "*"
minute_id = "*"
# Load the 2D tracking data of the ball and the player centroids.
data_tracking = hawkeye.load(
ball_feeds=sorted(hawkey_data_dir.glob(f'{season_id}_{league_id}_{match_id}_{period_id}_{minute_id}.football.samples.ball.gz')),
player_centroid_feeds=sorted(hawkey_data_dir.glob(f'{season_id}_{league_id}_{match_id}_{period_id}_{minute_id}.football.samples.centroids.gz')),
show_progress=True
)
# Loading the complete joint tracking data for a full game will probably require too much memory.
# There are two options.
# The first option is to load the data in batches.
# For example, to load all joint tracking data for the first minute of the game
data_joints = hawkeye.load(
ball_feeds=[hawkey_data_dir / 'f'{season_id}_{league_id}_{match_id}_1_1.football.samples.ball.gz'],
player_centroid_feeds=[hawkey_data_dir / f'{season_id}_{league_id}_{match_id}_1_1.football.samples.centroids.gz'],
player_joint_feeds=[hawkey_data_dir / f'{season_id}_{league_id}_{match_id}_1_1.football.samples.joints.gz'],
show_progress=False
)
# The second option is to load joint data only for a subset of tracking frames and or players.
# This can be configured by providing a function.
def load_joint_data(frame, player):
# only load joint data for a specific player
is_player = player.jersey_no == 20
# only load joint data for frames where the ball is closer than 2m to this player
ball_close = frame.players_data[player].coordinates.distance_to(frame.ball_coordinates) < 2
return is_player and ball_close
data_joints = hawkeye.load(
ball_feeds=sorted(hawkey_data_dir.glob('f'{season_id}_{league_id}_{match_id}_{period_id}_{minute_id}.football.samples.ball.gz')),
player_centroid_feeds=sorted(hawkey_data_dir.glob(f'{season_id}_{league_id}_{match_id}_{period_id}_{minute_id}.football.samples.centroids.gz')),
player_joint_feeds=sorted(hawkey_data_dir.glob(f'{season_id}_{league_id}_{match_id}_{period_id}_{minute_id}.football.samples.joints.gz')),
load_joint_data=load_joint_data,
show_progress=True
) |
Sorry for asking such a basic question, but how do I access the reference ‘from kloppy import hawkeye’? |
What do you mean by "The link doesn't seem to work"? Do you (1) get a 404 (try again, I guess; it might have been a server problem at GitHub), (2) do not have access permissions (that would be strange; I'm sure the fork is public) or (3) do not know how to install the library from a fork? The most straightforward method to install it is through pip with: pip install "git+https://github.com/probberechts/kloppy@feat/hawkeye" or in editable mode (allows you to make changes to the code) with: pip install -e "git+https://github.com/probberechts/kloppy@feat/hawkeye#egg=kloppy" |
Is there any plan to add Hawk-Eye Innovations tracking data?
The text was updated successfully, but these errors were encountered: