Skip to main content

LightGlueMatcher

Struct LightGlueMatcher 

Source
pub struct LightGlueMatcher { /* private fields */ }
Expand 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.

Implementations§

Source§

impl LightGlueMatcher

Source

pub fn create( model_path: impl AsRef<OsStr>, score_threshold: f32, backend: i32, target: i32, ) -> Result<Ptr<LightGlueMatcher>>

Creates LightGlueMatcher from a model file path.

§Parameters
  • modelPath: Path to the ONNX model file.
  • scoreThreshold: Match confidence threshold.
  • backend: DNN backend
  • target: DNN target
§C++ default parameters
  • score_threshold: 0.0f
  • backend: 0
  • target: 0
Source

pub fn create_def( model_path: impl AsRef<OsStr>, ) -> Result<Ptr<LightGlueMatcher>>

Creates LightGlueMatcher from a model file path.

§Parameters
  • modelPath: Path to the ONNX model file.
  • scoreThreshold: Match confidence threshold.
  • backend: DNN backend
  • target: DNN target
§Note

This alternative version of LightGlueMatcher::create function uses the following default values for its arguments:

  • score_threshold: 0.0f
  • backend: 0
  • target: 0
Source

pub fn create_from_memory( model_data: &Vector<u8>, score_threshold: f32, backend: i32, target: i32, ) -> Result<Ptr<LightGlueMatcher>>

Creates LightGlueMatcher from in-memory model data.

§Parameters
  • modelData: Buffer containing the model data.
  • scoreThreshold: Match confidence threshold.
  • backend: DNN backend
  • target: DNN target
§C++ default parameters
  • score_threshold: 0.0f
  • backend: 0
  • target: 0
Source

pub fn create_from_memory_def( model_data: &Vector<u8>, ) -> Result<Ptr<LightGlueMatcher>>

Creates LightGlueMatcher from in-memory model data.

§Parameters
  • modelData: Buffer containing the model data.
  • scoreThreshold: Match confidence threshold.
  • backend: DNN backend
  • target: DNN target
§Note

This alternative version of LightGlueMatcher::create_from_memory function uses the following default values for its arguments:

  • score_threshold: 0.0f
  • backend: 0
  • target: 0

Trait Implementations§

Source§

impl AlgorithmTrait for LightGlueMatcher

Source§

fn as_raw_mut_Algorithm(&mut self) -> *mut c_void

Source§

fn clear(&mut self) -> Result<()>

Clears the algorithm state
Source§

fn read(&mut self, fn_: &impl FileNodeTraitConst) -> Result<()>

Reads algorithm parameters from a file storage
Source§

impl AlgorithmTraitConst for LightGlueMatcher

Source§

fn as_raw_Algorithm(&self) -> *const c_void

Source§

fn write(&self, fs: &mut impl FileStorageTrait) -> Result<()>

Stores algorithm parameters in a file storage
Source§

fn write_1(&self, fs: &mut impl FileStorageTrait, name: &str) -> Result<()>

Stores algorithm parameters in a file storage Read more
Source§

fn empty(&self) -> Result<bool>

Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
Source§

fn save(&self, filename: impl AsRef<OsStr>) -> Result<()>

Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).
Source§

fn get_default_name(&self) -> Result<String>

Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.
Source§

impl Boxed for LightGlueMatcher

Source§

unsafe fn from_raw( ptr: <LightGlueMatcher as OpenCVFromExtern>::ExternReceive, ) -> Self

Wrap the specified raw pointer Read more
Source§

fn into_raw( self, ) -> <LightGlueMatcher as OpenCVTypeExternContainer>::ExternSendMut

Return the underlying raw pointer while consuming this wrapper. Read more
Source§

fn as_raw(&self) -> <LightGlueMatcher as OpenCVTypeExternContainer>::ExternSend

Return the underlying raw pointer. Read more
Source§

fn as_raw_mut( &mut self, ) -> <LightGlueMatcher as OpenCVTypeExternContainer>::ExternSendMut

Return the underlying mutable raw pointer Read more
Source§

impl Debug for LightGlueMatcher

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DescriptorMatcherTrait for LightGlueMatcher

Source§

fn as_raw_mut_DescriptorMatcher(&mut self) -> *mut c_void

Source§

fn add(&mut self, descriptors: &impl ToInputArray) -> Result<()>

Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor collection. Read more
Source§

fn clear(&mut self) -> Result<()>

Clears the train descriptor collections.
Source§

fn train(&mut self) -> Result<()>

Trains a descriptor matcher Read more
Source§

fn match_( &mut self, query_descriptors: &impl ToInputArray, matches: &mut Vector<DMatch>, masks: &impl ToInputArray, ) -> Result<()>

Finds the best match for each descriptor from a query set. Read more
Source§

fn match__def( &mut self, query_descriptors: &impl ToInputArray, matches: &mut Vector<DMatch>, ) -> Result<()>

Finds the best match for each descriptor from a query set. Read more
Source§

fn knn_match( &mut self, query_descriptors: &impl ToInputArray, matches: &mut Vector<Vector<DMatch>>, k: i32, masks: &impl ToInputArray, compact_result: bool, ) -> Result<()>

Finds the k best matches for each descriptor from a query set. Read more
Source§

fn knn_match_def( &mut self, query_descriptors: &impl ToInputArray, matches: &mut Vector<Vector<DMatch>>, k: i32, ) -> Result<()>

Finds the k best matches for each descriptor from a query set. Read more
Source§

