Revolutionizing Cricket Analytics: Predicting Ball Trajectories with Precision and Innovation
This project aims to predict the trajectory of a cricket ball in videos using advanced object detection and tracking techniques powered by YOLOv8. The system extracts frames from cricket videos, detects the cricket ball, and predicts its future trajectory, providing detailed insights into its motion.
- Cricket Ball Detection: Utilizes YOLOv8 for precise detection of cricket balls in diverse scenarios.
- Trajectory Prediction: Predicts the future positions of the ball based on its current trajectory.
- Angle Calculation: Calculates the angle of the ball's motion, identifying key events like bounces.
- Dataset Creation: Custom dataset with 1778 annotated images created from YouTube videos for robust model training.
- Real-time Tracking: Processes live or pre-recorded cricket videos for instant ball tracking.
└── kushagra3204-Cricket-Ball-Trajectory-Prediction/
├── runs/
│ └── detect/ # YOLOv8 training outputs
├── youtube_video_image_extractor.py # Extract frames from YouTube videos
├── yolov8s.pt # YOLOv8 small model
├── predict.py # Ball detection and trajectory prediction
├── modelSave.py # Save trained model to ONNX format
├── yolov8m.pt # YOLOv8 medium model
├── videos/ # Directory to store test videos
├── requirements.txt # Python dependencies
├── yolov8l.pt # YOLOv8 large model
├── ball_tracking_train.py # YOLOv8 training script
├── README.md # Project documentation
├── yolov8n.pt # YOLOv8 nano model
└── data.yaml # Dataset configuration for YOLOv8
-
Clone the Repository
git clone https://github.com/kushagra3204/Cricket-Ball-Trajectory-Prediction.git cd Cricket-Ball-Trajectory-Prediction
-
Install Dependencies
pip install -r requirements.txt
-
Download Pre-trained Models Place the YOLOv8 models (
yolov8n.pt
,yolov8s.pt
, etc.) in the project directory.
Use youtube_video_image_extractor.py
to extract frames from a YouTube video:
python youtube_video_image_extractor.py
Train the YOLOv8 model with the custom dataset:
python ball_tracking_train.py
Detect the ball and predict its trajectory:
python predict.py
Export the trained model to ONNX:
python modelSave.py
The dataset includes 1778 annotated images in YOLOv8 format, created by extracting frames from cricket videos using LabelImg.
- Diverse Conditions: Includes images under various lighting and background conditions.
- Real-world Scenarios: Captures cricket balls in motion, both in gameplay and practice settings.
- Multiple Ball States: Covers new and worn cricket balls for comprehensive detection.
- Real-time Cricket Analysis: Player performance analysis, ball trajectory tracking, and umpiring.
- Broadcasting Enhancements: Real-time overlays, highlights, and ball tracking.
- Automated Summarization: Key moment extraction for highlight reels.
Below are some visual examples showcasing the system in action:
We warmly invite researchers, developers, and enthusiasts from around the world to join us in making this project even more impactful. Your unique skills and ideas can help elevate this work to new heights, revolutionizing the field of sports analytics and cricket ball trajectory prediction.
Whether you're contributing code, refining models, expanding datasets, or sharing feedback, your collaboration is invaluable in advancing this mission. Together, we can create a groundbreaking tool that enhances cricket analysis, assists players, and engages fans globally.