OpenCV 5.0.0
Open Source Computer Vision
Loading...
Searching...
No Matches
cv::LightGlueMatcher Class Referenceabstract

LightGlue feature matcher. More...

#include <opencv2/features.hpp>

Public Member Functions

virtual ~LightGlueMatcher ()
virtual void clearPairInfo ()=0
 Clears stored pair context information.
virtual void setPairInfo (InputArray queryKpts, InputArray trainKpts, Size queryImageSize=Size(), Size trainImageSize=Size())=0
 Sets the keypoint and image size context for the next match() call.
Public Member Functions inherited from cv::DescriptorMatcher
virtual ~DescriptorMatcher ()
virtual void add (InputArrayOfArrays descriptors)
 Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor collection.
virtual void clear () CV_OVERRIDE
 Clears the train descriptor collections.
virtual CV_NODISCARD_STD Ptr< DescriptorMatcherclone (bool emptyTrainData=false) const =0
 Clones the matcher.
virtual bool empty () const CV_OVERRIDE
 Returns true if there are no train descriptors in the both collections.
const std::vector< Mat > & getTrainDescriptors () const
 Returns a constant link to the train descriptor collection trainDescCollection .
virtual bool isMaskSupported () const =0
 Returns true if the descriptor matcher supports masking permissible matches.
void knnMatch (InputArray queryDescriptors, InputArray trainDescriptors, std::vector< std::vector< DMatch > > &matches, int k, InputArray mask=noArray(), bool compactResult=false) const
 Finds the k best matches for each descriptor from a query set.
void knnMatch (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, int k, InputArrayOfArrays masks=noArray(), bool compactResult=false)
void match (InputArray queryDescriptors, InputArray trainDescriptors, std::vector< DMatch > &matches, InputArray mask=noArray()) const
 Finds the best match for each descriptor from a query set.
void match (InputArray queryDescriptors, std::vector< DMatch > &matches, InputArrayOfArrays masks=noArray())
void radiusMatch (InputArray queryDescriptors, InputArray trainDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArray mask=noArray(), bool compactResult=false) const
 For each query descriptor, finds the training descriptors not farther than the specified distance.
void radiusMatch (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArrayOfArrays masks=noArray(), bool compactResult=false)
virtual void read (const FileNode &) CV_OVERRIDE
 Reads algorithm parameters from a file storage.
void read (const String &fileName)
virtual void train ()
 Trains a descriptor matcher.
void write (const Ptr< FileStorage > &fs, const String &name) const
void write (const String &fileName) const
virtual void write (FileStorage &) const CV_OVERRIDE
 Stores algorithm parameters in a file storage.
void write (FileStorage &fs, const String &name) const
Public Member Functions inherited from cv::Algorithm
 Algorithm ()
virtual ~Algorithm ()
virtual String getDefaultName () const
virtual void save (const String &filename) const
void write (FileStorage &fs, const String &name) const

Static Public Member Functions

static Ptr< LightGlueMatchercreate (const String &modelPath, float scoreThreshold=0.0f, int backend=0, int target=0)
 Creates LightGlueMatcher from a model file path.
Static Public Member Functions inherited from cv::DescriptorMatcher
static Ptr< DescriptorMatchercreate (const DescriptorMatcher::MatcherType &matcherType)
static Ptr< DescriptorMatchercreate (const String &descriptorMatcherType)
 Creates a descriptor matcher of a given type with the default parameters (using default constructor).
Static Public Member Functions inherited from cv::Algorithm
template<typename _Tp>
static Ptr< _Tpload (const String &filename, const String &objname=String())
 Loads algorithm from the file.
template<typename _Tp>
static Ptr< _TploadFromString (const String &strModel, const String &objname=String())
 Loads algorithm from a String.
template<typename _Tp>
static Ptr< _Tpread (const FileNode &fn)
 Reads algorithm from the file node.

Protected Member Functions

 LightGlueMatcher ()