fn radius_match( &mut self, query_descriptors: &impl ToInputArray, matches: &mut Vector<Vector<DMatch>>, max_distance: f32, masks: &impl ToInputArray, compact_result: bool, ) -> Result<()>

For each query descriptor, finds the training descriptors not farther than the specified distance. Read more
Source§

fn radius_match_def( &mut self, query_descriptors: &impl ToInputArray, matches: &mut Vector<Vector<DMatch>>, max_distance: f32, ) -> Result<()>

For each query descriptor, finds the training descriptors not farther than the specified distance. Read more
Source§

fn read(&mut self, file_name: impl AsRef<OsStr>) -> Result<()>

Source§

fn read_from_node(&mut self, unnamed: &impl FileNodeTraitConst) -> Result<()>

Source§

impl DescriptorMatcherTraitConst for LightGlueMatcher

Source§

fn as_raw_DescriptorMatcher(&self) -> *const c_void

Source§

fn get_train_descriptors(&self) -> Result<Vector<Mat>>

Returns a constant link to the train descriptor collection trainDescCollection .
Source§

fn empty(&self) -> Result<bool>

Returns true if there are no train descriptors in the both collections.
Source§

fn is_mask_supported(&self) -> Result<bool>

Returns true if the descriptor matcher supports masking permissible matches.
Source§

fn train_match( &self, query_descriptors: &impl ToInputArray, train_descriptors: &impl ToInputArray, matches: &mut Vector<DMatch>, mask: &impl ToInputArray, ) -> Result<()>

Finds the best match for each descriptor from a query set. Read more
Source§

fn train_match_def( &self, query_descriptors: &impl ToInputArray, train_descriptors: &impl ToInputArray, matches: &mut Vector<DMatch>, ) -> Result<()>

Finds the best match for each descriptor from a query set. Read more
Source§

fn knn_train_match( &self, query_descriptors: &impl ToInputArray, train_descriptors: &impl ToInputArray, matches: &mut Vector<Vector<DMatch>>, k: i32, mask: &impl ToInputArray, compact_result: bool, ) -> Result<()>

Finds the k best matches for each descriptor from a query set. Read more
Source§

fn knn_train_match_def( &self, query_descriptors: &impl ToInputArray, train_descriptors: &impl ToInputArray, matches: &mut Vector<Vector<DMatch>>, k: i32, ) -> Result<()>

Finds the k best matches for each descriptor from a query set. Read more
Source§

fn radius_train_match( &self, query_descriptors: &impl ToInputArray, train_descriptors: &impl ToInputArray, matches: &mut Vector<Vector<DMatch>>, max_distance: f32, mask: &impl ToInputArray, compact_result: bool, ) -> Result<()>

For each query descriptor, finds the training descriptors not farther than the specified distance. Read more
Source§

fn radius_train_match_def( &self, query_descriptors: &impl ToInputArray, train_descriptors: &impl ToInputArray, matches: &mut Vector<Vector<DMatch>>, max_distance: f32, ) -> Result<()>

For each query descriptor, finds the training descriptors not farther than the specified distance. Read more
Source§

fn write(&self, file_name: impl AsRef<OsStr>) -> Result<()>

Source§

fn write_to_storage(&self, unnamed: &mut impl FileStorageTrait) -> Result<()>

Source§

fn clone(&self, empty_train_data: bool) -> Result<Ptr<DescriptorMatcher>>

Clones the matcher. Read more
Source§

fn clone_def(&self) -> Result<Ptr<DescriptorMatcher>>

Clones the matcher. Read more
Source§

fn write_to_storage_with_name( &self, fs: &mut impl FileStorageTrait, name: &str, ) -> Result<()>

Source§

impl Drop for LightGlueMatcher

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl From<LightGlueMatcher> for Algorithm

Source§

fn from(s: LightGlueMatcher) -> Self

Converts to this type from the input type.
Source§

impl From<LightGlueMatcher> for DescriptorMatcher

Source§

fn from(s: LightGlueMatcher) -> Self

Converts to this type from the input type.
Source§

impl LightGlueMatcherTrait for LightGlueMatcher

Source§

fn as_raw_mut_LightGlueMatcher(&mut self) -> *mut c_void

Source§

fn set_pair_info( &mut self, query_kpts: &impl ToInputArray, train_kpts: &impl ToInputArray, query_image_size: Size, train_image_size: Size, ) -> Result<()>

Sets the keypoint and image size context for the next match() call. Read more
Source§

fn set_pair_info_def( &mut self, query_kpts: &impl ToInputArray, train_kpts: &impl ToInputArray, ) -> Result<()>

Sets the keypoint and image size context for the next match() call. Read more
Source§

fn clear_pair_info(&mut self) -> Result<()>

Clears stored pair context information.
Source§

impl LightGlueMatcherTraitConst for LightGlueMatcher

Source§

impl Send for LightGlueMatcher

Source§

impl TryFrom<DescriptorMatcher> for LightGlueMatcher

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(s: DescriptorMatcher) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Mat> ModifyInplace for Mat
where Mat: Boxed,

Source§

unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res, ) -> Res

Helper function to call OpenCV functions that allow in-place modification of a Mat or another similar object. By passing a mutable reference to the Mat to this function your closure will get called with the read reference and a write references to the same Mat. This is unsafe in a general case as it leads to having non-exclusive mutable access to the internal data, but it can be useful for some performance sensitive operations. One example of an OpenCV function that allows such in-place modification is imgproc::threshold. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.