Skip to content

CPP Implementation of "LightGlue: Local Feature Matching at Light Speed"

License

Notifications You must be signed in to change notification settings

MrNeRF/Light_Glue_CPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LightGlue C++ Implementation

This repository contains a C++ implementation of LightGlue using LibTorch. LightGlue is a lightweight feature matcher that achieves state-of-the-art performance while being significantly faster than traditional approaches.

If you are interested in collaborating on this project, would like to reach out to me, or are considering to contribute to the discussion of the overall NeRF/GS pipeline, please join the Discord: https://discord.gg/NqwTqVYVmj

Features

  • Complete C++ implementation of LightGlue using LibTorch
  • CUDA acceleration support
  • Integration with OpenCV for image handling
  • ALIKED feature extractor implementation
  • Efficient memory management with move semantics
  • Visualization support for matches and pruning

Prerequisites

  • CMake >= 3.26
  • CUDA >= 12.1
  • LibTorch (C++ distribution of PyTorch)
  • OpenCV
  • C++20 compliant compiler
  • git-lfs (for model weights)

Building

mkdir build && cd build
cmake ..
make -j

Usage

The repository includes a sample application demonstrating feature matching between two images:

./LightGlue path/to/image1.jpg path/to/image2.jpg

Project Structure

.
├── include/
│   ├── feature/         # Feature extraction components
│   └── matcher/         # LightGlue matcher implementation
├── src/
│   ├── feature/         # Feature extraction implementations
│   └── matcher/         # Matcher implementations
├── examples/            # Example applications
├── models/             # Directory for model weights
└── CMakeLists.txt

Implementation Details

The implementation follows the original Python architecture while leveraging C++ and LibTorch features:

  • CUDA optimizations for performance
  • Move semantics for efficient memory handling
  • LibTorch's automatic differentiation (though primarily used for inference)
  • OpenCV integration for image processing and visualization

Model Weights

Place the model weights in the models/ directory. The following models are supported:

  • ALIKED feature extractor weights
  • LightGlue matcher weights

Future Development

TODO

  • Batch Processing Support

    • Implement efficient batch processing for multiple image pairs
    • Optimize memory usage for batch operations
    • Add batch-specific configuration options
  • Flash Attention Implementation

    • Add efficient Flash Attention mechanism
    • Optimize for different GPU architectures
    • Implement memory-efficient attention patterns

Contributing

Contributions are welcome! Please feel free to submit pull requests or create issues for bugs and feature requests.

Citations

If you use this implementation, please cite both the original LightGlue paper and the C++ implementation:

@inproceedings{lindenberger2023lightglue,
  author    = {Philipp Lindenberger and
               Paul-Edouard Sarlin and
               Marc Pollefeys},
  title     = {{LightGlue: Local Feature Matching at Light Speed}},
  booktitle = {ICCV},
  year      = {2023}
}

@misc{patas2024lightgluecpp,
  author    = {Janusch Patas},
  title     = {LightGlue C++ Implementation},
  year      = {2024},
  publisher = {GitHub},
  journal   = {GitHub Repository},
  howpublished = {\url{https://github.com/MrNeRF/Light_Glue_CPP}}
}

About

CPP Implementation of "LightGlue: Local Feature Matching at Light Speed"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published