--- task_categories: - object-detection language: - en tags: - soccer - football - pitch - ground - keypoints - camera - calibration - homography pretty_name: Soccana_keyp_v1 size_categories: - 1K ...` ### 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