File size: 5,725 Bytes
32674ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a37683
32674ab
6a37683
 
 
 
 
 
 
32674ab
 
6a37683
32674ab
 
 
 
6a37683
32674ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a37683
32674ab
 
6a37683
32674ab
 
6a37683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
license: gpl-3.0
task_categories:
- tabular-classification
- tabular-regression
- image-to-3d
- depth-estimation
pretty_name: AD Trajectories
size_categories:
- 100K<n<1M
---

**Paper in the making**

---

# AD-Trajectories Dataset
This dataset was created for the Master's thesis "From Broadcast to 3D: A Deep Learning Approach for Tennis Trajectory and Spin Estimation" by Alexandra Göppert at the University Augsburg, Chair of Machine Learning and Computer Vision.
The AD-Trajectories dataset is a large-scale synthetic dataset generated using the MuJoCo physics engine. It was built to bridge the synthetic-to-real gap by providing highly accurate physical models of aerodynamic forces, such as the Magnus effect, and complex ball-court interactions.

---
## Dataset Overview

The dataset comprises exactly 187,200 individual synthetic tennis trajectories. All physical kinematics, including the 3D positions, linear velocities, and angular velocities (spin), are captured at a high resolution of 500 frames per second (fps), corresponding to a time step of 0.002 seconds.
The trajectories do not only comprise of the 3D trajectory information (position, velocity, ...) but also include camera parameters that define a camera's intrinsic and extrinsic camera matrix. The camera is always placed behind the baseline on the positive x-axis (see image).

<img src="./camera_and court_origin.png" alt="Camera position in realtion to the world coordinate frame" style="width:50%; height:auto;" >

## Size

The dataset is saved as a .tar file becuase it compromises out of 187,200 individual folders. The tar file has a size of 17 GB. The unpacked dataset has a size of approx. 20 GB

---

# Folder Structure & Metadata
Unlike datasets that use a separate JSON or CSV file for labels, the metadata for each trajectory is encoded directly into its folder path. The repository utilizes a four-tier nested folder structure categorized by the specific properties of the shot:

    Base Stroke (Hit Type): The top-level folder defines the stroke. There are 7 options: groundstroke, lob, serve, short, smash, toss, or volley.
    Direction of Flight: The second tier defines the trajectory's direction in raltion to the camera's position, organized into close_to_far and far_to_close subfolders. Close_to_far means that the ball is flying in the negative x-axis direction. Far_to_close means the ball flies in the positce x-axis direction. 
    Status (In/Out): The third tier indicates whether the ball's first bounce landed validly inside the court (in) or outside the lines (out).
    Trajectory ID: The final folder contains the isolated data for a single shot, numbered sequentially (e.g., trajectory_0000, trajectory_0001, ...).

Example Path: groundstroke/close_to_far/in/trajectory_0000/

---
# Data Structures per Trajectory
Inside each trajectory_xxxx folder, you will find exactly seven .npy files. These numpy arrays store the spatial, temporal, and camera data for that specific sequence:

    positions.npy: The 3D position of the ball (x, y, z) throughout the trajectory, recorded at a resolution of 0.002s.
    velocities.npy: The linear velocity of the ball relative to the world coordinate system, recorded at a resolution of 0.002s.
    rotations.npy: The angular velocity (spin) of the ball in all 3 directions, recorded at a resolution of 0.002s.
    times.npy: A 1D array containing the corresponding timestamps for the positions, velocities, and rotations arrays.
    bounces.npy: Includes the exact timestamps of the bounces occurring during the trajectory, where t=0 represents the start of the trajectory.
    Mint.npy: The intrinsic camera matrix.
    Mext.npy: The extrinsic camera matrix.

The position and velocity is defined in relation to the 3D world coordinate system, which is defined like follows:
<img src="./3d_coordinate_system_in_field.png" alt="Coordinate system definition of 3D world coordinates" style="width:50%; height:auto;" >

The ball spin (rotations.npy) is defined in relation to the ball's local coordinate system. The direction of  which is defined as follows:
<img src="./Screenshot 2026-04-20 194926.png" alt="Definition of the ball's local coordinate system" >

Note on 2D Image Projections: To save space and reduce redundancy, this dataset does not include pre-calculated 2D image projections (u,v). Because both the intrinsic (Mint) and extrinsic (Mext) camera matrices are provided for every trajectory, users can easily calculate the 2D image projections themselves by multiplying the 3D world coordinates by the provided camera matrices.

---

# Download the Dataset

You can download the specific tar file using the hf_hub_download function. This is more efficient than cloning the entire repository if you only need the archive.
Python

```
from huggingface_hub import hf_hub_download
```

```
REPO_ID = "XSpaceCoderX/AD-Trajectories"
FILENAME = "data.tar"

print(f"Downloading {FILENAME}...")

local_path = hf_hub_download(
    repo_id=REPO_ID,
    filename=FILENAME,
    repo_type="dataset"
)

print(f"File downloaded to: {local_path}")
```

## Unpack the Dataset

Once downloaded, you can extract the contents using Python's built-in tarfile module or a system command.
Option A: Using Python (Cross-platform)

This is the recommended way to ensure compatibility across Windows, macOS, and Linux.

```
import tarfile
import os

def extract_tar(file_path, extract_path="."):
    print(f"Extracting {file_path}...")
    with tarfile.open(file_path, "r") as tar:
        tar.extractall(path=extract_path)
    print("Extraction complete!")
```

Note: Make sure you have at least 35-40GB of free disk space (17GB for the archive + ~20GB for the extracted contents).