A real-time exercise posture correction app that uses your webcam to detect exercises, count reps, and speak corrections aloud to help you maintain proper form.
- Exercise Detection — Automatically identifies squats, push-ups, and planks from your webcam feed
- Rep Counting — Tracks repetitions with a state machine (and hold time for planks)
- Posture Analysis — 11 rule-based checks across 3 exercises using joint angle calculations
- Voice Feedback — Speaks corrections through your browser speakers with smart throttling (no repeated nagging)
- Visual Overlay — Color-coded skeleton (green/orange/red) with feedback text on the video feed
- EMA Smoothing — Reduces landmark jitter for stable angle readings
| Exercise | Rules Checked |
|---|---|
| Squat | Back straightness, knee valgus (caving in), squat depth, knees over toes |
| Push-up | Body alignment (sag/pike), elbow flare, range of motion, head position |
| Plank | Hip position (sag/pike), head alignment, elbow placement under shoulders |
- MediaPipe — Pose estimation (33 body landmarks)
- Streamlit — Web UI
- streamlit-webrtc — Real-time webcam streaming
- OpenCV — Frame processing and visual overlay
- Web Speech API — Browser-native text-to-speech for voice feedback
- Python 3.10+
- Webcam
- A browser that supports Web Speech API (Chrome, Edge, Safari)
git clone https://github.com/alphoder/Exercise-Predictor-and-Posture-corrector.git
cd Exercise-Predictor-and-Posture-corrector
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtstreamlit run app.pyThe app opens in your browser. Click START, allow camera access, and begin exercising.
- Position your camera from the side for best results with all three exercises
- Ensure your full body is visible in the frame
- Good lighting improves pose detection accuracy
- Use the sidebar to toggle voice feedback on/off or reset the rep counter
├── app.py # Streamlit UI, WebRTC streaming, main pipeline
├── pose_estimator.py # MediaPipe PoseLandmarker wrapper + visual overlay
├── exercise_classifier.py # Exercise detection + rep counting state machine
├── posture_analyzer.py # Per-exercise posture correction rules
├── voice_feedback.py # Throttled TTS via Web Speech API
├── angle_utils.py # Joint angle geometry calculations
├── config.py # All thresholds and constants
└── requirements.txt # Dependencies
Each webcam frame flows through this pipeline (~20-35ms per frame):
Webcam Frame
→ MediaPipe Pose (33 landmarks)
→ Exercise Classifier (orientation + angle patterns → exercise type + rep state)
→ Posture Analyzer (joint angle rules → feedback list)
→ Visual Overlay (colored skeleton + text)
→ Voice Queue (throttled, priority-sorted browser TTS)
MIT