Dataset Viewer
Auto-converted to Parquet
Search is not available for this dataset
image
imagewidth (px)
960
960

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. 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
  2. Dataset Preparation
  3. Dataset Format
  4. Usage Examples
  5. Technical Implementation
  6. Repository Structure
  7. 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 for reference on how to download Soccernet Data, or can refer official documentation at Soccernet

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


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)

{
  "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

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

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

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

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

Downloads last month
14

Models trained or fine-tuned on Adit-jain/Soccana_Keypoint_detection_v1

Collection including Adit-jain/Soccana_Keypoint_detection_v1