A comprehensive sports analytics platform that provides real-time player and ball tracking, tactical analysis, performance feedback, and automated refereeing assistance for live sports events and uploaded video files.
- Identify and track all players on the field/court from live video feeds
- Visualize player IDs and movement trajectories as overlays
- Support multiple simultaneous player tracking with minimal latency
- Accurate ball detection and position tracking
- Real-time ball trajectory visualization
- Ball possession analysis
- Team formation detection (4-4-2, 4-3-3, etc.)
- Player spacing and distance analysis
- Heatmaps showing player activity zones
- Passing pattern analysis and ball possession statistics
- Individual player metrics (speed, distance, sprints, shot accuracy)
- Team performance indicators (possession %, total shots)
- Real-time dashboard with key statistics
- Computer vision algorithms for critical decisions
- Offside detection in football
- Line call assistance for tennis and other sports
- Process pre-recorded sports videos (MP4, AVI)
- Same analysis capabilities as live feeds
- Video player controls with synchronized analytics
- Flask: Web framework with WebSocket support
- OpenCV: Computer vision and video processing
- YOLO (Ultralytics): Real-time object detection
- MediaPipe: Pose estimation and tracking
- NumPy/SciPy: Numerical computations
- Matplotlib/Seaborn: Data visualization
- React: Modern UI framework
- Socket.IO: Real-time communication
- Canvas API: Video overlay rendering
- Chart.js: Interactive data visualizations
- Clone the repository
git clone <repository-url>
cd sports-analytics
- Set up Python environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
- Set up Node.js environment
cd frontend
npm install
- Download YOLO models
python scripts/download_models.py
- Start the backend server
python app.py
- Start the frontend development server
cd frontend
npm start
- Access the application
- Open http://localhost:3000 in your browser
- For live video analysis, connect a camera or video stream
- For uploaded video analysis, use the file upload feature
sports-analytics/
├── app.py # Main Flask application
├── requirements.txt # Python dependencies
├── models/ # AI/ML models
├── utils/ # Utility functions
├── static/ # Static files
├── templates/ # HTML templates
├── frontend/ # React frontend
├── scripts/ # Setup and utility scripts
└── data/ # Sample data and videos
GET /
: Main application pagePOST /upload
: Video file uploadGET /api/analysis/<video_id>
: Get analysis resultsWebSocket /socket.io
: Real-time video processing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details