Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Pose2Par Logo

Pose2Par โ›ณ

Professional Golf Swing Biomechanical Analysis โ€” From Standard Video to 3D Motion Data

License Python Docker Platform Status Validation


Pose2Par turns an ordinary video of a golf swing into full 3D biomechanical data โ€” pelvis rotation, torso rotation, X-factor, and swing event timing โ€” all without a motion capture lab.
It combines deep-learning pose estimation (MMPose), AI marker enhancement (LSTM / Transformer), and physics-based biomechanical modelling (OpenSim) into a single, Docker-powered pipeline with an easy-to-use desktop UI.


๐Ÿ“ธ UI Preview

Pose2Par UI

Capture, analyse, and visualise golf swing biomechanics โ€” all from one interface.


โœ… Validation

Pose2Par has been independently validated against laboratory-grade 3D motion capture equipment. Key findings:

Metric Reliability
Swing event timing โœ… High
Pelvis rotation (Top of Backswing) โœ… High
X-Factor (Top of Backswing) โœ… High
Impact detection (low handicap) โœ… Good
Impact detection (high handicap) โš ๏ธ Mixed
Swing finish phase โŒ Limited (self-occlusion)
Angular velocity โŒ Unreliable
Sagittal-plane tilt โŒ Unreliable (single camera depth)

โ†’ Read the full, transparent breakdown: VALIDATION.md


๐ŸŽฏ Features

  • Live Swing Capture โ€” high-FPS camera support (up to 120 FPS) with automatic swing detection
  • 2D Pose Estimation โ€” powered by MMPose with state-of-the-art keypoint detection
  • AI Marker Enhancement โ€” LSTM and Transformer models correct and fill tracking gaps
  • 3D Biomechanical Modelling โ€” OpenSim calculates true joint angles from markerless video
  • Golf-Specific Metrics:
    • Pelvis rotation angle
    • Torso rotation angle
    • X-Factor (torsoโ€“pelvis separation)
    • Swing phase labels (address โ†’ backswing โ†’ downswing โ†’ follow-through)
    • Key event timestamps (top of backswing, ball impact)
  • Interactive Desktop UI โ€” capture, replay, graph, and export in one window
  • CSV Export โ€” frame-by-frame metric export for external analysis
  • Fully Containerised โ€” Docker pipeline for reproducible, portable deployment

๐Ÿ—๏ธ Architecture

Pose2Par uses a three-stage pipeline:

Video Input โ†’ MMPose (Pose Estimation) โ†’ Marker Enhancer (ML Enhancement) โ†’ OpenSim (Biomechanics) โ†’ Analysis & Visualization

Pipeline Stages

  1. MMPose: 2D pose estimation using state-of-the-art deep learning models
  2. Marker Enhancer: LSTM/Transformer models to improve marker tracking and fill gaps
  3. OpenSim: Biomechanical modeling and joint angle calculations
  4. Analysis: Event detection, metric calculation, and visualization

๐Ÿ“‹ Prerequisites

System Requirements

  • OS: Windows 10/11 (tested), Linux (should work with minor modifications)
  • GPU: NVIDIA GPU with CUDA support (recommended for real-time performance)
  • RAM: 8GB minimum, 16GB recommended
  • Storage: 10GB free space (for Docker images and dependencies)

Software Requirements

  • Python: 3.8 or higher
  • Docker Desktop: Latest version with Docker Compose
  • NVIDIA GPU Drivers: If using GPU acceleration
  • NVIDIA Container Toolkit: For GPU support in Docker (Linux only)

Hardware Requirements

  • Camera: External USB webcam or capture card
    • Recommended: High-FPS camera (60-120 FPS) for optimal swing capture
    • Minimum: 30 FPS webcam
  • Camera Position: Face-on view of golfer during swing

๐Ÿš€ Quick Start

1. Clone the Repository

git clone https://github.com/cavanaulton/pose2par.git
cd pose2par

2. Run Setup Script

Windows:

setup.bat

Linux/Mac:

chmod +x setup.sh
./setup.sh

This will:

  • Verify Python and Docker installation
  • Install Python dependencies
  • Build Docker images (MMPose, Marker Enhancer, OpenSim)
  • Create necessary directories

3. Launch the Application

Windows:

scripts\run_pose2par.bat

Python (any OS):

python src/UI.py

๐Ÿ“– Detailed Installation

Step 1: Install Prerequisites

Install Python

Download and install Python 3.8+ from python.org

