An AI-powered, real-time exercise form tracker that uses your webcam to detect body pose, count reps, check form quality, visualize progress & symmetry, give voice coaching, and save your workout as a CSV log. Supports Bicep Curls, Squats, Push-ups, and Lunges.
- Real-time Pose Tracking with MediaPipe Pose (33 landmarks).
- Rep Counting with robust stage detection to avoid double counts.
- Form Feedback (on-screen + voice coaching) with color-coded messages.
- Progress Bar (rep completion) and Symmetry Gauge (left/right balance).
- Auto Set & Rest Timer: every 10 reps → start a 60s rest.
- Tutorial Mode: press
hto hear how to perform the current exercise. - Data Logging: press
sto append a detailed row toworkout_data.csv. - Fullscreen Toggle: press
fto focus on movement. - Keyboard Controls to switch exercises instantly.
Most rep counters only detect movement; they don’t care about form. This tracker measures joint angles, detects symmetry between left and right sides, gives actionable tips, and even talks to you so you can keep your eyes off the screen.
- Python
- OpenCV for video capture and on-screen UI overlays
- MediaPipe Pose for landmark detection
- NumPy for angle math
- pyttsx3 for offline Text‑to‑Speech (voice guidance)
Python: 3.9–3.12 recommended
# 1) Create & activate a virtual environment (recommended)
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate
# 2) Install dependencies
pip install -r requirements.txtIf MediaPipe fails to build on Linux, ensure you have recent pip, setuptools, and system build tools installed.
python main.pyThe app starts fullscreen. You can toggle fullscreen with
f.
Key controls
1Bicep Curl2Squat3Push-up4LungehVoice tutorial for the current exercisesSave current session snapshot toworkout_data.csvfToggle fullscreenqQuit
- OpenCV grabs frames from the webcam and draws UI overlays.
- MediaPipe Pose finds body landmarks each frame.
- For the selected exercise, the tracker computes specific joint angles and updates:
- Stage (e.g., “up”/“down”)
- Rep counters and per‑rep timing
- Form feedback, progress, and symmetry
- When form feedback changes (and after a cooldown), pyttsx3 speaks it out without blocking the video loop.
- Press
sto append a row toworkout_data.csv(timestamp, reps/sets, session duration).
- Uses pyttsx3 for local/offline Text‑to‑Speech.
- Runs speaking in a background thread to avoid UI freezes.
- Speaks only when feedback changes and obeys a small cooldown to prevent spam.
hwill speak the tutorial for the current exercise any time.
Below are the core ideas. Thresholds can be tuned per user.
- Landmarks: shoulder → elbow → wrist
- Angle: elbow angle
- Rep logic: when the arm is extended (angle > 160°) → stage =
down; when fully curled (angle < 30°) fromdown→ count 1 rep. - Extras:
- Tracks left & right arms separately with screen‑aware orientation.
- Symmetry score = 100 − (|left−right elbow angle| × factor).
- Progress bar fills as the elbow approaches full curl.
- Landmarks: hip → knee → ankle (both legs)
- Angles: left & right knee angles; uses average
- Rep logic: average angle > 160° → stage =
up; average angle < 90° fromup→ count 1 rep. - Form tips: warns if knees are not aligned (big L/R angle mismatch).
- Landmarks: shoulder → elbow → wrist (both arms) + back line
- Angles: left & right elbow angles; uses average
- Rep logic: average angle > 160° → stage =
up; average angle < 90° fromup→ count 1 rep. - Form tips:
- Checks back straightness using shoulder‑hip‑ankle angle ≈ 180° (tolerance ~15°).
- Gives “go deeper” or “good depth” feedback.
- Landmarks: hips, knees, ankles (both sides) + shoulders
- Angles: both knee angles and both hip angles
- Forward leg detection: the leg with smaller hip angle is considered forward.
- Rep logic: forward knee < 90° from
upand back leg > 160° → count 1 rep. - Form tips: asks to straighten back leg, align knees with ankle, or step deeper.
- Top‑left panel: exercise name, reps (both arms for curls), set #, stage, workout timer, rest countdown when active.
- Progress bar: bottom‑left (0–100% of the current rep).
- Symmetry gauge: top‑right circular meter (0–100).
- Color‑coded feedback:
- 🟩 Green — good form cues
- 🟧 Orange — caution (improve depth/range)
- 🟥 Red — form issues (e.g., knees misaligned / back not straight)
- Columns: Timestamp, Exercise, Left Reps, Right Reps, Total Reps, Sets, Workout Duration.
- For Bicep Curls, left/right reps are recorded independently; for other exercises, those columns are “-”.
- A simple
---divider row separates sessions.
Tip: You can import the CSV into a spreadsheet to visualize progress.
- Set size: 10 reps (auto rest after reaching 10).
- Rest duration: 60s.
- Voice rate: adjustable in
main.py. - Angle thresholds: inside
exercise_tracker.py(per‑exercise).
.
├── main.py # App entry: webcam loop, drawing, keyboard, voice
├── exercise_tracker.py # Exercise logic: counters, stages, feedback, saving
├── pose_utils.py # Math helpers: angles, landmark fetch, UI widgets
├── workout_data.csv # Created at runtime when you press 's'
├── requirements.txt
└── README.md
- No camera found: ensure another app isn’t using the webcam; try a different index in
cv2.VideoCapture(0). - No voice output: check system volume; on Linux, install a TTS backend (e.g.,
espeak). - Low FPS: reduce camera resolution or close other apps. Lighting significantly affects pose stability.
- Mediapipe install issues: upgrade
pip/setuptools, or try a different Python version (3.10–3.11 work well).
- Per‑user calibration of angle thresholds
- More exercises (plank, shoulder press, deadlift with safety checks)
- Workout history dashboard & charts
- Rep speed / tempo analysis and coaching
- Optional cloud sync
- MediaPipe team for high‑quality pose estimation
- OpenCV community
- pyttsx3 contributors for simple offline TTS
MIT — feel free to use and adapt. Consider opening PRs for improvements!