View Source Evision.BFMatcher (Evision v0.1.21)

Link to this section Summary

Types

t()

Type that represents an Evision.BFMatcher struct.

Functions

Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor collection.

Brute-force matcher constructor (obsolete). Please use BFMatcher.create()

Brute-force matcher constructor (obsolete). Please use BFMatcher.create()

Clears the train descriptor collections.

Clones the matcher.

Clones the matcher.

Brute-force matcher create method.

Brute-force matcher create method.

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

getDefaultName

Returns a constant link to the train descriptor collection trainDescCollection .

Returns true if the descriptor matcher supports masking permissible matches.

Variant 1:

Finds the k best matches for each descriptor from a query set.

Finds the k best matches for each descriptor from a query set.

Variant 1:

Finds the best match for each descriptor from a query set.

Finds the best match for each descriptor from a query set.

Variant 1:

For each query descriptor, finds the training descriptors not farther than the specified distance.

For each query descriptor, finds the training descriptors not farther than the specified distance.

Variant 1:

read

Trains a descriptor matcher

Variant 1:

write

Link to this section Types

@type t() :: %Evision.BFMatcher{ref: reference()}

Type that represents an Evision.BFMatcher struct.

  • ref. reference()

    The underlying erlang resource variable.

Link to this section Functions

@spec add(t(), [Evision.Mat.maybe_mat_in()]) :: :ok | {:error, String.t()}

Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor collection.

Positional Arguments
  • self: Evision.BFMatcher.t()

  • descriptors: [Evision.Mat].

    Descriptors to add. Each descriptors[i] is a set of descriptors from the same train image.

If the collection is not empty, the new descriptors are added to existing train descriptors.

Python prototype (for reference only):

add(descriptors) -> None
@spec bfMatcher() :: t() | {:error, String.t()}

Brute-force matcher constructor (obsolete). Please use BFMatcher.create()

Keyword Arguments
  • normType: int.
  • crossCheck: bool.
Return

Python prototype (for reference only):

BFMatcher([, normType[, crossCheck]]) -> <BFMatcher object>
@spec bfMatcher([{atom(), term()}, ...] | nil) :: t() | {:error, String.t()}

Brute-force matcher constructor (obsolete). Please use BFMatcher.create()

Keyword Arguments
  • normType: int.
  • crossCheck: bool.
Return

Python prototype (for reference only):

BFMatcher([, normType[, crossCheck]]) -> <BFMatcher object>
@spec clear(t()) :: :ok | {:error, String.t()}

Clears the train descriptor collections.

Positional Arguments
  • self: Evision.BFMatcher.t()

Python prototype (for reference only):

clear() -> None
@spec clone(t()) :: Evision.DescriptorMatcher.t() | {:error, String.t()}

Clones the matcher.

Positional Arguments
  • self: Evision.BFMatcher.t()
Keyword Arguments
  • emptyTrainData: bool.

    If emptyTrainData is false, the method creates a deep copy of the object, that is, copies both parameters and train data. If emptyTrainData is true, the method creates an object copy with the current parameters but with empty train data.

Return

Python prototype (for reference only):

clone([, emptyTrainData]) -> retval
@spec clone(t(), [{atom(), term()}, ...] | nil) ::
  Evision.DescriptorMatcher.t() | {:error, String.t()}

Clones the matcher.

Positional Arguments
  • self: Evision.BFMatcher.t()
Keyword Arguments
  • emptyTrainData: bool.

    If emptyTrainData is false, the method creates a deep copy of the object, that is, copies both parameters and train data. If emptyTrainData is true, the method creates an object copy with the current parameters but with empty train data.

Return

Python prototype (for reference only):

clone([, emptyTrainData]) -> retval
@spec create() :: t() | {:error, String.t()}

Brute-force matcher create method.

Keyword Arguments
  • normType: int.

    One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor description).

  • crossCheck: bool.

    If it is false, this is will be default BFMatcher behaviour when it finds the k nearest neighbors for each query descriptor. If crossCheck==true, then the knnMatch() method with k=1 will only return pairs (i,j) such that for i-th query descriptor the j-th descriptor in the matcher's collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent pairs. Such technique usually produces best results with minimal number of outliers when there are enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.

Return

Python prototype (for reference only):

