Refactor tracking data model#377
Conversation
This commit adds support for computing the speed and acceleration of the ball and the players from tracking data.
For savitzky-golay filter
|
@probberechts when considering joint tracking I would propose not adding it directly as Additionally, we should probably consider that joint data does not always come in the form of world coordinates, but sometimes it is provided as "angles" (e.g. "head_angle", "hip_angle" etc.) without the inclusion of coordinates. |
|
Hi, I came across this PR and wanted to suggest an approach using the MultiIndex. This allows for convenient working with:
Here is an example: import pandas as pd
data = [
{
("frame_id", "", ""): 1,
("phase", "", ""): 1,
("home", 9, "position"): (0.7, 0.5),
("away", 7, "position"): (0.3, 0.35),
("ball", "position", ""): np.array([0.5, 0.5, 0.0]),
("ball", "status", ""): "dead"
},
{
("frame_id", "", ""): 2,
("phase", "", ""): 1,
("home", 9, "position"): (0.75, 0.52),
("away", 7, "position"): (0.31, 0.36),
("ball", "position", ""): np.array([0.56, 0.47, 0.0]),
("ball", "status", ""): "alive"
}
]
multi_columns = pd.MultiIndex.from_tuples(data[0].keys())
tracking_df = pd.DataFrame(data, columns=multi_columns)
# Fetch all frame ids
print(tracking_df["frame_id"])
# Fetch all info about frame with given frame id
print(tracking_df[tracking_df["frame_id"] == 2])
# Fetch all info about ball
print(tracking_df["ball"])
# Fetch all info about home team
print(tracking_df["home"])
# Fetch ball status from given frame
print(tracking_df.loc[0, ("ball", "status")])
# Fetch positions from all frames for home players only
print(tracking_df.loc[:, pd.IndexSlice["home", :, "position"]])Since I haven't use this package that much yet, I'm not able to tell if this could cover 100% of current features. I'm aware that kloppy's approach is more object oriented, but maybe it's worth exploration. |
This pull request proposes a new domain model for tracking data and updates various serializers to align with it.
The idea is that a tracking dataset is a collection of object detections. There are two ways to organize this collection:
The deserializers still create the frame-based representation but you can now also compute the trajectory-based representation for any trackable object.
Why this is better
I think this has a few advantages:
Breaking changes
PlayerDataentity was replaced by aDetectionentityStill thinking about
Detection, aDetection.joint_coordinatesattribute, ...?MaybeEdit: Now usingDetectionis too ambiguous for an entity name?TrackedObjectState