A prototype application that analyzes baseball or softball swings using OpenPose and biomechanics data. The app processes an uploaded video, extracts pose data, compares the swing against ideal biomechanics, and returns feedback including recommended drills and exercises.
- 📹 Video Upload: Users can upload swing videos via the frontend.
- 🧍 Pose Extraction: Backend uses OpenPose to extract 2D keypoints.
- 📊 Biomechanics Comparison: JSON-based rules compare user swing to ideal form.
- 🧠 Feedback Engine: Detects flaws and maps them to swing drills and muscle exercises.
- ⚛️ Frontend: Built in React with shadcn/ui components for clean display.
Swing Analyzer/
├── swing_analysis_prototype.py # Flask backend with OpenPose integration
├── biomechanics_ideal.json # Biomechanical standards and thresholds
├── requirements.txt # Python dependencies
├── frontend/ # Complete React frontend
│ ├── package.json # Frontend dependencies
│ ├── vite.config.js # Vite configuration
│ ├── tailwind.config.js # Tailwind CSS config
│ ├── postcss.config.js # PostCSS config
│ ├── index.html # HTML entry point
│ └── src/
│ ├── main.jsx # React entry point
│ ├── App.jsx # Main app component
│ ├── index.css # Global styles with Tailwind
│ ├── lib/
│ │ └── utils.js # Utility functions
│ └── components/
│ ├── SwingAnalyzer.jsx # Main analysis component
│ └── ui/ # Reusable UI components
│ ├── card.jsx
│ ├── button.jsx
│ └── progress.jsx
├── .gitignore # Git ignore patterns
└── README.md
- Python 3.8+
- Node.js 16+
- OpenPose (optional - app will use mock analysis if not available)
- Install Python dependencies:
cd "Swing Analyzer"
pip install -r requirements.txt- Run the Flask backend:
python swing_analysis_prototype.pyThe backend will start on http://localhost:5001 with these endpoints:
GET /health- Health check and OpenPose availabilityPOST /analyze- Video analysis endpoint
- Navigate to frontend directory and install dependencies:
cd "Swing Analyzer/frontend"
npm install- Start the development server:
npm run devThe frontend will be available at http://localhost:5173
- Start both backend and frontend servers
- Open
http://localhost:5173in your browser - Upload a swing video (MP4, MOV, AVI up to 100MB)
- Click "Analyze Swing" to get biomechanical feedback
- Review detected issues and recommended drills/exercises
- OpenPose API created with Flask
- Biomechanics-based swing fault detection (hip-shoulder separation sample)
- Drill/exercise feedback mapping in backend
- React frontend with file upload and result cards
- Error handling and graceful UI messaging
-
🔍 More Biomechanical Metrics
- Add ideal ranges for shoulder angle, elbow flexion, stride timing, bat speed, etc.
-
🧠 Machine Learning Model
- Use LSTM or ST-GCN to classify swing errors from sequences
-
🎥 Video Annotation
- Draw keypoints or error labels directly onto swing frames
-
📱 Mobile Support
- Build companion mobile app with camera capture & upload
-
💬 Natural Language Feedback
- Use Codex/GPT-4 to explain what’s wrong and how to fix it conversationally
-
📈 Progress Tracker
- Save historical swing reports to track improvements over time
-
👥 Multi-Athlete Support
- Tag and filter reports by player (e.g., Landyn Hughes #15)
- OpenPose by CMU Perceptual Computing Lab
- UI built with shadcn/ui
{
"hip_shoulder_separation": [30, 60],
"pelvis_rotation_deg": [40, 60],
"bat_speed_mph": [75, 95]
}Feel free to contribute or extend it into a production-grade swing diagnostic tool!