create([, normType[, crossCheck]]) -> retval
@spec create([{atom(), term()}, ...] | nil) :: t() | {:error, String.t()}

Brute-force matcher create method.

Keyword Arguments
  • normType: int.

    One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor description).

  • crossCheck: bool.

    If it is false, this is will be default BFMatcher behaviour when it finds the k nearest neighbors for each query descriptor. If crossCheck==true, then the knnMatch() method with k=1 will only return pairs (i,j) such that for i-th query descriptor the j-th descriptor in the matcher's collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent pairs. Such technique usually produces best results with minimal number of outliers when there are enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.

Return

Python prototype (for reference only):

create([, normType[, crossCheck]]) -> retval
@spec empty(t()) :: boolean() | {:error, String.t()}

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

Positional Arguments
  • self: Evision.BFMatcher.t()
Return
  • retval: bool

Python prototype (for reference only):

empty() -> retval
@spec getDefaultName(t()) :: binary() | {:error, String.t()}

getDefaultName

Positional Arguments
  • self: Evision.BFMatcher.t()
Return

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.

Python prototype (for reference only):

getDefaultName() -> retval
Link to this function

getTrainDescriptors(self)

View Source
@spec getTrainDescriptors(t()) :: [Evision.Mat.t()] | {:error, String.t()}

Returns a constant link to the train descriptor collection trainDescCollection .

Positional Arguments
  • self: Evision.BFMatcher.t()
Return
  • retval: std::vector<Mat>

Python prototype (for reference only):

getTrainDescriptors() -> retval
@spec isMaskSupported(t()) :: boolean() | {:error, String.t()}

Returns true if the descriptor matcher supports masking permissible matches.

Positional Arguments
  • self: Evision.BFMatcher.t()
Return
  • retval: bool

Python prototype (for reference only):

isMaskSupported() -> retval
Link to this function

knnMatch(self, queryDescriptors, k)

View Source
@spec knnMatch(t(), Evision.Mat.maybe_mat_in(), integer()) ::
  [[Evision.DMatch.t()]] | {:error, String.t()}

knnMatch

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • k: int.

    Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.

Keyword Arguments
  • masks: [Evision.Mat].

    Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].

  • compactResult: bool.

    Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.

Return
  • matches: [[Evision.DMatch]].

    Matches. Each matches[i] is k or less matches for the same query descriptor.

Has overloading in C++

Python prototype (for reference only):

knnMatch(queryDescriptors, k[, masks[, compactResult]]) -> matches
Link to this function

knnMatch(self, queryDescriptors, k, opts)

View Source
@spec knnMatch(
  t(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) ::
  [[Evision.DMatch.t()]] | {:error, String.t()}
@spec knnMatch(t(), Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in(), integer()) ::
  [[Evision.DMatch.t()]] | {:error, String.t()}

Variant 1:

Finds the k best matches for each descriptor from a query set.

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • trainDescriptors: Evision.Mat.

    Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.

  • k: int.

    Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.

Keyword Arguments
  • mask: Evision.Mat.

    Mask specifying permissible matches between an input query and train matrices of descriptors.

  • compactResult: bool.

    Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.

Return
  • matches: [[Evision.DMatch]].

    Matches. Each matches[i] is k or less matches for the same query descriptor.

These extended variants of DescriptorMatcher::match methods find several best matches for each query descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::match for the details about query and train descriptors.

Python prototype (for reference only):

knnMatch(queryDescriptors, trainDescriptors, k[, mask[, compactResult]]) -> matches

Variant 2:

knnMatch

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • k: int.

    Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.

Keyword Arguments
  • masks: [Evision.Mat].

    Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].

  • compactResult: bool.

    Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.

Return
  • matches: [[Evision.DMatch]].

    Matches. Each matches[i] is k or less matches for the same query descriptor.

Has overloading in C++

Python prototype (for reference only):

knnMatch(queryDescriptors, k[, masks[, compactResult]]) -> matches
Link to this function

knnMatch(self, queryDescriptors, trainDescriptors, k, opts)

