@lid-vizion/pose-analysis
v0.1.2
Published
Pose analysis library with MediaPipe, Gemini-powered custom exercises, and MongoDB persistence
Readme
Pose Analysis Library
This library provides real-time human pose analysis using MediaPipe. It includes React components for video and live camera analysis, along with standalone logic for counting repetitions and providing feedback for specific exercises.
📂 Project Structure
libraries/pose-analysis/
├── src/
│ ├── analyzers/ # Core exercise logic (pure TypeScript)
│ │ ├── squat.ts # Squat form analysis
│ │ ├── kettlebell.ts # Single Hand Snatch analysis
│ │ ├── long_cycle.ts # Long Cycle (Double Kettlebell) analysis
│ │ └── types.ts # Shared interfaces
│ ├── components/ # React UI components
│ │ ├── AnalysisPage.tsx # Video/Image upload & analysis
│ │ ├── ExercisePage.tsx # Live webcam exercise tracking
│ │ └── BottomNav.tsx # Navigation component
│ ├── hooks/ # Custom React hooks
│ │ └── usePoseDetection.ts # MediaPipe integration hook
│ ├── lib/ # Utilities
│ │ └── utils.ts # Helper functions (cn, etc.)
│ └── index.ts # Public API exports
├── dev-app/ # Standalone Vite development app
├── start-dev.sh # Script to build & run dev-app
├── package.json # Library dependencies
└── tsconfig.json # TypeScript configuration🏋️ implemented Exercises
1. Squat Form (squat.ts)
- Logic: Calculates the angle between Hip, Knee, and Ankle.
- States:
UP->DOWN->UP. - Feedback: Checks depth (< 90 degrees) and full extension.
2. Single Hand Kettlebell Snatch (kettlebell.ts)
- Logic: Tracks wrist position relative to shoulder (top) and hip (bottom).
- States: Independent
UP/DOWNstates for Left and Right arms. - Feedback: "Left Up!", "Right Rep Complete!", etc.
3. Long Cycle (Double Kettlebell) (long_cycle.ts)
- Logic: Tracks BOTH hands simultaneously.
- Requirement: Both wrists must move from below hips to above shoulders and back down together.
- Feedback: "Lift both hands!", "Rep Complete!".
🚀 Standalone Development
You can run this library in isolation without the main app.
- Navigate to directory:
cd libraries/pose-analysis - Run the dev script:
This will:./start-dev.sh # Or on Windows Git Bash: bash start-dev.sh- Install dependencies for the
dev-app. - Build the library.
- Start a local Vite server at
http://localhost:5173.
- Install dependencies for the
🔌 Integration Guide
Frontend (React App)
To use these components in the main baas application:
- Add Dependency:
Add to root
package.json:"@lid-vizion/pose-analysis": "workspace:*" - Install:
npm install - Import & Route:
In
src/App.tsx:import { AnalysisPage, ExercisePage } from "@lid-vizion/pose-analysis"; // In Routes: <Route path="/analysis" element={<AnalysisPage />} /> <Route path="/exercise" element={<ExercisePage />} />
Backend (AWS Lambda)
To run analysis logic on the server (e.g., for processing uploaded videos):
Handler: A handler file has been created at
lambda/src/handlers/pose-analysis.ts.- It imports the analyzers (
SquatAnalyzer, etc.) directly. - Uncomment the code in this file to enable it.
- It imports the analyzers (
Infrastructure (SAM): A resource definition has been added to
lambda/workspace-template.yml.- Uncomment the
PoseAnalysisFunctionsection to provision the Lambda.
- Uncomment the
Dependencies: Add
@lid-vizion/pose-analysistolambda/package.jsonif you want to share the exact same logic code between frontend and backend.
🛠 Dependencies
- @mediapipe/pose: AI model for body tracking.
- react-webcam: For handling camera input.
- lucide-react: UI icons.
- tailwindcss: Styling (via
clsxandtailwind-merge).