Protected Member Functions inherited from cv::DescriptorMatcher
void checkMasks (InputArrayOfArrays masks, int queryDescriptorsCount) const
virtual void knnMatchImpl (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, int k, InputArrayOfArrays masks=noArray(), bool compactResult=false)=0
virtual void radiusMatchImpl (InputArray queryDescriptors, std::vector< std::vector< DMatch > > &matches, float maxDistance, InputArrayOfArrays masks=noArray(), bool compactResult=false)=0
Protected Member Functions inherited from cv::Algorithm
void writeFormat (FileStorage &fs) const

Additional Inherited Members

Public Types inherited from cv::DescriptorMatcher
enum  MatcherType {
  FLANNBASED = 1 ,
  BRUTEFORCE = 2 ,
  BRUTEFORCE_L1 = 3 ,
  BRUTEFORCE_HAMMING = 4 ,
  BRUTEFORCE_HAMMINGLUT = 5 ,
  BRUTEFORCE_SL2 = 6
}
Static Protected Member Functions inherited from cv::DescriptorMatcher
static CV_NODISCARD_STD Mat clone_op (Mat m)
static bool isMaskedOut (InputArrayOfArrays masks, int queryIdx)
static bool isPossibleMatch (InputArray mask, int queryIdx, int trainIdx)
Protected Attributes inherited from cv::DescriptorMatcher
std::vector< MattrainDescCollection
 Collection of descriptors from train images.
std::vector< UMatutrainDescCollection

Detailed Description

LightGlue feature matcher.

LightGlue is a CNN-based feature matcher, as described in [Lindenberger23] . It takes keypoint locations and descriptors from two images and directly predicts match pairs. Unlike traditional matchers that compute descriptor distances, LightGlue uses attention mechanisms to produce confidence scores for each potential match pair.

The matcher extends DescriptorMatcher and supports the standard match(), knnMatch(), and radiusMatch() interfaces. Context (keypoints and image sizes) must be provided via setPairInfo() before matching.

Constructor & Destructor Documentation

◆ LightGlueMatcher()

cv::LightGlueMatcher::LightGlueMatcher ( )
protected

◆ ~LightGlueMatcher()

virtual cv::LightGlueMatcher::~LightGlueMatcher ( )
virtual

Member Function Documentation

◆ clearPairInfo()

virtual void cv::LightGlueMatcher::clearPairInfo ( )
pure virtual
Python:
cv.LightGlueMatcher.clearPairInfo() -> None

Clears stored pair context information.

◆ create()

Ptr< LightGlueMatcher > cv::LightGlueMatcher::create ( const String & modelPath,
float scoreThreshold = 0.0f,
int backend = 0,
int target = 0 )
static
Python:
cv.LightGlueMatcher.create(modelPath[, scoreThreshold[, backend[, target]]]) -> retval
cv.LightGlueMatcher.createFromMemory(modelData[, scoreThreshold[, backend[, target]]]) -> retval
cv.LightGlueMatcher_create(modelPath[, scoreThreshold[, backend[, target]]]) -> retval
cv.LightGlueMatcher_createFromMemory(modelData[, scoreThreshold[, backend[, target]]]) -> retval

Creates LightGlueMatcher from a model file path.

Parameters
modelPathPath to the ONNX model file.
scoreThresholdMatch confidence threshold.
backendDNN backend
targetDNN target
Examples
samples/cpp/stitching_detailed.cpp.

◆ setPairInfo()

virtual void cv::LightGlueMatcher::setPairInfo ( InputArray queryKpts,
InputArray trainKpts,
Size queryImageSize = Size(),
Size trainImageSize = Size() )
pure virtual
Python:
cv.LightGlueMatcher.setPairInfo(queryKpts, trainKpts[, queryImageSize[, trainImageSize]]) -> None

Sets the keypoint and image size context for the next match() call.

This provides the spatial context that LightGlue needs in addition to descriptors. Must be called before match()/knnMatch()/radiusMatch() unless using automatic context from in-process ALIKED instances.

Parameters
queryKptsQuery image keypoints (Nx2 float matrix with x,y coordinates).
trainKptsTrain image keypoints (Nx2 float matrix with x,y coordinates).
queryImageSizeSize of the query image (width, height).
trainImageSizeSize of the train image (width, height).

The documentation for this class was generated from the following file: