Skip to content

nihalanas/gait-analysis

Repository files navigation

Gait Analysis & Joint Angle Estimation

Real-time gait tracking and joint-angle estimation from video, built with MediaPipe Pose and OpenCV. The pipeline detects body landmarks, computes hip and knee angles live, smooths joint trajectories with a Kalman filter, and exports per-frame angle data to CSV for downstream gait analysis.

Computer-vision research project exploring markerless gait analysis as a low-cost alternative to lab-based motion capture.

Features

  • Real-time pose & angle estimation — hip and knee angles computed and overlaid live on the video feed.
  • Ankle trajectory tracking — right-ankle path projected over time for stride visualisation.
  • Kalman filtering — applied to ankle and knee positions for smooth, noise-reduced tracking.
  • ArUco marker support — optional hip marker for improved hip-angle accuracy.
  • Gait feature extraction — gait-cycle time, stride length and height derived from processed data.
  • CSV export — per-frame hip/knee angles saved for further analysis (see gait_angles.csv for a sample).

Tech Stack

Area Tools
Pose detection MediaPipe Pose
Computer vision OpenCV (incl. ArUco)
Signal smoothing Kalman filter
Data & visualisation NumPy, pandas, Matplotlib, SciPy
Language Python

Getting Started

# 1. Install dependencies (a virtual environment is recommended)
pip install -r requirements.txt

# 2. Open the notebooks
jupyter notebook
  • angle_estimation.ipynb — joint-angle estimation from a live webcam feed. Each cell is annotated for clarity.
  • gait_model.ipynb — full gait model on both video input and live webcam, including angle calculation and CSV export.

Repository Structure

.
├── angle_estimation.ipynb   # Live webcam joint-angle estimation
├── gait_model.ipynb         # Full gait model (video + webcam) with CSV export
├── gait_angles.csv          # Sample exported hip/knee angle data
├── marker_1.png             # Sample generated ArUco marker
├── requirements.txt
├── ideal_data/              # Reference "ideal" hip/knee angles by subject height
│   ├── angles_164.csv       #   subject height 164 cm
│   └── angles_174.csv       #   subject height 174 cm
├── support_files/           # Component build/test notebooks and utilities
│   ├── aruco_creater.py     #   generates an ArUco marker
│   ├── gait_trajectory.ipynb
│   ├── graph_plotting.ipynb #   plots recorded hip/knee angle data
│   └── ideal_analysis.ipynb #   feature engineering on the ideal data
└── test_videos/             # Sample clips across resolutions/frame rates

Test video formats

File Resolution Frame rate
gait_video11.mp4 1080p 30 fps
gait_video12.mp4 1080p 60 fps
gait_video13.mp4 4K 30 fps
gait_video14.mp4 4K 24 fps

Notes

  • The MediaPipe Pose (Heavy) model is loaded via the mediapipe package; no separate download is required.
  • File paths inside the notebooks may need adjusting to match your local layout.

License

Released under the MIT License.

About

Real-time markerless gait analysis and joint-angle estimation from video using MediaPipe Pose, OpenCV and Kalman filtering.

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors