Datasets:
File size: 10,549 Bytes
c4e14f8 e3452de c4e14f8 e3452de |
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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
---
task_categories:
- object-detection
language:
- en
tags:
- soccer
- football
- pitch
- ground
- keypoints
- camera
- calibration
- homography
pretty_name: Soccana_keyp_v1
size_categories:
- 1K<n<10K
---
# SoccerNet Keypoints Dataset
---
## Introduction
The SoccerNet Keypoints dataset is a comprehensive computer vision dataset for soccer field keypoint detection and pitch object localization. This dataset is derived from the SoccerNet calibration dataset and provides precise field keypoints extracted from line endpoints, enabling accurate field analysis, camera calibration, and tactical analysis in soccer videos.
In order to download the dataset, download Soccernet Calibration Dataset as given in [Soccernet Official Documentation](https://www.soccer-net.org/data). This repository contains keypoints and Object labels for the Soccernet data. (Soccernet by default provides edges.)
The dataset combines computer vision techniques including line intersection calculations, green area detection for pitch objects, and comprehensive keypoint extraction to create a robust dataset for Football Field Keypoint Detection
## Index
1. [Dataset Details](#dataset-details)
2. [Dataset Preparation](#dataset-preparation)
3. [Dataset Format](#dataset-format)
4. [Usage Examples](#usage-examples)
5. [Technical Implementation](#technical-implementation)
6. [Repository Structure](#repository-structure)
7. [Samples](#samples)
## Dataset Details
### Overview
- **Source**: SoccerNet Calibration Dataset
- **Task**: Keypoint Detection and Pitch Object Detection
- **Total Classes**: 1 (Pitch Object)
- **Total Keypoints**: 29 field keypoints per image
- **Coordinate System**: Normalized coordinates (0-1 range)
- **Annotation Format**: JSON + YOLO format
- **Dataset Splits**: Train, Validation, Test
### Classes and Objects
#### Object Detection Classes
- **Class 0: Pitch Object**
- Complete green field area is termed at pitch object
- Bounding box encompasses entire visible pitch
- Normalized coordinates with center_x, center_y, width, height format
#### Keypoint Classes (29 Field Keypoints)
The dataset provides 29 precisely calculated field keypoints covering:
1. **Field Boundaries (4 points)**
- `0_sideline_top_left`
- `9_sideline_bottom_left`
- `16_sideline_top_right`
- `25_sideline_bottom_right`
2. **Penalty Areas - Big Box (8 points)**
- Left side: `1_big_rect_left_top_pt1`, `2_big_rect_left_top_pt2`, `3_big_rect_left_bottom_pt1`, `4_big_rect_left_bottom_pt2`
- Right side: `17_big_rect_right_top_pt1`, `18_big_rect_right_top_pt2`, `19_big_rect_right_bottom_pt1`, `20_big_rect_right_bottom_pt2`
3. **Goal Areas - Small Box (8 points)**
- Left side: `5_small_rect_left_top_pt1`, `6_small_rect_left_top_pt2`, `7_small_rect_left_bottom_pt1`, `8_small_rect_left_bottom_pt2`
- Right side: `21_small_rect_right_top_pt1`, `22_small_rect_right_top_pt2`, `23_small_rect_right_bottom_pt1`, `24_small_rect_right_bottom_pt2`
4. **Center Line and Circle (6 points)**
- `11_center_line_top`
- `12_center_line_bottom`
- `13_center_circle_top`
- `14_center_circle_bottom`
- `15_field_center`
- `27_center_circle_left`, `28_center_circle_right`
5. **Semicircles (2 points)**
- `10_left_semicircle_right`
- `26_right_semicircle_left`
---
## Dataset Preparation
### Download Process
View [downloader.py](https://github.com/Adit-jain/Soccer_Analysis/blob/main/Data_utils/SoccerNet_Keypoints/downloader.py) for reference on how to download Soccernet Data, or can refer official documentation at [Soccernet](https://www.soccer-net.org/data)
### Processing Pipeline
The dataset preparation follows the following steps:
#### Line-to-Keypoint Conversion (`line_intersections.py`)
- **Class**: `LineIntersectionCalculator`
- **Input**: SoccerNet JSON files with line endpoints
- **Process**: Calculate 29 field keypoints from line intersections using geometric algorithms
- **Key Methods**:
- `line_intersection()`: Calculate intersection points between two lines
- `calculate_field_keypoints()`: Generate all 29 keypoints from line data
- `point_to_line_distance()`: Calculate perpendicular distances for circle keypoints
#### Pitch Object Detection (`get_pitch_object.py`)
- **Class**: `PitchDetector`
- **Process**: Detect complete green field area using HSV color segmentation
- **Key Methods**:
- `detect_green_area()`: HSV-based green area detection with morphological operations
- `find_largest_contour()`: Identify the largest contour as the pitch
- `get_pitch_bounding_box()`: Calculate normalized bounding box from contour
#### Unified Processing (`process_images.py`)
- **Function**: `process_unified_soccernet_dataset()`
- **Output Formats**:
- **JSON annotations**: Complete metadata with keypoints and pitch objects
- **YOLO labels**: Ultralytics-compatible format for training
- **Visualization images**: Annotated images showing detections
#### Dataset Configuration (`create_dataset_yaml.py`)
- Generate `dataset.yaml` for Ultralytics YOLO training
- Configure keypoint connections for visualization
- Set up dataset paths and class definitions
**[Github Repo](https://github.com/Adit-jain/Soccer_Analysis/tree/main/Data_utils/SoccerNet_Keypoints)**
---
## Dataset Format
### Directory Structure
```
unified_output/
βββ annotations_json/ # Complete JSON annotations
β βββ train/
β βββ valid/
β βββ test/
βββ processed_images/ # Visualization images
β βββ train/
β βββ valid/
β βββ test/
βββ yolo_labels/ # Ultralytics YOLO format
β βββ train/
β βββ valid/
β βββ test/
βββ dataset.yaml # YOLO configuration
βββ README.md # Usage instructions
```
### Annotation Formats
#### JSON Format (Complete Annotations)
```json
{
"image_info": {
"file_name": "image.jpg",
"path": "/path/to/image.jpg",
"width": 1920,
"height": 1080
},
"pitch_object": {
"class_id": 0,
"class_name": "pitch",
"center_x": 0.5,
"center_y": 0.5,
"width": 0.8,
"height": 0.6,
"x_min": 0.1,
"y_min": 0.2,
"x_max": 0.9,
"y_max": 0.8,
"area": 0.48,
"contour_area": 0.45
},
"keypoints": {
"0_sideline_top_left": [0.1, 0.2],
"1_big_rect_left_top_pt1": [0.15, 0.25],
...
},
"original_lines": {
"Side line top": [{"x": 0.1, "y": 0.2}, {"x": 0.9, "y": 0.2}],
...
},
"dataset_split": "train",
"total_keypoints": 29,
"annotation_format": "SoccerNet_unified_v1"
}
```
#### YOLO Format (Ultralytics Compatible)
```
0 0.500000 0.500000 0.800000 0.600000 0.100000 0.200000 2 0.150000 0.250000 2 ... (29 keypoints with visibility)
```
Format: `<class-index> <center_x> <center_y> <width> <height> <kp1_x> <kp1_y> <kp1_visibility> <kp2_x> <kp2_y> <kp2_visibility> ...`
### Keypoint Visibility
- **2**: Visible keypoint (calculated successfully)
- **0**: Not visible/not detected (coordinates set to 0.0, 0.0)
### Coordinate System
- All coordinates normalized to [0, 1] range
- Origin (0,0) at top-left corner of image
- X-axis increases rightward, Y-axis increases downward
---
## Usage Examples
### Training with Ultralytics YOLO
```python
from ultralytics import YOLO
# Load pre-trained pose model
model = YOLO('yolov8n-pose.pt')
# Train on SoccerNet Keypoints
results = model.train(
data='dataset.yaml',
epochs=100,
imgsz=640,
batch=16,
name='soccernet_keypoints'
)
```
### Custom Processing
```python
from get_pitch_object import PitchDetector
from line_intersections import LineIntersectionCalculator
# Initialize processors
pitch_detector = PitchDetector()
keypoint_calculator = LineIntersectionCalculator()
# Process single image
pitch_result = pitch_detector.detect_pitch_from_image('image.jpg')
keypoint_calculator.load_soccernet_data('annotations.json')
keypoints, lines = keypoint_calculator.calculate_field_keypoints()
```
### Visualization
```python
from process_images import create_unified_visualization
create_unified_visualization(
image_path='image.jpg',
pitch_data=pitch_result['pitch_detection'],
keypoints=keypoints,
lines=lines,
output_path='annotated_image.jpg'
)
```
---
## Technical Implementation
### Core Algorithms
#### Line Intersection Mathematics
Using parametric line representation:
- Line 1: `P = P1 + t(P2 - P1)`
- Line 2: `Q = Q1 + u(Q2 - Q1)`
- Intersection calculated using determinant method with parallel line detection
#### HSV Color Segmentation
- Green detection optimized for grass fields
- Morphological operations for noise reduction
- Largest contour selection for pitch identification
#### Keypoint Validation
- Coordinate boundary checking [0,1]
- Distance-based point selection for circles
- Error handling for missing line data
### Performance Optimizations
- Batch processing with progress tracking
- Efficient contour operations
- Optimized intersection calculations
- Memory-efficient image processing
---
## Repository Structure
**GitHub Repository**: [https://github.com/Adit-jain/Soccer_Analysis/tree/main/Data_utils/SoccerNet_Keypoints](https://github.com/Adit-jain/Soccer_Analysis/tree/main/Data_utils/SoccerNet_Keypoints)
### Module Overview
- `constants.py`: Dataset configuration and field specifications
- `downloader.py`: SoccerNet data download utilities
- `get_pitch_object.py`: Pitch object detection using color segmentation
- `line_intersections.py`: Geometric keypoint calculation from line endpoints
- `process_images.py`: Unified processing pipeline for all formats
- `create_dataset_yaml.py`: YOLO configuration generation
- `transfer_json_files.py`: Data organization utilities
### Integration
This dataset preparation module integrates seamlessly with the main Soccer Analysis project, providing field keypoints for:
- Camera calibration and homography estimation
- Tactical analysis and player positioning
- Field coordinate transformations
- Real-time field understanding in soccer videos
The dataset serves as a foundation for advanced soccer analysis applications including tactical analysis, player tracking calibration, and automated field understanding systems.
---
## Samples
<p align="center">
<img src="00024_annotated.jpg" width="800"/>
<img src="00112_annotated.jpg" width="800"/>
<img src="00233_annotated.jpg" width="800"/>
<img src="00313_annotated.jpg" width="800"/>
<img src="00580_annotated.jpg" width="800"/>
</p> |