https://github.com/vasa-develop/dumbbell-form-analyzer
https://github.com/vasa-develop/dumbbell-form-analyzer
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vasa-develop/dumbbell-form-analyzer
- Owner: vasa-develop
- Created: 2025-05-31T22:57:24.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-06-01T01:03:36.000Z (10 months ago)
- Last Synced: 2025-06-01T10:11:12.384Z (10 months ago)
- Language: TypeScript
- Size: 58.9 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dumbbell Curl Form Analyzer - Local Benchmark Version
A real-time dumbbell curl form analyzer using MediaPipe pose detection. This is the benchmark version that runs entirely locally on your machine.
## Features
- **Real-time pose detection** using Google's MediaPipe AI
- **Automatic rep counting** with accurate curl phase detection
- **Form analysis** including elbow angles, shoulder stability, and range of motion
- **Voice feedback** with technique tips and encouragement
- **Live stats display** showing reps, angles, and current phase
## Requirements
- Python 3.12+ with Poetry
- Node.js 18+ with npm
- Webcam or video file for testing
- Modern web browser (Chrome, Firefox, Safari)
## Quick Start
### Option 1: Automated Setup (Recommended)
```bash
./run_local.sh
```
This script will install dependencies and start the backend. Then open a new terminal and run:
```bash
cd frontend && npm run dev
```
### Option 2: Manual Setup
**1. Install Dependencies:**
```bash
# Backend
cd backend && poetry install && cd ..
# Frontend
cd frontend && npm install && cd ..
```
**2. Start Backend (Terminal 1):**
```bash
cd backend
poetry run fastapi dev app/main.py
```
**3. Start Frontend (Terminal 2):**
```bash
cd frontend
npm run dev
```
**4. Open Application:**
- Navigate to http://localhost:5173 in your browser
- Click "Start Analysis" and grant camera permission
- Position yourself so your full upper body is visible
- Start doing dumbbell curls!
## Benchmark Performance
This version uses MediaPipe's full pose detection model with verified accuracy:
### ✅ Verified Test Results (with provided video)
- **Pose Detection Rate**: 100% (249/249 frames detected)
- **Rep Detection**: 1 complete curl accurately detected
- **Angle Range**: 9.4° (peak flexion) to 165.1° (full extension)
- **Phase Transitions**:
- Down→Up at 88° (frame 40, t=0.7s)
- Up→Down at 140° (frame 218, t=3.6s)
- **Feedback Accuracy**: Real-time form analysis with appropriate tips
### Technical Specifications
- **Pose Model**: MediaPipe with 33 body landmarks
- **Processing**: Real-time WebSocket communication
- **Angle Calculation**: 3-point joint angle measurement
- **Rep Logic**: Phase-based counting with angle thresholds
- **Feedback System**: Context-aware voice guidance
## Testing with Your Video
The project includes a test script to verify detection accuracy:
```bash
cd backend
poetry run python ../test_with_video.py
```
This will analyze the included test video and show detailed frame-by-frame results.
## Architecture
- **Backend**: FastAPI + MediaPipe + WebSocket real-time processing
- **Frontend**: React + Vite + WebRTC camera access + Web Speech API
- **Communication**: WebSocket for low-latency frame analysis
- **Detection**: MediaPipe Pose with custom curl form analysis
## Troubleshooting
### Camera Issues
- Ensure browser has camera permissions
- Try refreshing if camera doesn't start
- Check no other apps are using the camera
- Use Chrome/Firefox for best WebRTC support
### Performance Issues
- Ensure good lighting for pose detection
- Position camera at chest level
- Keep full upper body in frame
- Close resource-intensive applications
### Connection Issues
- Verify backend running on port 8000
- Verify frontend running on port 5173
- Check WebSocket connection status in browser console
- Restart both servers if connection fails
## Benchmark vs Future Implementations
This MediaPipe version serves as the accuracy benchmark for comparison with:
1. **TensorFlow.js Lite + PoseNet** (mobile-optimized)
2. **React Native implementation** (native mobile)
3. **Lighter pose detection models** (faster processing)
**Key Metrics to Maintain:**
- Rep detection accuracy (currently 100%)
- Angle measurement precision (±2°)
- Real-time performance (<100ms latency)
- Form feedback quality
## File Structure
```
dumbbell-form-analyzer/
├── backend/ # FastAPI + MediaPipe backend
│ ├── app/main.py # Main server with pose detection
│ ├── pyproject.toml # Python dependencies
│ └── poetry.lock # Locked dependency versions
├── frontend/ # React + Vite frontend
│ ├── src/App.tsx # Main application component
│ ├── package.json # Node.js dependencies
│ └── .env # Backend URL configuration
├── test_with_video.py # Video analysis test script
├── test_video.mp4 # Sample curl video for testing
├── run_local.sh # Automated setup script
└── README.md # This file
```
## Next Steps
This benchmark establishes the performance baseline. Future development will:
1. **Implement TensorFlow.js version** for mobile compatibility
2. **Compare detection accuracy** against this MediaPipe benchmark
3. **Optimize for mobile deployment** while maintaining accuracy
4. **Build React Native app** for native mobile experience
The goal is to achieve similar accuracy (>95% rep detection) with improved mobile performance and easier deployment.