A computer vision system for real-time exercise classification and repetition counting using MediaPipe pose detection and deep learning models.
SmartMirror/
├── 📁 src/ Source code
│ ├── 📁 backend_interface/
│ │ ├── backend_interface.py Backend interface to communicate with the mirror
│ │ ├── server.py HTTP server to receive data batches from the mirror
│ │ └── shared_data.py Thread-Safe IPC
│ ├── 📁 core/ Core functionality
│ │ ├── realtime_pipeline.py Main realtime pipeline
│ │ ├── dataset_builder.py Dataset creation and management
│ │ ├── realtime.py Realtime model & OpenCV rendering
│ │ ├── realtime_no_counting.py
│ │ ├── main.py Main script
│ │ └── __init__.py
│ ├── 📁 training/ Model training
│ │ ├── train_classifier.py Classification model training
│ │ ├── retrain_segmentation_realtime.py Real-time segmentation training
│ │ ├── classification/ Classification modules
│ │ └── segmentation/ Segmentation modules
│ ├── 📁 testing/ Testing and debugging
│ │ ├── test_*.py Various test scripts
│ │ ├── debug_classification.py
│ │ └── inspect_classification_dataset.py
│ ├── 📁 utils/ Utility scripts
│ │ ├── classification_demo.py
│ │ ├── segmentation_demo.py
│ │ ├── mediapipe_demo.py
│ │ └── video_labeler.py
│ └── __init__.py
├── 📁 data/ Data storage
│ ├── 📁 raw/ Raw video files
│ ├── 📁 processed/ Processed datasets
│ └── 📁 labels/ Annotation files
├── 📁 models/ Trained models
│ ├── 📁 classification/ Classification models
│ └── 📁 segmentation/ Segmentation models
├── 📁 logs/ Training logs
├── 📁 output_videos/ Output videos
├── 📁 test_videos/ Test videos
├── 📁 docs/ Documentation
├── 📁 scripts/ Utility scripts
├── 🐍 run_realtime.py Main entry point
├── 📄 requirements.txt Dependencies
└── 📄 README.md This file
-
Clone the repository:
git clone <repository-url> cd SmartMirror
-
Install dependencies:
pip install -r requirements.txt
-
Run the real-time pipeline:
python run_realtime.py
- Press 'q' to quit the application
- Press 'r' to reset rep counts
- The system will automatically detect and classify exercises
- Rep counts are displayed in real-time
- 4 Exercise Types: Push-ups, Squats, Pull-ups, Dips
- Real-time Detection: Live webcam feed processing
- High Accuracy: 99.98% test accuracy
- Low Latency: Optimized for real-time performance
- State Machine: Advanced rep detection algorithm
- Low-FPS Optimized: Works with 3 FPS performance
- Multiple Exercises: Simultaneous tracking
- Visual Feedback: Real-time state display
- 30-Frame Windows: Optimized for real-time processing
- Frame Skipping: Reduces computational load
- Adaptive Thresholds: Adjusts to performance constraints
- Efficient Models: Lightweight neural networks
Classification Model:
cd src/training
python train_classifier.pyReal-time Segmentation Models:
cd src/training
python retrain_segmentation_realtime.pyTest with video files:
cd src/testing
python test_realtime_video.py test_videos/test0.mp4Debug classification:
cd src/testing
python debug_classification.py test_videos/test0.mp4- Classification Accuracy: 99.98%
- Real-time FPS: ~3 FPS (CPU-based)
- Latency: ~350ms per frame
- Memory Usage: ~2GB RAM
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- MediaPipe: Pose detection framework
- TensorFlow: Deep learning framework
- OpenCV: Computer vision library