Skip to content

Ananya020/StepSure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

StepSure

AI-Powered Real-Time Gait Rehabilitation Assistant

StepSure is a cross-platform Flutter application that transforms a smartphone camera into an intelligent physiotherapy assistant.

It performs real-time gait analysis using pose estimation, calculates biomechanical recovery metrics, evaluates fall risk, and generates AI-powered rehabilitation reports with exportable medical PDFs.


๐Ÿš€ Overview

StepSure is designed for stroke survivors and individuals undergoing lower-limb rehabilitation who need:

  • Objective gait monitoring at home
  • Continuous recovery tracking
  • Real-time corrective feedback
  • Structured rehabilitation reports

The system combines:

  • Computer Vision (Pose Estimation)
  • Biomechanical Analysis
  • AI-generated Medical Reports
  • Cloud-based Session Storage (Supabase)

๐Ÿง  Core Capabilities

โœ… Real-Time Gait Analysis

  • Live camera pose detection
  • Skeleton overlay aligned to body orientation
  • Joint angle computation (hip, knee, ankle)
  • Step detection using hysteresis-based state machine
  • Cadence, symmetry, and stability metrics

๐Ÿ“น Video Upload Analysis

  • Frame extraction at 5 FPS
  • Per-frame pose detection
  • Session-level biomechanical aggregation
  • Fall risk classification

๐Ÿ“Š Recovery Metrics

  • Recovery Score (0โ€“100)
  • Gait Symmetry Index
  • Stride Consistency
  • Stability Indicator
  • Fall Risk Classification (Low / Moderate / High)

๐Ÿ“ˆ Progress Tracking

  • Historical session storage
  • Improvement trend visualization
  • Longitudinal recovery monitoring

๐Ÿงพ AI Rehab Report Generator

  • Natural language session summary
  • Abnormality identification
  • Exercise suggestions
  • Risk explanation
  • Exportable medical-grade PDF report

โ˜ Supabase Backend

  • Authentication
  • PostgreSQL session storage
  • Secure video upload
  • Cloud sync

๐Ÿ— System Architecture

User โ†’ Flutter App โ†’ Camera / Video Input โ†’ Pose Detection (ML Kit) โ†’ GaitAnalysisService โ†’ Session Metrics Computation โ†’ Supabase Storage โ†’ AI Report Generator โ†’ Results Dashboard + PDF Export


๐Ÿ›  Technical Implementation Details

1๏ธโƒฃ Step Detection (gait_analysis_service.dart)

Replaced naive angle threshold logic with a per-leg rising-edge state machine using 20ยฐ hysteresis:

  • Arm condition: <140ยฐ
  • Fire condition: >160ยฐ

This prevents false triggering and ensures medically realistic cadence instead of inflated 10โ€“30ร— step counts.


2๏ธโƒฃ Camera Input Handling (recording_screen.dart)

Platform-specific image processing:

  • Android โ†’ Concatenates YUV planes (NV21 format)
  • iOS โ†’ Uses BGRA8888 single-plane format
  • Dynamically reads sensor orientation from: _cameraController.description.sensorOrientation
  • No hardcoded rotation assumptions

3๏ธโƒฃ Skeleton Coordinate Transformation (skeleton_painter.dart)

  • Accepts InputImageRotation

  • Applies correct axis swap for:

    • 0ยฐ
    • 90ยฐ
    • 180ยฐ
    • 270ยฐ
  • Ensures accurate body alignment

  • Fixes quadrant misalignment issues


4๏ธโƒฃ Video Analysis Pipeline (video_analysis_service.dart)

  • Extracts frames at 5 FPS

  • Uses VideoPlayerController

  • Captures frames via RenderRepaintBoundary.toImage()

  • Uses PoseDetectionMode.single (correct for non-sequential frames)

  • Feeds frames to GaitAnalysisService.processFrame()

  • Aggregates metrics using computeSessionMetrics()

  • Throws descriptive errors if:

    • Video too short
    • <5 pose detections

5๏ธโƒฃ Upload Screen Processing (upload_screen.dart)

  • Off-screen hidden VideoPlayer

  • RepaintBoundary positioned at left: -4000 to preserve key integrity

  • Full ML pipeline execution:

    • Frame extraction
    • Pose detection
    • Gait analysis
    • Session save to Supabase
    • PDF generation
    • Navigation to ResultsScreen
  • Live progress percentage display

  • Retry mechanism on failure


6๏ธโƒฃ PDF Report Generator (pdf_generator.dart)

Generates a structured A4 medical report:

Includes:

  • Header bar
  • Score & Risk banner
  • 6-row metrics table (color-coded Normal/Good/Poor)
  • AI-generated summary
  • Abnormalities list
  • Exercise suggestions
  • Risk explanation
  • Medical disclaimer footer

Functions:

  • generateSessionReport(session, report) โ†’ Uint8List
  • sharePdf() โ†’ opens system share sheet

7๏ธโƒฃ Results Screen (results_screen.dart)

  • Displays computed metrics
  • Risk classification badge
  • โ€œExport PDF Reportโ€ button
  • Loading state during PDF generation

๐Ÿ“‚ Folder Structure

lib/
 โ”œโ”€โ”€ core/
 โ”œโ”€โ”€ data/
 โ”œโ”€โ”€ domain/
 โ”œโ”€โ”€ features/
 โ”‚    โ”œโ”€โ”€ recording/
 โ”‚    โ”œโ”€โ”€ upload/
 โ”‚    โ”œโ”€โ”€ results/
 โ”‚    โ”œโ”€โ”€ analysis/
 โ”œโ”€โ”€ services/
 โ”œโ”€โ”€ presentation/
 โ”œโ”€โ”€ widgets/
assets/
test/

๐Ÿ“ฑ Supported Platforms

  • Android
  • iOS
  • Web (limited camera support)
  • Windows
  • macOS
  • Linux

๐Ÿ” Security & Data Handling

  • Supabase Authentication
  • Secure PostgreSQL storage
  • Controlled access to uploaded videos
  • No third-party sharing
  • Designed for future HIPAA-compliant expansion

โš  Limitations

  • Prototype stage (no clinical validation yet)
  • Camera positioning affects accuracy
  • Lighting conditions impact pose detection
  • Not a replacement for licensed physiotherapy

๐Ÿ”ฎ Future Roadmap

  • Clinician dashboard
  • Remote monitoring portal
  • Multi-language support
  • Wearable sensor integration
  • Clinical trial validation
  • Predictive relapse detection

๐Ÿงช Getting Started

1. Install Flutter

https://docs.flutter.dev/get-started/install

2. Clone Repository

git clone <repo-url>
cd StepSure

3. Install Dependencies

flutter pub get

4. Configure Supabase

  • Add your Supabase URL
  • Add anon/public key
  • Configure storage bucket for videos

5. Run Application

flutter run

๐Ÿ“„ License

(Academic Use).


๐Ÿ‘ฉโ€โš• Disclaimer

StepSure is a research and prototype application. It does not replace professional medical diagnosis or treatment. Always consult a licensed physiotherapist or medical professional for rehabilitation guidance.


About

real-time gait analysis intelligent physiotherapy assistant.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors