|
|
@ -63,170 +63,315 @@ namespace cv { namespace cuda { |
|
|
|
//! @addtogroup cudafeatures2d
|
|
|
|
//! @addtogroup cudafeatures2d
|
|
|
|
//! @{
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Brute-force descriptor matcher.
|
|
|
|
//
|
|
|
|
|
|
|
|
// DescriptorMatcher
|
|
|
|
For each descriptor in the first set, this matcher finds the closest descriptor in the second set |
|
|
|
//
|
|
|
|
by trying each one. This descriptor matcher supports masking permissible matches between descriptor |
|
|
|
|
|
|
|
sets. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The class BFMatcher_CUDA has an interface similar to the class DescriptorMatcher. It has two groups |
|
|
|
/** @brief Abstract base class for matching keypoint descriptors.
|
|
|
|
of match methods: for matching descriptors of one image with another image or with an image set. |
|
|
|
|
|
|
|
Also, all functions have an alternative to save results either to the GPU memory or to the CPU |
|
|
|
|
|
|
|
memory. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@sa DescriptorMatcher, BFMatcher |
|
|
|
It has two groups of match methods: for matching descriptors of an image with another image or with |
|
|
|
|
|
|
|
an image set. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class CV_EXPORTS BFMatcher_CUDA |
|
|
|
class CV_EXPORTS DescriptorMatcher : public cv::Algorithm |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
explicit BFMatcher_CUDA(int norm = cv::NORM_L2); |
|
|
|
//
|
|
|
|
|
|
|
|
// Factories
|
|
|
|
//! Add descriptors to train descriptor collection
|
|
|
|
//
|
|
|
|
void add(const std::vector<GpuMat>& descCollection); |
|
|
|
|
|
|
|
|
|
|
|
/** @brief Brute-force descriptor matcher.
|
|
|
|
//! Get train descriptors collection
|
|
|
|
|
|
|
|
const std::vector<GpuMat>& getTrainDescriptors() const; |
|
|
|
For each descriptor in the first set, this matcher finds the closest descriptor in the second set |
|
|
|
|
|
|
|
by trying each one. This descriptor matcher supports masking permissible matches of descriptor |
|
|
|
//! Clear train descriptors collection
|
|
|
|
sets. |
|
|
|
void clear(); |
|
|
|
|
|
|
|
|
|
|
|
@param normType One of NORM_L1, NORM_L2, NORM_HAMMING. L1 and L2 norms are |
|
|
|
//! Return true if there are not train descriptors in collection
|
|
|
|
preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and |
|
|
|
bool empty() const; |
|
|
|
BRIEF). |
|
|
|
|
|
|
|
*/ |
|
|
|
//! Return true if the matcher supports mask in match methods
|
|
|
|
static Ptr<DescriptorMatcher> createBFMatcher(int norm = cv::NORM_L2); |
|
|
|
bool isMaskSupported() const; |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//! Find one best match for each query descriptor
|
|
|
|
// Utility
|
|
|
|
void matchSingle(const GpuMat& query, const GpuMat& train, |
|
|
|
//
|
|
|
|
GpuMat& trainIdx, GpuMat& distance, |
|
|
|
|
|
|
|
const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null()); |
|
|
|
/** @brief Returns true if the descriptor matcher supports masking permissible matches.
|
|
|
|
|
|
|
|
*/ |
|
|
|
//! Download trainIdx and distance and convert it to CPU vector with DMatch
|
|
|
|
virtual bool isMaskSupported() const = 0; |
|
|
|
static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector<DMatch>& matches); |
|
|
|
|
|
|
|
//! Convert trainIdx and distance to vector with DMatch
|
|
|
|
//
|
|
|
|
static void matchConvert(const Mat& trainIdx, const Mat& distance, std::vector<DMatch>& matches); |
|
|
|
// Descriptor collection
|
|
|
|
|
|
|
|
//
|
|
|
|
//! Find one best match for each query descriptor
|
|
|
|
|
|
|
|
void match(const GpuMat& query, const GpuMat& train, std::vector<DMatch>& matches, const GpuMat& mask = GpuMat()); |
|
|
|
/** @brief Adds descriptors to train a descriptor collection.
|
|
|
|
|
|
|
|
|
|
|
|
//! Make gpu collection of trains and masks in suitable format for matchCollection function
|
|
|
|
If the collection is not empty, the new descriptors are added to existing train descriptors. |
|
|
|
void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection, const std::vector<GpuMat>& masks = std::vector<GpuMat>()); |
|
|
|
|
|
|
|
|
|
|
|
@param descriptors Descriptors to add. Each descriptors[i] is a set of descriptors from the same |
|
|
|
//! Find one best match from train collection for each query descriptor
|
|
|
|
train image. |
|
|
|
void matchCollection(const GpuMat& query, const GpuMat& trainCollection, |
|
|
|
*/ |
|
|
|
GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, |
|
|
|
virtual void add(const std::vector<GpuMat>& descriptors) = 0; |
|
|
|
const GpuMat& masks = GpuMat(), Stream& stream = Stream::Null()); |
|
|
|
|
|
|
|
|
|
|
|
/** @brief Returns a constant link to the train descriptor collection.
|
|
|
|
//! Download trainIdx, imgIdx and distance and convert it to vector with DMatch
|
|
|
|
*/ |
|
|
|
static void matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, std::vector<DMatch>& matches); |
|
|
|
virtual const std::vector<GpuMat>& getTrainDescriptors() const = 0; |
|
|
|
//! Convert trainIdx, imgIdx and distance to vector with DMatch
|
|
|
|
|
|
|
|
static void matchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector<DMatch>& matches); |
|
|
|
/** @brief Clears the train descriptor collection.
|
|
|
|
|
|
|
|
*/ |
|
|
|
//! Find one best match from train collection for each query descriptor.
|
|
|
|
virtual void clear() = 0; |
|
|
|
void match(const GpuMat& query, std::vector<DMatch>& matches, const std::vector<GpuMat>& masks = std::vector<GpuMat>()); |
|
|
|
|
|
|
|
|
|
|
|
/** @brief Returns true if there are no train descriptors in the collection.
|
|
|
|
//! Find k best matches for each query descriptor (in increasing order of distances)
|
|
|
|
*/ |
|
|
|
void knnMatchSingle(const GpuMat& query, const GpuMat& train, |
|
|
|
virtual bool empty() const = 0; |
|
|
|
GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, |
|
|
|
|
|
|
|
const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null()); |
|
|
|
/** @brief Trains a descriptor matcher.
|
|
|
|
|
|
|
|
|
|
|
|
//! Download trainIdx and distance and convert it to vector with DMatch
|
|
|
|
Trains a descriptor matcher (for example, the flann index). In all methods to match, the method |
|
|
|
//! compactResult is used when mask is not empty. If compactResult is false matches
|
|
|
|
train() is run every time before matching. |
|
|
|
//! vector will have the same size as queryDescriptors rows. If compactResult is true
|
|
|
|
*/ |
|
|
|
//! matches vector will not contain matches for fully masked out query descriptors.
|
|
|
|
virtual void train() = 0; |
|
|
|
static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, |
|
|
|
|
|
|
|
std::vector< std::vector<DMatch> >& matches, bool compactResult = false); |
|
|
|
//
|
|
|
|
//! Convert trainIdx and distance to vector with DMatch
|
|
|
|
// 1 to 1 match
|
|
|
|
static void knnMatchConvert(const Mat& trainIdx, const Mat& distance, |
|
|
|
//
|
|
|
|
std::vector< std::vector<DMatch> >& matches, bool compactResult = false); |
|
|
|
|
|
|
|
|
|
|
|
/** @brief Finds the best match for each descriptor from a query set (blocking version).
|
|
|
|
//! Find k best matches for each query descriptor (in increasing order of distances).
|
|
|
|
|
|
|
|
//! compactResult is used when mask is not empty. If compactResult is false matches
|
|
|
|
@param queryDescriptors Query set of descriptors. |
|
|
|
//! vector will have the same size as queryDescriptors rows. If compactResult is true
|
|
|
|
@param trainDescriptors Train set of descriptors. This set is not added to the train descriptors |
|
|
|
//! matches vector will not contain matches for fully masked out query descriptors.
|
|
|
|
collection stored in the class object. |
|
|
|
void knnMatch(const GpuMat& query, const GpuMat& train, |
|
|
|
@param matches Matches. If a query descriptor is masked out in mask , no match is added for this |
|
|
|
std::vector< std::vector<DMatch> >& matches, int k, const GpuMat& mask = GpuMat(), |
|
|
|
descriptor. So, matches size may be smaller than the query descriptors count. |
|
|
|
bool compactResult = false); |
|
|
|
@param mask Mask specifying permissible matches between an input query and train matrices of |
|
|
|
|
|
|
|
descriptors. |
|
|
|
//! Find k best matches from train collection for each query descriptor (in increasing order of distances)
|
|
|
|
|
|
|
|
void knnMatch2Collection(const GpuMat& query, const GpuMat& trainCollection, |
|
|
|
In the first variant of this method, the train descriptors are passed as an input argument. In the |
|
|
|
GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, |
|
|
|
second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is |
|
|
|
const GpuMat& maskCollection = GpuMat(), Stream& stream = Stream::Null()); |
|
|
|
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 |
|
|
|
//! Download trainIdx and distance and convert it to vector with DMatch
|
|
|
|
mask.at\<uchar\>(i,j) is non-zero. |
|
|
|
//! compactResult is used when mask is not empty. If compactResult is false matches
|
|
|
|
*/ |
|
|
|
//! vector will have the same size as queryDescriptors rows. If compactResult is true
|
|
|
|
virtual void match(InputArray queryDescriptors, InputArray trainDescriptors, |
|
|
|
//! matches vector will not contain matches for fully masked out query descriptors.
|
|
|
|
std::vector<DMatch>& matches, |
|
|
|
//! @see BFMatcher_CUDA::knnMatchDownload
|
|
|
|
InputArray mask = noArray()) = 0; |
|
|
|
static void knnMatch2Download(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, |
|
|
|
|
|
|
|
std::vector< std::vector<DMatch> >& matches, bool compactResult = false); |
|
|
|
/** @overload
|
|
|
|
//! Convert trainIdx and distance to vector with DMatch
|
|
|
|
*/ |
|
|
|
//! @see BFMatcher_CUDA::knnMatchConvert
|
|
|
|
virtual void match(InputArray queryDescriptors, |
|
|
|
static void knnMatch2Convert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, |
|
|
|
std::vector<DMatch>& matches, |
|
|
|
std::vector< std::vector<DMatch> >& matches, bool compactResult = false); |
|
|
|
const std::vector<GpuMat>& masks = std::vector<GpuMat>()) = 0; |
|
|
|
|
|
|
|
|
|
|
|
//! Find k best matches for each query descriptor (in increasing order of distances).
|
|
|
|
/** @brief Finds the best match for each descriptor from a query set (asynchronous version).
|
|
|
|
//! compactResult is used when mask is not empty. If compactResult is false matches
|
|
|
|
|
|
|
|
//! vector will have the same size as queryDescriptors rows. If compactResult is true
|
|
|
|
@param queryDescriptors Query set of descriptors. |
|
|
|
//! matches vector will not contain matches for fully masked out query descriptors.
|
|
|
|
@param trainDescriptors Train set of descriptors. This set is not added to the train descriptors |
|
|
|
void knnMatch(const GpuMat& query, std::vector< std::vector<DMatch> >& matches, int k, |
|
|
|
collection stored in the class object. |
|
|
|
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false); |
|
|
|
@param matches Matches array stored in GPU memory. Internal representation is not defined. |
|
|
|
|
|
|
|
Use DescriptorMatcher::matchConvert method to retrieve results in standard representation. |
|
|
|
//! Find best matches for each query descriptor which have distance less than maxDistance.
|
|
|
|
@param mask Mask specifying permissible matches between an input query and train matrices of |
|
|
|
//! nMatches.at<int>(0, queryIdx) will contain matches count for queryIdx.
|
|
|
|
descriptors. |
|
|
|
//! carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches,
|
|
|
|
@param stream CUDA stream. |
|
|
|
//! because it didn't have enough memory.
|
|
|
|
|
|
|
|
//! If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nTrain / 100), 10),
|
|
|
|
In the first variant of this method, the train descriptors are passed as an input argument. In the |
|
|
|
//! otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
|
|
|
|
second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is |
|
|
|
//! Matches doesn't sorted.
|
|
|
|
used. Optional mask (or masks) can be passed to specify which query and training descriptors can be |
|
|
|
void radiusMatchSingle(const GpuMat& query, const GpuMat& train, |
|
|
|
matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if |
|
|
|
GpuMat& trainIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance, |
|
|
|
mask.at\<uchar\>(i,j) is non-zero. |
|
|
|
const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null()); |
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void matchAsync(InputArray queryDescriptors, InputArray trainDescriptors, |
|
|
|
//! Download trainIdx, nMatches and distance and convert it to vector with DMatch.
|
|
|
|
OutputArray matches, |
|
|
|
//! matches will be sorted in increasing order of distances.
|
|
|
|
InputArray mask = noArray(), |
|
|
|
//! compactResult is used when mask is not empty. If compactResult is false matches
|
|
|
|
Stream& stream = Stream::Null()) = 0; |
|
|
|
//! vector will have the same size as queryDescriptors rows. If compactResult is true
|
|
|
|
|
|
|
|
//! matches vector will not contain matches for fully masked out query descriptors.
|
|
|
|
/** @overload
|
|
|
|
static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, const GpuMat& nMatches, |
|
|
|
*/ |
|
|
|
std::vector< std::vector<DMatch> >& matches, bool compactResult = false); |
|
|
|
virtual void matchAsync(InputArray queryDescriptors, |
|
|
|
//! Convert trainIdx, nMatches and distance to vector with DMatch.
|
|
|
|
OutputArray matches, |
|
|
|
static void radiusMatchConvert(const Mat& trainIdx, const Mat& distance, const Mat& nMatches, |
|
|
|
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), |
|
|
|
std::vector< std::vector<DMatch> >& matches, bool compactResult = false); |
|
|
|
Stream& stream = Stream::Null()) = 0; |
|
|
|
|
|
|
|
|
|
|
|
//! Find best matches for each query descriptor which have distance less than maxDistance
|
|
|
|
/** @brief Converts matches array from internal representation to standard matches vector.
|
|
|
|
//! in increasing order of distances).
|
|
|
|
|
|
|
|
void radiusMatch(const GpuMat& query, const GpuMat& train, |
|
|
|
The method is supposed to be used with DescriptorMatcher::matchAsync to get final result. |
|
|
|
std::vector< std::vector<DMatch> >& matches, float maxDistance, |
|
|
|
Call this method only after DescriptorMatcher::matchAsync is completed (ie. after synchronization). |
|
|
|
const GpuMat& mask = GpuMat(), bool compactResult = false); |
|
|
|
|
|
|
|
|
|
|
|
@param gpu_matches Matches, returned from DescriptorMatcher::matchAsync. |
|
|
|
//! Find best matches for each query descriptor which have distance less than maxDistance.
|
|
|
|
@param matches Vector of DMatch objects. |
|
|
|
//! If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nQuery / 100), 10),
|
|
|
|
*/ |
|
|
|
//! otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches
|
|
|
|
virtual void matchConvert(InputArray gpu_matches, |
|
|
|
//! Matches doesn't sorted.
|
|
|
|
std::vector<DMatch>& matches) = 0; |
|
|
|
void radiusMatchCollection(const GpuMat& query, GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance, |
|
|
|
|
|
|
|
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), Stream& stream = Stream::Null()); |
|
|
|
//
|
|
|
|
|
|
|
|
// knn match
|
|
|
|
//! Download trainIdx, imgIdx, nMatches and distance and convert it to vector with DMatch.
|
|
|
|
//
|
|
|
|
//! matches will be sorted in increasing order of distances.
|
|
|
|
|
|
|
|
//! compactResult is used when mask is not empty. If compactResult is false matches
|
|
|
|
/** @brief Finds the k best matches for each descriptor from a query set (blocking version).
|
|
|
|
//! vector will have the same size as queryDescriptors rows. If compactResult is true
|
|
|
|
|
|
|
|
//! matches vector will not contain matches for fully masked out query descriptors.
|
|
|
|
@param queryDescriptors Query set of descriptors. |
|
|
|
static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, const GpuMat& nMatches, |
|
|
|
@param trainDescriptors Train set of descriptors. This set is not added to the train descriptors |
|
|
|
std::vector< std::vector<DMatch> >& matches, bool compactResult = false); |
|
|
|
collection stored in the class object. |
|
|
|
//! Convert trainIdx, nMatches and distance to vector with DMatch.
|
|
|
|
@param matches Matches. Each matches[i] is k or less matches for the same query descriptor. |
|
|
|
static void radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches, |
|
|
|
@param k Count of best matches found per each query descriptor or less if a query descriptor has |
|
|
|
std::vector< std::vector<DMatch> >& matches, bool compactResult = false); |
|
|
|
less than k possible matches in total. |
|
|
|
|
|
|
|
@param mask Mask specifying permissible matches between an input query and train matrices of |
|
|
|
//! Find best matches from train collection for each query descriptor which have distance less than
|
|
|
|
descriptors. |
|
|
|
//! maxDistance (in increasing order of distances).
|
|
|
|
@param compactResult Parameter used when the mask (or masks) is not empty. If compactResult is |
|
|
|
void radiusMatch(const GpuMat& query, std::vector< std::vector<DMatch> >& matches, float maxDistance, |
|
|
|
false, the matches vector has the same size as queryDescriptors rows. If compactResult is true, |
|
|
|
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false); |
|
|
|
the matches vector does not contain matches for fully masked-out query descriptors. |
|
|
|
|
|
|
|
|
|
|
|
int norm; |
|
|
|
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 |
|
|
|
private: |
|
|
|
for the details about query and train descriptors. |
|
|
|
std::vector<GpuMat> trainDescCollection; |
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void knnMatch(InputArray queryDescriptors, InputArray trainDescriptors, |
|
|
|
|
|
|
|
std::vector<std::vector<DMatch> >& matches, |
|
|
|
|
|
|
|
int k, |
|
|
|
|
|
|
|
InputArray mask = noArray(), |
|
|
|
|
|
|
|
bool compactResult = false) = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @overload
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void knnMatch(InputArray queryDescriptors, |
|
|
|
|
|
|
|
std::vector<std::vector<DMatch> >& matches, |
|
|
|
|
|
|
|
int k, |
|
|
|
|
|
|
|
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), |
|
|
|
|
|
|
|
bool compactResult = false) = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Finds the k best matches for each descriptor from a query set (asynchronous version).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param queryDescriptors Query set of descriptors. |
|
|
|
|
|
|
|
@param trainDescriptors Train set of descriptors. This set is not added to the train descriptors |
|
|
|
|
|
|
|
collection stored in the class object. |
|
|
|
|
|
|
|
@param matches Matches array stored in GPU memory. Internal representation is not defined. |
|
|
|
|
|
|
|
Use DescriptorMatcher::knnMatchConvert method to retrieve results in standard representation. |
|
|
|
|
|
|
|
@param k Count of best matches found per each query descriptor or less if a query descriptor has |
|
|
|
|
|
|
|
less than k possible matches in total. |
|
|
|
|
|
|
|
@param mask Mask specifying permissible matches between an input query and train matrices of |
|
|
|
|
|
|
|
descriptors. |
|
|
|
|
|
|
|
@param compactResult 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. |
|
|
|
|
|
|
|
@param stream CUDA stream. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
These extended variants of DescriptorMatcher::matchAsync methods find several best matches for each query |
|
|
|
|
|
|
|
descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::matchAsync |
|
|
|
|
|
|
|
for the details about query and train descriptors. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void knnMatchAsync(InputArray queryDescriptors, InputArray trainDescriptors, |
|
|
|
|
|
|
|
OutputArray matches, |
|
|
|
|
|
|
|
int k, |
|
|
|
|
|
|
|
InputArray mask = noArray(), |
|
|
|
|
|
|
|
Stream& stream = Stream::Null()) = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @overload
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void knnMatchAsync(InputArray queryDescriptors, |
|
|
|
|
|
|
|
OutputArray matches, |
|
|
|
|
|
|
|
int k, |
|
|
|
|
|
|
|
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), |
|
|
|
|
|
|
|
Stream& stream = Stream::Null()) = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Converts matches array from internal representation to standard matches vector.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The method is supposed to be used with DescriptorMatcher::knnMatchAsync to get final result. |
|
|
|
|
|
|
|
Call this method only after DescriptorMatcher::knnMatchAsync is completed (ie. after synchronization). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param gpu_matches Matches, returned from DescriptorMatcher::knnMatchAsync. |
|
|
|
|
|
|
|
@param matches Vector of DMatch objects. |
|
|
|
|
|
|
|
@param compactResult 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. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void knnMatchConvert(InputArray gpu_matches, |
|
|
|
|
|
|
|
std::vector< std::vector<DMatch> >& matches, |
|
|
|
|
|
|
|
bool compactResult = false) = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// radius match
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief For each query descriptor, finds the training descriptors not farther than the specified distance (blocking version).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param queryDescriptors Query set of descriptors. |
|
|
|
|
|
|
|
@param trainDescriptors Train set of descriptors. This set is not added to the train descriptors |
|
|
|
|
|
|
|
collection stored in the class object. |
|
|
|
|
|
|
|
@param matches Found matches. |
|
|
|
|
|
|
|
@param maxDistance 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)! |
|
|
|
|
|
|
|
@param mask Mask specifying permissible matches between an input query and train matrices of |
|
|
|
|
|
|
|
descriptors. |
|
|
|
|
|
|
|
@param compactResult 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. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void radiusMatch(InputArray queryDescriptors, InputArray trainDescriptors, |
|
|
|
|
|
|
|
std::vector<std::vector<DMatch> >& matches, |
|
|
|
|
|
|
|
float maxDistance, |
|
|
|
|
|
|
|
InputArray mask = noArray(), |
|
|
|
|
|
|
|
bool compactResult = false) = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @overload
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void radiusMatch(InputArray queryDescriptors, |
|
|
|
|
|
|
|
std::vector<std::vector<DMatch> >& matches, |
|
|
|
|
|
|
|
float maxDistance, |
|
|
|
|
|
|
|
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), |
|
|
|
|
|
|
|
bool compactResult = false) = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief For each query descriptor, finds the training descriptors not farther than the specified distance (asynchronous version).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param queryDescriptors Query set of descriptors. |
|
|
|
|
|
|
|
@param trainDescriptors Train set of descriptors. This set is not added to the train descriptors |
|
|
|
|
|
|
|
collection stored in the class object. |
|
|
|
|
|
|
|
@param matches Matches array stored in GPU memory. Internal representation is not defined. |
|
|
|
|
|
|
|
Use DescriptorMatcher::radiusMatchConvert method to retrieve results in standard representation. |
|
|
|
|
|
|
|
@param maxDistance 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)! |
|
|
|
|
|
|
|
@param mask Mask specifying permissible matches between an input query and train matrices of |
|
|
|
|
|
|
|
descriptors. |
|
|
|
|
|
|
|
@param compactResult 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. |
|
|
|
|
|
|
|
@param stream CUDA stream. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void radiusMatchAsync(InputArray queryDescriptors, InputArray trainDescriptors, |
|
|
|
|
|
|
|
OutputArray matches, |
|
|
|
|
|
|
|
float maxDistance, |
|
|
|
|
|
|
|
InputArray mask = noArray(), |
|
|
|
|
|
|
|
Stream& stream = Stream::Null()) = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @overload
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void radiusMatchAsync(InputArray queryDescriptors, |
|
|
|
|
|
|
|
OutputArray matches, |
|
|
|
|
|
|
|
float maxDistance, |
|
|
|
|
|
|
|
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), |
|
|
|
|
|
|
|
Stream& stream = Stream::Null()) = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Converts matches array from internal representation to standard matches vector.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The method is supposed to be used with DescriptorMatcher::radiusMatchAsync to get final result. |
|
|
|
|
|
|
|
Call this method only after DescriptorMatcher::radiusMatchAsync is completed (ie. after synchronization). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@param gpu_matches Matches, returned from DescriptorMatcher::radiusMatchAsync. |
|
|
|
|
|
|
|
@param matches Vector of DMatch objects. |
|
|
|
|
|
|
|
@param compactResult 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. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
virtual void radiusMatchConvert(InputArray gpu_matches, |
|
|
|
|
|
|
|
std::vector< std::vector<DMatch> >& matches, |
|
|
|
|
|
|
|
bool compactResult = false) = 0; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|