View Source
@spec knnMatch(
  t(),
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: [[Evision.DMatch.t()]] | {:error, String.t()}

Finds the k best matches for each descriptor from a query set.

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • trainDescriptors: Evision.Mat.

    Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.

  • k: int.

    Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.

Keyword Arguments
  • mask: Evision.Mat.

    Mask specifying permissible matches between an input query and train matrices of descriptors.

  • compactResult: bool.

    Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.

Return
  • matches: [[Evision.DMatch]].

    Matches. Each matches[i] is k or less matches for the same query descriptor.

These extended variants of DescriptorMatcher::match methods find several best matches for each query descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::match for the details about query and train descriptors.

Python prototype (for reference only):

knnMatch(queryDescriptors, trainDescriptors, k[, mask[, compactResult]]) -> matches
Link to this function

match(self, queryDescriptors)

View Source
@spec match(t(), Evision.Mat.maybe_mat_in()) ::
  [Evision.DMatch.t()] | {:error, String.t()}

match

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

Keyword Arguments
  • masks: [Evision.Mat].

    Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].

Return
  • matches: [Evision.DMatch].

    Matches. If a query descriptor is masked out in mask , no match is added for this descriptor. So, matches size may be smaller than the query descriptors count.

Has overloading in C++

Python prototype (for reference only):

match(queryDescriptors[, masks]) -> matches
Link to this function

match(self, queryDescriptors, opts)

View Source
@spec match(t(), Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  [Evision.DMatch.t()] | {:error, String.t()}
@spec match(t(), Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  [Evision.DMatch.t()] | {:error, String.t()}

Variant 1:

Finds the best match for each descriptor from a query set.

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • trainDescriptors: Evision.Mat.

    Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.

Keyword Arguments
  • mask: Evision.Mat.

    Mask specifying permissible matches between an input query and train matrices of descriptors.

Return
  • matches: [Evision.DMatch].

    Matches. If a query descriptor is masked out in mask , no match is added for this descriptor. So, matches size may be smaller than the query descriptors count.

In the first variant of this method, the train descriptors are passed as an input argument. In the second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is used. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if mask.at\<uchar>(i,j) is non-zero.

Python prototype (for reference only):

match(queryDescriptors, trainDescriptors[, mask]) -> matches

Variant 2:

match

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

Keyword Arguments
  • masks: [Evision.Mat].

    Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].

Return
  • matches: [Evision.DMatch].

    Matches. If a query descriptor is masked out in mask , no match is added for this descriptor. So, matches size may be smaller than the query descriptors count.

Has overloading in C++

Python prototype (for reference only):

match(queryDescriptors[, masks]) -> matches
Link to this function

match(self, queryDescriptors, trainDescriptors, opts)

View Source
@spec match(
  t(),
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  [Evision.DMatch.t()] | {:error, String.t()}

Finds the best match for each descriptor from a query set.

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • trainDescriptors: Evision.Mat.

    Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.

Keyword Arguments
  • mask: Evision.Mat.

    Mask specifying permissible matches between an input query and train matrices of descriptors.

Return
  • matches: [Evision.DMatch].

    Matches. If a query descriptor is masked out in mask , no match is added for this descriptor. So, matches size may be smaller than the query descriptors count.

In the first variant of this method, the train descriptors are passed as an input argument. In the second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is used. Optional mask (or masks) can be passed to specify which query and training descriptors can be matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if mask.at\<uchar>(i,j) is non-zero.

Python prototype (for reference only):

match(queryDescriptors, trainDescriptors[, mask]) -> matches
Link to this function

radiusMatch(self, queryDescriptors, maxDistance)

View Source
@spec radiusMatch(t(), Evision.Mat.maybe_mat_in(), number()) ::
  [[Evision.DMatch.t()]] | {:error, String.t()}

radiusMatch

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • maxDistance: float.

    Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)!

Keyword Arguments
  • masks: [Evision.Mat].

    Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].

  • compactResult: bool.

    Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.

Return
  • matches: [[Evision.DMatch]].

    Found matches.

Has overloading in C++

Python prototype (for reference only):

radiusMatch(queryDescriptors, maxDistance[, masks[, compactResult]]) -> matches
Link to this function

radiusMatch(self, queryDescriptors, maxDistance, opts)

View Source
@spec radiusMatch(
  t(),
  Evision.Mat.maybe_mat_in(),
  number(),
  [{atom(), term()}, ...] | nil
) ::
  [[Evision.DMatch.t()]] | {:error, String.t()}
@spec radiusMatch(
  t(),
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  number()
) ::
  [[Evision.DMatch.t()]] | {:error, String.t()}

Variant 1:

For each query descriptor, finds the training descriptors not farther than the specified distance.

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • trainDescriptors: Evision.Mat.

    Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.

  • maxDistance: float.

    Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)!

Keyword Arguments
  • mask: Evision.Mat.

    Mask specifying permissible matches between an input query and train matrices of descriptors.

  • compactResult: bool.

    Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.

Return
  • matches: [[Evision.DMatch]].

    Found matches.

For each query descriptor, the methods find such training descriptors that the distance between the query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are returned in the distance increasing order.

Python prototype (for reference only):

radiusMatch(queryDescriptors, trainDescriptors, maxDistance[, mask[, compactResult]]) -> matches

Variant 2:

radiusMatch

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • maxDistance: float.

    Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)!

Keyword Arguments
  • masks: [Evision.Mat].

    Set of masks. Each masks[i] specifies permissible matches between the input query descriptors and stored train descriptors from the i-th image trainDescCollection[i].

  • compactResult: bool.

    Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.

Return
  • matches: [[Evision.DMatch]].

    Found matches.

Has overloading in C++

Python prototype (for reference only):

radiusMatch(queryDescriptors, maxDistance[, masks[, compactResult]]) -> matches
Link to this function

radiusMatch(self, queryDescriptors, trainDescriptors, maxDistance, opts)

View Source
@spec radiusMatch(
  t(),
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  number(),
  [{atom(), term()}, ...] | nil
) :: [[Evision.DMatch.t()]] | {:error, String.t()}

For each query descriptor, finds the training descriptors not farther than the specified distance.

Positional Arguments
  • self: Evision.BFMatcher.t()

  • queryDescriptors: Evision.Mat.

    Query set of descriptors.

  • trainDescriptors: Evision.Mat.

    Train set of descriptors. This set is not added to the train descriptors collection stored in the class object.

  • maxDistance: float.

    Threshold for the distance between matched descriptors. Distance means here metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured in Pixels)!

Keyword Arguments
  • mask: Evision.Mat.

    Mask specifying permissible matches between an input query and train matrices of descriptors.

  • compactResult: bool.

    Parameter used when the mask (or masks) is not empty. If compactResult is false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, the matches vector does not contain matches for fully masked-out query descriptors.

Return
  • matches: [[Evision.DMatch]].

    Found matches.

For each query descriptor, the methods find such training descriptors that the distance between the query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are returned in the distance increasing order.

Python prototype (for reference only):

radiusMatch(queryDescriptors, trainDescriptors, maxDistance[, mask[, compactResult]]) -> matches
@spec read(t(), Evision.FileNode.t()) :: :ok | {:error, String.t()}
@spec read(t(), binary()) :: :ok | {:error, String.t()}

Variant 1:

read

Positional Arguments

Python prototype (for reference only):

read(arg1) -> None

Variant 2:

read

Positional Arguments
  • self: Evision.BFMatcher.t()
  • fileName: String

Python prototype (for reference only):

read(fileName) -> None
@spec save(t(), binary()) :: :ok | {:error, String.t()}

save

Positional Arguments
  • self: Evision.BFMatcher.t()
  • filename: String

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

Python prototype (for reference only):

save(filename) -> None
@spec train(t()) :: :ok | {:error, String.t()}

Trains a descriptor matcher

Positional Arguments
  • self: Evision.BFMatcher.t()

Trains a descriptor matcher (for example, the flann index). In all methods to match, the method train() is run every time before matching. Some descriptor matchers (for example, BruteForceMatcher) have an empty implementation of this method. Other matchers really train their inner structures (for example, FlannBasedMatcher trains flann::Index ).

Python prototype (for reference only):

train() -> None
@spec write(t(), Evision.FileStorage.t()) :: :ok | {:error, String.t()}
@spec write(t(), binary()) :: :ok | {:error, String.t()}

Variant 1:

write

Positional Arguments
Keyword Arguments

Python prototype (for reference only):

write(fs[, name]) -> None

Variant 2:

write

Positional Arguments
  • self: Evision.BFMatcher.t()
  • fileName: String

Python prototype (for reference only):

write(fileName) -> None
@spec write(t(), Evision.FileStorage.t(), [{atom(), term()}, ...] | nil) ::
  :ok | {:error, String.t()}

write

Positional Arguments
Keyword Arguments

Python prototype (for reference only):

write(fs[, name]) -> None