Install Docker Desktop

  1. Download from docker.com
  2. Install and ensure Docker is running
  3. (Windows) Enable WSL 2 backend if prompted

Install NVIDIA Drivers (for GPU acceleration)

  1. Download latest drivers from nvidia.com
  2. Install NVIDIA Container Toolkit (Linux):
    distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
    curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
    curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
    sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
    sudo systemctl restart docker

Step 2: Install Python Dependencies

pip install -r requirements_ui.txt

Step 3: Build Docker Images

# Windows
build_docker_images.bat

# Linux/Mac
docker-compose -f docker-compose.build.yml build

This builds three Docker images:

  • mmpose:latest - Pose estimation
  • marker_enhancer:latest - ML-based marker enhancement
  • opensim:latest - Biomechanical modeling

Note: First build may take 20-30 minutes depending on your internet speed and system.

Step 4: Configure Camera (Optional)

Edit config.py to customize camera settings:

# Camera settings
CAMERA_WIDTH = 1920
CAMERA_HEIGHT = 1080
CAMERA_FPS = 60

# Force specific camera index (None for auto-detection)
FORCE_CAMERA_INDEX = None  # or set to specific index like 2

# Golfer handedness
GOLFER_HANDEDNESS = 'right'  # or 'left'

๐ŸŽฎ Usage

Capturing a Golf Swing

  1. Launch the UI: Run python UI.py or run_pose2par.bat
  2. Select Camera: Choose your external camera from the dropdown
  3. Position Golfer: Ensure face-on view with full body visible
  4. Start Recording: Click "Start Recording" button
  5. Capture Swing: Record 3-5 seconds including full swing
  6. Stop Recording: Click "Stop Recording"

Analyzing a Swing

  1. Run Analysis: Click "Analyze Swing" button
  2. Wait for Processing: Pipeline runs automatically (2-5 minutes typical)
  3. View Results:
    • Playback with overlay visualization
    • Real-time angle graphs
    • Frame-by-frame metrics
  4. Export Data: Click "Export" to save CSV with all metrics

Working with Existing Videos

  1. Place video file in pipeline_data/input_video/ as input_video.mp4
  2. Click "Analyze Swing" in UI, or
  3. Run pipeline manually:
    python run_full_pipeline.py

๐Ÿ“Š Output Files

After analysis, you'll find:

  • pipeline_data/mmpose_output/ - Raw pose estimation data
  • pipeline_data/marker_enhancer_output/ - Enhanced marker trajectories (.trc files)
  • pipeline_data/opensim_output/ - Biomechanical analysis results (.mot files, joint angles)
  • pipeline_data/exports/ - CSV exports for external analysis

๐Ÿ”ง Configuration

Camera Configuration (config.py)

# Camera settings
CAMERA_WIDTH = 1920
CAMERA_HEIGHT = 1080
CAMERA_FPS = 60
FORCE_CAMERA_INDEX = None  # Auto-detect or specify index

# Skip built-in webcams
SKIP_BUILTIN_WEBCAM = True

# Golf analysis settings
GOLFER_HANDEDNESS = 'right'  # 'right' or 'left'
CAMERA_VIEW = 'face_on'      # 'face_on' or 'down_the_line'

Pipeline Configuration

Edit Docker service parameters in docker-compose.yml:

# MMPose settings
--bbox-thr 0.4    # Bounding box confidence threshold
--kpt-thr 0.3     # Keypoint confidence threshold

# Marker Enhancer settings
--fps 60          # Video framerate
--subject_height 1.70  # Subject height in meters
--subject_weight 74.0  # Subject weight in kg

๐Ÿงช Development

Project Structure

