An AI-powered gym training assistant that uses computer vision and pose estimation to count your exercise repetitions in real time. Currently tracks bicep curls — with the angle of the right arm detected frame-by-frame, the system counts every complete rep and displays a live progress bar.
- Real-time pose detection powered by MediaPipe
- Automatic rep counting — no buttons, no timers, just move
- Live progress bar showing how far through the current rep you are (0 → 100%)
- Rep counter panel displayed on screen
- Works with a webcam feed or a pre-recorded video file
| Technology | Purpose |
|---|---|
| Python 3 | Core language |
OpenCV (cv2) |
Video capture, drawing overlays |
| MediaPipe | Human pose landmark detection |
| NumPy | Angle-to-percentage interpolation |
- Python 3.8 or higher
- A webcam or a compatible
.mp4video file
-
Clone the repository
git clone https://github.com/Mpradeep-dev/AI_Trainer.git cd AI_Trainer -
Install dependencies
pip install opencv-python mediapipe numpy
python main.pyBy default main.py reads res/gym1.mp4.
Open main.py and change line 5:
# Use webcam
vid = cv.VideoCapture(0)
# Use a video file
vid = cv.VideoCapture("res/gym1.mp4")| Key | Action |
|---|---|
Esc |
Quit |
AI_Trainer/
├── main.py # Entry point — video loop, rep counting, UI overlays
├── pose_module.py # Reusable pose detector class (MediaPipe wrapper)
├── res/
│ └── gym1.mp4 # Sample workout video
└── README.md
- Frame capture — each video frame is read and resized to 2× for better visibility.
- Pose landmarks — MediaPipe identifies 33 body key-points per frame.
- Angle calculation — the angle at the elbow (shoulder → elbow → wrist, landmarks 12-14-16) is computed using
atan2. - Rep counting — the angle is interpolated to a 0–100% range. A full rep is counted when the arm goes from 0 % → 100 % → 0 % (or vice-versa).
- Overlays drawn:
- Right-side magenta bar = current rep progress.
- Bottom-left green panel = total reps completed.
12 → Right Shoulder
14 → Right Elbow (vertex of the angle)
16 → Right Wrist
dec = pm.detector()
img = dec.find_pose(img, draw=True) # Draw skeleton on frame
lmks = dec.get_conn(img, draw=False) # Returns list of [id, cx, cy]
angle = dec.find_angle(p1, p2, p3, img, draw=True) # Angle at p2- Support multiple exercises (squats, push-ups, shoulder press)
- Voice feedback announcements ("Rep 5 done!")
- Web or desktop GUI with session history
- Webcam auto-detection with file-path fallback
- Export rep data to CSV / JSON
This project is open source and available under the MIT License.