Skip to content

πŸ‹οΈ AI Fitness Monitor - Real-time pose detection for exercise analysis. Android app streams camera to Flask server using MediaPipe for instant squat counting & jump height measurement with skeleton overlay feedback. Built with Python, Kotlin, CameraX & OpenCV.

Notifications You must be signed in to change notification settings

NYN-05/Sports_android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Fitness Monitor

Python Flask MediaPipe Android License

Real-time AI-powered fitness monitoring system using pose estimation

Features β€’ Installation β€’ Usage β€’ API β€’ Architecture β€’ Contributing


🎯 Overview

AI Fitness Monitor is a comprehensive fitness tracking system that uses computer vision and machine learning to analyze exercise form in real-time. The system consists of a Python server with pose detection capabilities and an Android mobile application for user interaction.

Key Features

  • Real-time Squat Analysis: Tracks squat depth, knee angles, and form with instant feedback
  • Vertical Jump Measurement: Measures jump height using pose estimation
  • Voice Feedback: Audio cues to guide proper exercise form
  • Mobile Integration: Android app for convenient mobile workout tracking
  • WebSocket Streaming: Low-latency video processing for smooth experience

πŸ“ Project Structure

SIH_SPORTS_proj/
β”œβ”€β”€ server/                     # Python backend server
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ analyzers/         # Exercise analysis modules
β”‚   β”‚   β”‚   β”œβ”€β”€ squat_analyzer.py
β”‚   β”‚   β”‚   └── jump_analyzer.py
β”‚   β”‚   β”œβ”€β”€ api/               # Flask API routes
β”‚   β”‚   β”‚   └── routes.py
β”‚   β”‚   └── utils/             # Utility modules
β”‚   β”‚       β”œβ”€β”€ camera_manager.py
β”‚   β”‚       └── frame_processor.py
β”‚   β”œβ”€β”€ config/                # Configuration files
β”‚   β”‚   └── settings.py
β”‚   β”œβ”€β”€ templates/             # HTML templates
β”‚   β”œβ”€β”€ tests/                 # Unit & integration tests
β”‚   β”œβ”€β”€ requirements.txt       # Python dependencies
β”‚   └── run.py                 # Main entry point
β”‚
β”œβ”€β”€ android_app/               # Android mobile application
β”‚   β”œβ”€β”€ app/src/main/
β”‚   β”‚   β”œβ”€β”€ java/             # Kotlin source code
β”‚   β”‚   └── res/              # Android resources
β”‚   β”œβ”€β”€ build.gradle.kts      # Gradle build config
β”‚   └── USER_MANUAL.md        # User documentation
β”‚
β”œβ”€β”€ builds/                    # Pre-built APK files
β”‚   └── FitnessMonitor.apk
β”‚
β”œβ”€β”€ docs/                      # Additional documentation
β”‚   β”œβ”€β”€ API.md                # API reference
β”‚   └── ARCHITECTURE.md       # System architecture
β”‚
└── README.md                  # This file

πŸš€ Installation

Prerequisites

  • Python 3.8+ with pip
  • Android Studio (for Android development)
  • Webcam (for local testing)

Server Setup

  1. Clone the repository

    git clone https://github.com/your-repo/ai-fitness-monitor.git
    cd ai-fitness-monitor
  2. Create virtual environment

    python -m venv venv
    
    # Windows
    venv\Scripts\activate
    
    # Linux/macOS
    source venv/bin/activate
  3. Install dependencies

    cd server
    pip install -r requirements.txt
  4. Run the server

    python run.py

    The server will start at http://0.0.0.0:5000

Android App Setup

  1. Install pre-built APK

    • Transfer builds/FitnessMonitor.apk to your Android device
    • Enable "Install from unknown sources"
    • Install the APK
  2. Or build from source

    cd android_app
    ./gradlew assembleDebug

πŸ“± Usage

Quick Start

  1. Start the server on your computer
  2. Connect your phone to the same WiFi network
  3. Open the app and enter the server IP address
  4. Select exercise type (Squat or Jump)
  5. Position yourself in the camera frame
  6. Start exercising and get real-time feedback!

Server Modes

  • Webcam Mode: Uses your computer's webcam
  • Mobile Mode: Processes frames from the Android app

Exercise Guidelines

Squats

  • Stand 6-8 feet from camera
  • Ensure full body is visible
  • Listen for voice feedback on depth

Vertical Jumps

  • Stand still for calibration
  • Jump straight up
  • Wait for height measurement

πŸ”Œ API Reference

Endpoints

Method Endpoint Description
GET / Web interface
GET /squat_feed MJPEG squat analysis stream
GET /jump_feed MJPEG jump analysis stream
POST /process_frame Process mobile camera frame
POST /reset_analyzer Reset analyzer state

POST /process_frame

Request:

{
  "image": "base64_encoded_jpeg",
  "type": "squat" | "jump"
}

Response:

{
  "image": "base64_encoded_result",
  "count": 5,
  "stage": "UP",
  "feedback": "Good form!"
}

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Android   │────▢│   Flask     │────▢│  MediaPipe  β”‚
β”‚     App     │◀────│   Server    │◀────│    Pose     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚                    β”‚                    β”‚
      β”‚   HTTP/WebSocket   β”‚    Pose Detection  β”‚
      β”‚                    β”‚                    β”‚
      β–Ό                    β–Ό                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Camera    β”‚     β”‚   OpenCV    β”‚     β”‚   Numpy     β”‚
β”‚   Frame     β”‚     β”‚  Processing β”‚     β”‚   Arrays    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

  • MediaPipe Pose: Google's ML model for body pose estimation
  • OpenCV: Image processing and video capture
  • Flask: Lightweight web framework for API
  • pyttsx3: Offline text-to-speech for voice feedback

πŸ§ͺ Testing

cd server

# Run all tests
pytest

# Run with coverage
pytest --cov=src tests/

# Run specific test file
pytest tests/test_analyzers.py -v

🀝 Contributing

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

πŸ“„ License

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


πŸ™ Acknowledgments


Made with ❀️ for SIH 2025

About

πŸ‹οΈ AI Fitness Monitor - Real-time pose detection for exercise analysis. Android app streams camera to Flask server using MediaPipe for instant squat counting & jump height measurement with skeleton overlay feedback. Built with Python, Kotlin, CameraX & OpenCV.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published