Skip to content

About

Hack The North 2025. We kept PIVOTING.

Resources

Stars

1 star

Watchers

0 watching

Forks

Β 
Β 

Repository files navigation

PostureGuard AI

Real-time posture monitoring and analysis using AI-powered pose detection

PostureGuard AI is an intelligent posture detection application that helps you maintain healthy sitting habits by providing real-time feedback on your posture using advanced computer vision and machine learning techniques.

🌟 Features

  • Real-Time Pose Detection: Live posture analysis using MediaPipe Tasks Vision
  • Comprehensive Metrics: Track neck angle, trunk flexion, elbow position, knee angle, and more
  • Smart Smoothing: Advanced filtering algorithms reduce noise for stable readings
  • Visual Feedback: Live skeleton overlay and color-coded status indicators
  • Privacy-First: All processing happens locally in your browser - no data leaves your device
  • Multi-Camera Support: Choose from available cameras with automatic device detection
  • Responsive Design: Works on desktop and mobile devices
  • Dark/Light Theme: Toggle between themes for comfortable usage

πŸ—οΈ Project Structure

PostureGuard-AI/
β”œβ”€β”€ app/                      # Next.js 14 App Router
β”‚   β”œβ”€β”€ layout.tsx           # Root layout with theme provider
β”‚   └── page.tsx             # Main application page
β”œβ”€β”€ components/              # React components
β”‚   β”œβ”€β”€ ui/                  # shadcn/ui components
β”‚   β”‚   β”œβ”€β”€ badge.tsx
β”‚   β”‚   β”œβ”€β”€ button.tsx
β”‚   β”‚   β”œβ”€β”€ card.tsx
β”‚   β”‚   β”œβ”€β”€ dialog.tsx
β”‚   β”‚   β”œβ”€β”€ select.tsx
β”‚   β”‚   └── separator.tsx
β”‚   β”œβ”€β”€ PoseDetection.tsx    # Core pose detection component
β”‚   β”œβ”€β”€ PostureAnalyzer.tsx  # Posture analysis and metrics display
β”‚   β”œβ”€β”€ mode-toggle.tsx      # Dark/light theme toggle
β”‚   └── theme-provider.tsx   # Theme context provider
β”œβ”€β”€ lib/                     # Utility libraries
β”‚   β”œβ”€β”€ poseUtils.ts         # Pose analysis algorithms and utilities
β”‚   └── utils.ts             # General utilities (cn function)
β”œβ”€β”€ styles/                  # Global styles
β”‚   └── globals.css          # Tailwind CSS and custom styles
β”œβ”€β”€ workers/                 # Web Workers (if needed)
β”‚   └── poseWorker.ts        # Pose processing worker
β”œβ”€β”€ public/                  # Static assets
β”‚   └── favicon.ico
└── config files             # Configuration files
    β”œβ”€β”€ next.config.js       # Next.js configuration
    β”œβ”€β”€ tailwind.config.js   # Tailwind CSS configuration
    β”œβ”€β”€ tsconfig.json        # TypeScript configuration
    β”œβ”€β”€ postcss.config.js    # PostCSS configuration
    └── components.json      # shadcn/ui configuration

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ (LTS recommended)
  • npm or yarn package manager
  • A modern web browser with camera support
  • HTTPS connection (required for camera access)

Installation

  1. Clone the repository

    git clone https://github.com/your-username/PostureGuard-AI.git
    cd PostureGuard-AI
  2. Install dependencies

    npm install
    # or
    yarn install
  3. Run the development server

    npm run dev
    # or
    yarn dev
  4. Open your browser Navigate to http://localhost:3000

Production Build

# Build the application
npm run build

# Start the production server
npm start

🎯 How It Works

Core Technologies

  1. MediaPipe Tasks Vision: Google's advanced pose detection model

    • Uses the heavy pose landmarker model for accuracy
    • Detects 33 3D landmarks on the human body
    • Runs entirely in the browser using WebAssembly
  2. Real-Time Analysis Engine

    • Calculates key posture angles (neck, trunk, limbs)
    • Applies smoothing filters to reduce noise
    • Provides instant feedback on posture quality
  3. Advanced Metrics

    • Craniovertebral Angle (CVA): Head position relative to shoulders
    • Trunk Flexion: Spine alignment with vertical axis
    • Pelvic Tilt: Hip alignment and stability
    • Elbow Angle: Upper limb positioning
    • Knee Angle: Lower limb positioning
    • Confidence Score: Tracking quality assessment

Usage Instructions

  1. Camera Setup

    • Allow camera access when prompted
    • Select your preferred camera from the dropdown
    • Position yourself so your upper body is visible
  2. Start Detection

    • Click "Start Camera" to begin video feed
    • Click "Start Detection" to begin pose analysis
    • Ensure good lighting for optimal results
  3. Monitor Your Posture

    • Watch the real-time metrics update
    • Follow the color-coded status indicators:
      • 🟒 Green: Good posture
      • 🟑 Yellow: Needs improvement
      • πŸ”΄ Red: Poor posture
    • Read the tips and recommendations provided

🧠 Technical Details

Pose Analysis Pipeline

// Core analysis flow
Camera Feed β†’ MediaPipe Model β†’ Pose Landmarks β†’
Angle Calculations β†’ Smoothing Filters β†’
Classification β†’ User Feedback

Key Algorithms

  • Angle Calculation: Vector-based angle computation between body landmarks
  • Smoothing: Moving average and One-Euro filters for stable readings
  • Classification: Rule-based posture assessment with configurable thresholds
  • Ergonomic Scoring: Weighted composite score across multiple metrics

Performance Optimizations

  • Efficient landmark processing at 30 FPS
  • Selective rendering to minimize GPU usage
  • Smart throttling for UI updates
  • Memory-efficient filter implementations

πŸ› οΈ Development

Tech Stack

  • Framework: Next.js 14 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: shadcn/ui (Radix UI primitives)
  • AI/ML: MediaPipe Tasks Vision
  • Build Tool: Next.js built-in bundler

Scripts

npm run dev      # Start development server
npm run build    # Build for production
npm run start    # Start production server
npm run lint     # Run ESLint

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ”’ Privacy & Security

  • Local Processing: All pose detection runs in your browser
  • No Data Collection: Camera data never leaves your device
  • No Server Required: Fully client-side application
  • HTTPS Enforced: Secure camera access protocols
  • Open Source: Transparent and auditable codebase

πŸ“Š Supported Metrics

Metric Description Optimal Range Status
Neck Angle Head alignment with vertical 0-15Β° βœ… Active
Trunk Flexion Spine curvature from vertical 0-15Β° βœ… Active
Elbow Angle Upper arm to forearm angle 90-110Β° βœ… Active
Knee Angle Thigh to shin angle 80-110Β° βœ… Active
Pelvic Tilt Hip alignment deviation Β±10Β° βœ… Active
Confidence Landmark detection quality >80% βœ… Active

🌐 Browser Compatibility

  • Chrome 88+ (Recommended)
  • Firefox 85+
  • Safari 14+
  • Edge 88+

Note: Camera access requires HTTPS in production environments.

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Acknowledgments

  • MediaPipe Team for the excellent pose detection models
  • Google for MediaPipe Tasks Vision
  • Vercel for Next.js framework
  • shadcn for the beautiful UI components
  • Radix UI for accessible primitives

πŸ“ž Support

For questions, issues, or feature requests:

  • Open an issue on GitHub
  • Check existing documentation
  • Review the code examples in the repository

Built with ❀️ for HTN 2025 β€’ Live Demo β€’ GitHub

About

Hack The North 2025. We kept PIVOTING.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages