pub struct BinaryDescriptorMatcher { /* private fields */ }Expand description
furnishes all functionalities for querying a dataset provided by user or internal to class (that user must, anyway, populate) on the model of [features2d_match]
Once descriptors have been extracted from an image (both they represent lines and points), it becomes interesting to be able to match a descriptor with another one extracted from a different image and representing the same line or point, seen from a differente perspective or on a different scale. In reaching such goal, the main headache is designing an efficient search algorithm to associate a query descriptor to one extracted from a dataset. In the following, a matching modality based on Multi-Index Hashing (MiHashing) will be described.
§Multi-Index Hashing
The theory described in this section is based on MIH . Given a dataset populated with binary
codes, each code is indexed m times into m different hash tables, according to m substrings it
has been divided into. Thus, given a query code, all the entries close to it at least in one
substring are returned by search as neighbor candidates. Returned entries are then checked for
validity by verifying that their full codes are not distant (in Hamming space) more than r bits
from query code. In details, each binary code h composed of b bits is divided into m
disjoint substrings , each with length
or
bits. Formally, when two codes h and g differ
by at the most r bits, in at the least one of their m substrings they differ by at the most
bits. In particular, when
(where
is the Hamming norm), there must exist a substring k (with
) such that
That means that if Hamming distance between each of the m substring is strictly greater than
, then
must be larger that r and that is a
contradiction. If the codes in dataset are divided into m substrings, then m tables will be
built. Given a query q with substrings
, i-th hash table is
searched for entries distant at the most
from
and a set of
candidates
is obtained. The union of sets
is a superset of the r-neighbors
of q. Then, last step of algorithm is computing the Hamming distance between q and each
element in
, deleting the codes that are distant more that r from q.
Implementations§
Source§impl BinaryDescriptorMatcher
impl BinaryDescriptorMatcher
Sourcepub fn create_binary_descriptor_matcher() -> Result<Ptr<BinaryDescriptorMatcher>>
pub fn create_binary_descriptor_matcher() -> Result<Ptr<BinaryDescriptorMatcher>>
Create a BinaryDescriptorMatcher object and return a smart pointer to it.
Sourcepub fn default() -> Result<BinaryDescriptorMatcher>
pub fn default() -> Result<BinaryDescriptorMatcher>
Constructor.
The BinaryDescriptorMatcher constructed is able to store and manage 256-bits long entries.
Trait Implementations§
Source§impl AlgorithmTraitConst for BinaryDescriptorMatcher
impl AlgorithmTraitConst for BinaryDescriptorMatcher
fn as_raw_Algorithm(&self) -> *const c_void
Source§fn write(&self, fs: &mut impl FileStorageTrait) -> Result<()>
fn write(&self, fs: &mut impl FileStorageTrait) -> Result<()>
Source§fn write_1(&self, fs: &mut impl FileStorageTrait, name: &str) -> Result<()>
fn write_1(&self, fs: &mut impl FileStorageTrait, name: &str) -> Result<()>
Source§fn write_with_name(&self, fs: &Ptr<FileStorage>, name: &str) -> Result<()>
fn write_with_name(&self, fs: &Ptr<FileStorage>, name: &str) -> Result<()>
Source§fn write_with_name_def(&self, fs: &Ptr<FileStorage>) -> Result<()>
fn write_with_name_def(&self, fs: &Ptr<FileStorage>) -> Result<()>
§Note
Source§fn empty(&self) -> Result<bool>
fn empty(&self) -> Result<bool>
Source§fn save(&self, filename: &str) -> Result<()>
fn save(&self, filename: &str) -> Result<()>
Source§fn get_default_name(&self) -> Result<String>
fn get_default_name(&self) -> Result<String>
Source§impl BinaryDescriptorMatcherTrait for BinaryDescriptorMatcher
impl BinaryDescriptorMatcherTrait for BinaryDescriptorMatcher
fn as_raw_mut_BinaryDescriptorMatcher(&mut self) -> *mut c_void
Source§fn match_query(
&mut self,
query_descriptors: &impl MatTraitConst,
matches: &mut Vector<DMatch>,
masks: &Vector<Mat>,
) -> Result<()>
fn match_query( &mut self, query_descriptors: &impl MatTraitConst, matches: &mut Vector<DMatch>, masks: &Vector<Mat>, ) -> Result<()>
Source§fn match_query_def(
&mut self,
query_descriptors: &impl MatTraitConst,
matches: &mut Vector<DMatch>,
) -> Result<()>
fn match_query_def( &mut self, query_descriptors: &impl MatTraitConst, matches: &mut Vector<DMatch>, ) -> Result<()>
Source§fn knn_match_query(
&mut self,
query_descriptors: &impl MatTraitConst,
matches: &mut Vector<Vector<DMatch>>,
k: i32,
masks: &Vector<Mat>,
compact_result: bool,
) -> Result<()>
fn knn_match_query( &mut self, query_descriptors: &impl MatTraitConst, matches: &mut Vector<Vector<DMatch>>, k: i32, masks: &Vector<Mat>, compact_result: bool, ) -> Result<()>
Source§fn knn_match_query_def(
&mut self,
query_descriptors: &impl MatTraitConst,
matches: &mut Vector<Vector<DMatch>>,
k: i32,
) -> Result<()>
fn knn_match_query_def( &mut self, query_descriptors: &impl MatTraitConst, matches: &mut Vector<Vector<DMatch>>, k: i32, ) -> Result<()>
Source§fn radius_match_1(
&mut self,
query_descriptors: &impl MatTraitConst,
matches: &mut Vector<Vector<DMatch>>,
max_distance: f32,
masks: &Vector<Mat>,
compact_result: bool,
) -> Result<()>
fn radius_match_1( &mut self, query_descriptors: &impl MatTraitConst, matches: &mut Vector<Vector<DMatch>>, max_distance: f32, masks: &Vector<Mat>, compact_result: bool, ) -> Result<()>
Source§fn radius_match_def_1(
&mut self,
query_descriptors: &impl MatTraitConst,
matches: &mut Vector<Vector<DMatch>>,
max_distance: f32,
) -> Result<()>
fn radius_match_def_1( &mut self, query_descriptors: &impl MatTraitConst, matches: &mut Vector<Vector<DMatch>>, max_distance: f32, ) -> Result<()>
Source§fn add(&mut self, descriptors: &Vector<Mat>) -> Result<()>
fn add(&mut self, descriptors: &Vector<Mat>) -> Result<()>
Source§impl BinaryDescriptorMatcherTraitConst for BinaryDescriptorMatcher
impl BinaryDescriptorMatcherTraitConst for BinaryDescriptorMatcher
fn as_raw_BinaryDescriptorMatcher(&self) -> *const c_void
Source§fn match_(
&self,
query_descriptors: &impl MatTraitConst,
train_descriptors: &impl MatTraitConst,
matches: &mut Vector<DMatch>,
mask: &impl MatTraitConst,
) -> Result<()>
fn match_( &self, query_descriptors: &impl MatTraitConst, train_descriptors: &impl MatTraitConst, matches: &mut Vector<DMatch>, mask: &impl MatTraitConst, ) -> Result<()>
Source§fn match__def(
&self,
query_descriptors: &impl MatTraitConst,
train_descriptors: &impl MatTraitConst,
matches: &mut Vector<DMatch>,
) -> Result<()>
fn match__def( &self, query_descriptors: &impl MatTraitConst, train_descriptors: &impl MatTraitConst, matches: &mut Vector<DMatch>, ) -> Result<()>
Source§fn knn_match(
&self,
query_descriptors: &impl MatTraitConst,
train_descriptors: &impl MatTraitConst,
matches: &mut Vector<Vector<DMatch>>,
k: i32,
mask: &impl MatTraitConst,
compact_result: bool,
) -> Result<()>
fn knn_match( &self, query_descriptors: &impl MatTraitConst, train_descriptors: &impl MatTraitConst, matches: &mut Vector<Vector<DMatch>>, k: i32, mask: &impl MatTraitConst, compact_result: bool, ) -> Result<()>
Source§fn knn_match_def(
&self,
query_descriptors: &impl MatTraitConst,
train_descriptors: &impl MatTraitConst,
matches: &mut Vector<Vector<DMatch>>,
k: i32,
) -> Result<()>
fn knn_match_def( &self, query_descriptors: &impl MatTraitConst, train_descriptors: &impl MatTraitConst, matches: &mut Vector<Vector<DMatch>>, k: i32, ) -> Result<()>
Source§fn radius_match(
&self,
query_descriptors: &impl MatTraitConst,
train_descriptors: &impl MatTraitConst,
matches: &mut Vector<Vector<DMatch>>,
max_distance: f32,
mask: &impl MatTraitConst,
compact_result: bool,
) -> Result<()>
fn radius_match( &self, query_descriptors: &impl MatTraitConst, train_descriptors: &impl MatTraitConst, matches: &mut Vector<Vector<DMatch>>, max_distance: f32, mask: &impl MatTraitConst, compact_result: bool, ) -> Result<()>
Source§fn radius_match_def(
&self,
query_descriptors: &impl MatTraitConst,
train_descriptors: &impl MatTraitConst,
matches: &mut Vector<Vector<DMatch>>,
max_distance: f32,
) -> Result<()>
fn radius_match_def( &self, query_descriptors: &impl MatTraitConst, train_descriptors: &impl MatTraitConst, matches: &mut Vector<Vector<DMatch>>, max_distance: f32, ) -> Result<()>
Source§impl Boxed for BinaryDescriptorMatcher
impl Boxed for BinaryDescriptorMatcher
Source§unsafe fn from_raw(
ptr: <BinaryDescriptorMatcher as OpenCVFromExtern>::ExternReceive,
) -> Self
unsafe fn from_raw( ptr: <BinaryDescriptorMatcher as OpenCVFromExtern>::ExternReceive, ) -> Self
Source§fn into_raw(
self,
) -> <BinaryDescriptorMatcher as OpenCVTypeExternContainer>::ExternSendMut
fn into_raw( self, ) -> <BinaryDescriptorMatcher as OpenCVTypeExternContainer>::ExternSendMut
Source§fn as_raw(
&self,
) -> <BinaryDescriptorMatcher as OpenCVTypeExternContainer>::ExternSend
fn as_raw( &self, ) -> <BinaryDescriptorMatcher as OpenCVTypeExternContainer>::ExternSend
Source§fn as_raw_mut(
&mut self,
) -> <BinaryDescriptorMatcher as OpenCVTypeExternContainer>::ExternSendMut
fn as_raw_mut( &mut self, ) -> <BinaryDescriptorMatcher as OpenCVTypeExternContainer>::ExternSendMut
Source§impl Debug for BinaryDescriptorMatcher
impl Debug for BinaryDescriptorMatcher
Source§impl Drop for BinaryDescriptorMatcher
impl Drop for BinaryDescriptorMatcher
Source§impl From<BinaryDescriptorMatcher> for Algorithm
impl From<BinaryDescriptorMatcher> for Algorithm
Source§fn from(s: BinaryDescriptorMatcher) -> Self
fn from(s: BinaryDescriptorMatcher) -> Self
impl Send for BinaryDescriptorMatcher
Auto Trait Implementations§
impl Freeze for BinaryDescriptorMatcher
impl RefUnwindSafe for BinaryDescriptorMatcher
impl !Sync for BinaryDescriptorMatcher
impl Unpin for BinaryDescriptorMatcher
impl UnwindSafe for BinaryDescriptorMatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
impl<Mat> ModifyInplace for Matwhere
Mat: Boxed,
Source§unsafe fn modify_inplace<Res>(
&mut self,
f: impl FnOnce(&Mat, &mut Mat) -> Res,
) -> Res
unsafe fn modify_inplace<Res>( &mut self, f: impl FnOnce(&Mat, &mut Mat) -> Res, ) -> Res
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