๐ฅ Demo Video Watch the demo = https://github.com/gaurav02081/push-up-tracker-ai/blob/main/assets/demo.mp4
A computer vision-based push-up counter that uses MediaPipe for real-time pose detection and tracking. The application automatically counts your push-ups by monitoring your elbow angle and provides visual feedback.
- Real-time pose tracking using MediaPipe
- Automatic rep counting based on elbow angle
- Visual feedback with progress bars and angle display
- Session logging to CSV file with timestamps and statistics
- Optional face recognition using InsightFace
- Session summary popup at the end of each workout
- User-friendly interface with clear visual indicators
Before you begin, ensure you have:
- Windows 10/11 (tested on Windows)
- Python 3.10 or higher installed
- Webcam connected and working
- Good lighting for accurate pose detection
- 6-8 feet of space from your camera
First, verify that Python is installed on your system:
py --versionIf you see a version number (e.g., "Python 3.10.0"), you're good to go. If not, download and install Python from python.org.
- Download or clone this project to your computer
- Open Command Prompt or PowerShell
- Navigate to the project folder:
cd path\to\your\project\folder
Install the required packages using these commands:
# Install core dependencies
py -m pip install opencv-python==4.8.1.78 mediapipe numpy==1.26.4
# Optional: Install face recognition (recommended)
py -m pip install onnxruntime insightfaceNote: The specific versions ensure compatibility. If you encounter any errors, try installing without version numbers:
py -m pip install opencv-python mediapipe numpyRun a quick test to ensure everything is working:
py -c "import cv2, mediapipe, numpy; print('All packages installed successfully!')"If you see "All packages installed successfully!", you're ready to go!
-
Start the application:
py cool.py
-
Position yourself:
- Stand about 6-8 feet from your camera
- Make sure your full upper body is visible
- Ensure good lighting (avoid backlighting)
- Wear clothing that doesn't obscure your arms
-
Start your workout:
- The app will automatically detect your pose
- Begin doing push-ups
- Watch the real-time feedback on screen
-
End your session:
- Press 'q' to quit
- Review your session summary
- Your stats are automatically saved
- Elbow Angle Display: Shows your current elbow angle in degrees
- Push-up Counter: Displays your total reps
- Progress Bars: Visual indicators on the sides showing your position
- Pose Overlay: Skeleton lines showing detected body parts
- User Recognition: Shows recognized user name (if face recognition is set up)
- 'q' - Quit the application and show summary
- Any other key - Continue the session
To enable automatic user recognition:
-
Create the faces folder structure:
faces/ โโโ YourName/ โ โโโ photo1.jpg โ โโโ photo2.jpg โ โโโ photo3.jpg โโโ AnotherUser/ โโโ photo1.jpg โโโ photo2.jpg -
Add photos:
- Create a folder with your name inside the
faces/directory - Add 2-3 clear photos of your face (different angles work best)
- Supported formats: JPG, JPEG, PNG, BMP
- Create a folder with your name inside the
-
Test recognition:
- Run the application
- Look at the camera for the first few seconds
- Your name should appear in the top-right corner
- Down position: Elbow angle < 90ยฐ
- Up position: Elbow angle > 160ยฐ
- One rep: Complete cycle from up โ down โ up
The app automatically saves your workout data to workout_log.csv:
| Column | Description |
|---|---|
| datetime | Date and time of the session |
| name | Recognized user name or "Unknown" |
| reps | Total push-ups completed |
| duration_sec | Session duration in seconds |
| pace_rpm | Reps per minute (pace) |
datetime,name,reps,duration_sec,pace_rpm
2024-01-15 14:30:25,John,15,120.5,7.47
2024-01-15 16:45:12,John,20,180.2,6.66
Camera not working:
- Make sure your webcam is connected and not being used by another application
- Try closing other video applications (Zoom, Teams, etc.)
- Check Windows camera permissions
Poor pose detection:
- Improve lighting (avoid shadows and backlighting)
- Ensure your full upper body is visible
- Wear clothing that doesn't obscure your arms
- Stand 6-8 feet from the camera
Package installation errors:
# If you get NumPy conflicts:
py -m pip uninstall numpy
py -m pip install numpy==1.26.4
# If OpenCV fails:
py -m pip install opencv-contrib-pythonFace recognition not working:
- Ensure InsightFace is installed:
py -m pip install insightface - Check that your photos are clear and well-lit
- Make sure the folder structure is correct
- Try adding more photos of different angles
Application crashes:
- Update your graphics drivers
- Try running with a different camera
- Check Windows compatibility mode
- Close unnecessary applications to free up system resources
- Use good lighting for better detection accuracy
- Position yourself correctly - full upper body visible
- Wear contrasting clothing to your background
push-up-tracker/
โโโ cool.py # Main application
โโโ README.md # This file
โโโ requirements.txt # Dependencies list
โโโ workout_log.csv # Session history (auto-generated)
โโโ faces/ # Face recognition photos
โโโ YourName/
โโโ photo1.jpg
โโโ photo2.jpg
โโโ photo3.jpg
- OpenCV 4.8.1.78 - Computer vision and camera handling
- MediaPipe 0.10.14 - Real-time pose estimation
- NumPy 1.26.4 - Numerical computations
- InsightFace 0.7.3 - Face recognition (optional)
- ONNX Runtime - Machine learning inference
- Pose Detection: MediaPipe analyzes each frame to detect 33 body landmarks
- Angle Calculation: Computes elbow angle from shoulder, elbow, and wrist positions
- Rep Counting: State machine tracks up/down positions to count complete reps
- Face Recognition: InsightFace creates embeddings from photos and matches them in real-time
- Data Logging: Session statistics are saved to CSV for tracking progress
- CPU: Any modern multi-core processor
- RAM: 4GB minimum, 8GB recommended
- Storage: 100MB free space
- Camera: Any USB webcam or built-in camera
- OS: Windows 10/11 (tested), should work on macOS/Linux
Feel free to improve this project by:
- Adding support for other exercises
- Improving the UI/UX
- Adding more detailed analytics
- Supporting different camera setups
This project is open source. Feel free to use and modify for personal or educational purposes.
If you encounter issues:
- Check the troubleshooting section above
- Ensure all prerequisites are met
- Try reinstalling dependencies
- Check that your camera and lighting are adequate
Happy working out! ๐ช