A web application for real-time yoga pose detection and feedback using MediaPipe and WebSocket communication.
- Python backend with MediaPipe pose detection
- Real-time pose landmark detection and visualization
- Pose comparison and alignment feedback
- Calibration and session management
- Modern Next.js frontend with real-time feedback
-
Install Python dependencies:
cd backend pip install -r requirements.txt -
Test MediaPipe installation:
python test_mediapipe.py
This will open your webcam and verify MediaPipe is working correctly.
-
Start the WebSocket server:
python app.py
This will start the server at
ws://127.0.0.1:5000.
-
Install Node.js dependencies:
cd frontend npm install -
Start the development server:
npm run dev
This will start the frontend at
http://localhost:3000.
- Open
http://localhost:3000in your browser - Navigate to the Workouts page
- Allow webcam access when prompted
- Calibrate each pose by clicking "Calibrate Pose"
- Start a session by clicking "Start Session"
- Follow the alignment feedback to improve your pose
- If the webcam doesn't appear, check browser permissions
- If landmarks aren't detected, ensure you're visible in the camera frame
- For backend issues, check the terminal for error messages
- For MediaPipe installation issues, run
python test_mediapipe.py
-
/backend- Python backend with MediaPipe and WebSocket serverapp.py- Main WebSocket server with pose detectiontest_mediapipe.py- Test script for MediaPipe functionalitycalibration/- Reference pose images
-
/frontend- Next.js frontend applicationapp/workouts/page.tsx- Main page for yoga pose detectionsrc/hooks/useWebSocket.ts- WebSocket connection handlingpublic/poses/- Reference pose images
- The backend captures video from your webcam and processes it with MediaPipe
- Real-time pose landmarks are extracted and sent via WebSocket
- The frontend displays your webcam feed and overlays the landmarks
- During calibration, your pose is saved as a reference
- During a session, your current pose is compared to the calibrated references
- Real-time feedback helps you adjust your alignment
For more detail on the workings of the application, check out these key files:
backend/app.py- Main server implementation with MediaPipe integrationfrontend/app/workouts/page.tsx- Main frontend interface for pose detectionfrontend/src/hooks/useWebSocket.ts- WebSocket communication