pose2par/
โ”œโ”€โ”€ UI.py                    # Main application UI
โ”œโ”€โ”€ config.py                # Configuration settings
โ”œโ”€โ”€ docker_handler.py        # Docker pipeline orchestration
โ”œโ”€โ”€ event_detection.py       # Golf swing event detection
โ”œโ”€โ”€ camera_detector.py       # Camera detection utilities
โ”œโ”€โ”€ run_full_pipeline.py     # Standalone pipeline runner
โ”œโ”€โ”€ setup.bat                # Windows setup script
โ”œโ”€โ”€ build_docker_images.bat  # Docker image builder
โ”œโ”€โ”€ run_pose2par.bat         # Windows launcher
โ”œโ”€โ”€ docker-compose.yml       # Docker services configuration
โ”œโ”€โ”€ requirements_ui.txt      # Python dependencies
โ”œโ”€โ”€ mmpose/                  # MMPose pose estimation
โ”œโ”€โ”€ marker-enhancer/         # ML-based marker enhancement
โ”œโ”€โ”€ opensim/                 # OpenSim biomechanical models
โ”œโ”€โ”€ docker_image_files/      # Dockerfiles for each service
โ”œโ”€โ”€ pipeline_data/           # Pipeline input/output/working directory
โ”‚   โ”œโ”€โ”€ input_video/        # Input videos
โ”‚   โ”œโ”€โ”€ mmpose_output/      # Pose estimation output
โ”‚   โ”œโ”€โ”€ marker_enhancer_output/  # Enhanced markers
โ”‚   โ”œโ”€โ”€ opensim_output/     # Biomechanical analysis
โ”‚   โ””โ”€โ”€ exports/            # CSV exports
โ”œโ”€โ”€ scripts/                 # Utility scripts
โ””โ”€โ”€ models/                  # Pre-trained model weights

Running Individual Pipeline Stages

Test individual stages using Docker Compose profiles:

# MMPose only
docker-compose run mmpose-only

# Marker Enhancer only
docker-compose run marker-enhancer-only

# OpenSim only
docker-compose run opensim-only

Adding New Biomechanical Metrics

  1. Modify OpenSim scripts in opensim/scripts/
  2. Update docker_handler.py to parse new metrics
  3. Update UI.py to visualize new metrics

๐Ÿ› Troubleshooting

Docker Issues

Problem: "Cannot connect to Docker daemon"

# Ensure Docker Desktop is running
# Windows: Check system tray for Docker icon
# Linux: sudo systemctl start docker

Problem: "CUDA not available" in Docker container

# Windows: Ensure WSL 2 is enabled and NVIDIA drivers are installed in Windows
# Linux: Install nvidia-container-toolkit

Camera Issues

Problem: Camera not detected

# Check camera connection
# Try different USB port
# Set FORCE_CAMERA_INDEX in config.py

Problem: Low FPS during capture

# Reduce CAMERA_FPS in config.py
# Check camera specifications
# Close other applications using camera

Pipeline Issues

Problem: "No pose detected" error

# Ensure golfer is fully visible in frame
# Check lighting conditions
# Lower --bbox-thr threshold in docker-compose.yml

Problem: Docker build fails

# Ensure stable internet connection
# Clear Docker cache: docker system prune -a
# Rebuild: docker-compose -f docker-compose.build.yml build --no-cache

๐Ÿ“š Citation

If you use Pose2Par in your research, please cite:

@software{pose2par,
  title={Pose2Par: Markerless Golf Swing Biomechanical Analysis via Monocular Video},
  author={Aulton, Cavan},
  year={2026},
  url={https://github.com/cavanaulton/pose2par}
}

Acknowledgements

Pose2Par builds on the following open-source projects โ€” thank you to their maintainers:

Project Licence Use in Pose2Par
MMPose Apache 2.0 2D pose estimation backbone
OpenSim Apache 2.0 Biomechanical modelling engine
PyTorch BSD ML model training and inference

๐Ÿ“„ License

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

Individual components may have their own licenses:

  • MMPose: Apache License 2.0
  • OpenSim: Apache License 2.0
  • Marker Enhancer: Check marker-enhancer/LICENSE

๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Make your changes and test them
  4. Open a Pull Request with a clear description

๐Ÿ’ฌ Support

๐Ÿ—บ๏ธ Roadmap

  • Down-the-line camera view support
  • Multi-camera fusion for improved depth estimation
  • Cloud-based processing option
  • Expanded biomechanical metrics (hip speed, shoulder plane)
  • Mobile companion app

๐Ÿ“ Changelog

See CHANGELOG.md for version history.

โš ๏ธ Disclaimer

Pose2Par is a research and coaching tool for biomechanical analysis. Results should be interpreted by qualified professionals. This software is not intended for medical diagnosis or treatment. See VALIDATION.md for a full account of accuracy and known limitations.


Made with โ›ณ for golf biomechanics research

VALIDATION.md ยท CHANGELOG.md ยท LICENSE ยท Issues

About

AI-powered golf swing analysis: Real-time motion capture, pose estimation (MMPose), ML marker enhancement, and OpenSim biomechanics for swing metrics and coaching insights.

Resources

Stars

16 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages