A real-time bicep curl tracking application using MediaPipe pose estimation to count repetitions and provide visual feedback.
- Real-time pose detection using MediaPipe
- Automatic rep counting for both left and right arms
- Visual feedback with colored landmarks
- SF Pro font rendering for clean, modern UI
- Dual-arm tracking with independent counting
- Configurable parameters for different exercise standards
- Python 3.7+
- OpenCV
- MediaPipe
- NumPy
- PIL (Pillow)
- Install the required dependencies:
pip install opencv-python mediapipe numpy pillow- Ensure you have the
bicep_curl.pymodule in the same directory.
Run the demo:
python simple_bicep_curl_demo.py- Press
qto quit the application
The application displays:
- Rep counts for both arms in large, yellow text
- Colored landmarks:
- 🔵 Blue circles: Shoulders
- 🟢 Green circles: Elbows
- 🔴 Red circles: Wrists
- Pose connections showing the full skeleton
You can adjust these parameters at the top of the script:
IDEAL_ANGLE = 90 # degrees, for a good curl (arm bent at 90°)
TOLERANCE = 20 # degrees, allowed deviation
EXTENDED_THRESHOLD = 160 # degrees, arm considered straight- IDEAL_ANGLE: The target angle for a proper bicep curl (90° = arm bent at right angle)
- TOLERANCE: How much deviation from the ideal angle is acceptable
- EXTENDED_THRESHOLD: The angle at which the arm is considered fully extended for rep counting
- Start of rep: Arm must be extended (angle > 160°) and then begin curling
- End of rep: Arm returns to extended position (angle > 160°)
- Counting: Each complete cycle (extended → curled → extended) counts as one rep
The application uses MediaPipe's pose estimation to track:
- Left shoulder (landmark 11)
- Left elbow (landmark 13)
- Left wrist (landmark 15)
- Right shoulder (landmark 12)
- Right elbow (landmark 14)
- Right wrist (landmark 16)
The elbow angle is calculated using the three-point method:
- Point A: Shoulder
- Point B: Elbow (vertex)
- Point C: Wrist
The angle at the elbow is computed using vector mathematics.
- MediaPipe: Google's framework for building perception pipelines
- OpenCV: Computer vision library for image processing
- NumPy: Numerical computing for angle calculations
- PIL: Python Imaging Library for font rendering
The application attempts to load SF Pro font from macOS system locations:
/System/Library/Fonts/SF-Pro-Text-Regular.otf/System/Library/Fonts/SF-Pro-Text-Bold.otf- Falls back to system default fonts if SF Pro is unavailable
- Optimized for real-time processing
- Configurable detection confidence thresholds
- Efficient landmark tracking with MediaPipe
- "No person detected": Ensure you're visible in the camera frame
- Poor tracking: Adjust lighting conditions or camera position
- Font errors: The app will fall back to default fonts if SF Pro is unavailable
- Position yourself 2-3 feet from the camera
- Ensure good lighting
- Stand with your side profile visible for best tracking
- Keep both arms visible in the frame
├── simple_bicep_curl_demo.py # Main demo application
├── bicep_curl.py # BicepCurl class for angle calculations
├── example curl tracking mediapipe.png # Example screenshot
└── README_simple_bicep_curl_demo.md # This documentation
Feel free to modify the parameters or add new features:
- Adjust rep counting thresholds
- Add audio feedback
- Implement exercise form analysis
- Add data logging capabilities
This project is part of the AI Gym Pose Estimation suite for fitness tracking and analysis.