A comprehensive running form analysis system that uses computer vision and machine learning to analyze running videos, detect gait patterns, and provide detailed biomechanical insights.
- Pose Detection: Uses MediaPipe to detect and track human pose landmarks
- Gait Analysis: Identifies foot strikes, stride patterns, and running cadence
- Video Annotation: Multiple annotation styles with detailed metrics overlay
- Biomechanical Metrics: Calculates stride length, ground contact time, and other key running metrics
- Modern UI: Clean, responsive Next.js frontend with Tailwind CSS
- Video Upload: Easy video upload and processing interface
- Real-time Processing: FastAPI backend for efficient video analysis
- Cloud Storage: Integrated with Supabase for scalable file management
- Background Processing: Automated cron job processing for video analysis
- Email Notifications: Automatic email alerts when analysis is complete
- Batch Processing: Handle multiple videos efficiently
- Python 3.8+
- Node.js 18+
- FFmpeg (for video processing)
-
Clone the repository
git clone <repository-url> cd sports_video
-
Set up the Python environment
pip install -r requirements.txt
-
Set up the web application
# Backend cd webapp/backend pip install -r requirements.txt # Frontend cd ../my-app npm install
-
Configure environment variables
# In webapp/backend/.env SUPABASE_URL=your_supabase_url SUPABASE_KEY=your_supabase_key SUPABASE_BUCKET=your_bucket_name
-
Start the backend server
cd webapp/backend uvicorn main:app --reload -
Start the frontend development server
cd webapp/my-app npm run dev -
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
running_analysis.py- Main analysis engine for detecting running patternsannotate_analysis.py- Creates annotated videos with detailed metricsannotate_with_opencv_pillow.py- Alternative annotation systemannotate_landmarks.py- Pose landmark visualizationannotate_analysis_moviepy.py- MoviePy-based video annotation
# Analyze a running video
python running_analysis.py path/to/video.mp4
# Create annotated output
python annotate_analysis.py path/to/video.mp4
# Process with landmarks overlay
python annotate_landmarks.py path/to/video.mp4The system includes automated processing capabilities:
# Set up cron job (see CRON_SETUP.md for details)
cd webapp/backend
./run_cron.shConfigure email notifications for processing completion:
# See EMAIL_SETUP.md for configuration details
python send_email.pyThe system provides comprehensive running analysis including:
-
Gait Metrics
- Foot strike patterns (heel, midfoot, forefoot)
- Ground contact time
- Flight time
- Cadence (steps per minute)
-
Biomechanical Analysis
- Stride length and frequency
- Vertical oscillation
- Pose landmark tracking
- Joint angle analysis
-
Visual Annotations
- Real-time metrics overlay
- Pose skeleton visualization
- Foot strike indicators
- Performance graphs
- FastAPI - High-performance web framework
- MediaPipe - Google's ML framework for pose detection
- OpenCV - Computer vision and video processing
- NumPy - Numerical computing
- Supabase - Cloud database and storage
- Next.js 15 - React framework with server-side rendering
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- Radix UI - Headless UI components
- PIL/Pillow - Image processing
- MoviePy - Video editing and processing
sports_video/
βββ running_analysis.py # Main analysis engine
βββ annotate_analysis.py # Video annotation
βββ annotate_with_opencv_pillow.py
βββ annotate_landmarks.py
βββ annotate_analysis_moviepy.py
βββ requirements.txt # Python dependencies
βββ videos/ # Video files
βββ mocks/ # Mock data and images
βββ font/ # Font files for annotations
βββ webapp/
β βββ backend/ # FastAPI backend
β β βββ main.py # API endpoints
β β βββ cron_processor.py # Automated processing
β β βββ send_email.py # Email notifications
β β βββ requirements.txt # Backend dependencies
β βββ my-app/ # Next.js frontend
β βββ app/ # Next.js app directory
β βββ components/ # React components
β βββ package.json # Frontend dependencies
- Video Input - Upload or select running video
- Pose Detection - Extract body landmarks using MediaPipe
- Gait Analysis - Analyze foot strikes and running patterns
- Metric Calculation - Compute biomechanical metrics
- Visualization - Generate annotated video with overlays
- Output - Provide analysis results and annotated video
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Linux/macOS/Windows
- Python 3.8+
- Node.js 18+
- 4GB+ RAM (8GB recommended for video processing)
See requirements.txt and webapp/backend/requirements.txt
See webapp/my-app/package.json
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Check the documentation in the
webapp/backend/directory - Review setup guides:
CRON_SETUP.mdandEMAIL_SETUP.md - Create an issue in the repository
- Real-time video processing
- Mobile app integration
- Advanced biomechanical analysis
- Multi-sport analysis support
- AI-powered coaching recommendations