2011-02-22 21:43:26 +01:00
Feature Detection and Description
=================================
.. highlight :: cpp
2011-07-22 14:50:49 +02:00
2011-02-22 21:43:26 +01:00
gpu::SURF_GPU
-------------
2011-06-16 14:48:23 +02:00
.. ocv:class :: gpu::SURF_GPU
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
Class used for extracting Speeded Up Robust Features (SURF) from an image. ::
2011-02-22 21:43:26 +01:00
2012-04-03 08:49:13 +02:00
class SURF_GPU
2011-02-26 12:05:10 +01:00
{
public:
2011-08-30 10:27:23 +02:00
enum KeypointLayout
2011-05-23 09:59:20 +02:00
{
2012-04-03 08:49:13 +02:00
X_ROW = 0,
Y_ROW,
LAPLACIAN_ROW,
OCTAVE_ROW,
SIZE_ROW,
ANGLE_ROW,
HESSIAN_ROW,
ROWS_COUNT
2011-05-23 09:59:20 +02:00
};
2011-03-14 08:04:41 +01:00
//! the default constructor
SURF_GPU();
//! the full constructor taking all the necessary parameters
explicit SURF_GPU(double _hessianThreshold, int _nOctaves=4,
2011-03-29 01:05:42 +02:00
int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f);
2011-03-14 08:04:41 +01:00
2011-02-26 12:05:10 +01:00
//! returns the descriptor size in float's (64 or 128)
int descriptorSize() const;
//! upload host keypoints to device memory
2011-03-14 08:04:41 +01:00
void uploadKeypoints(const vector<KeyPoint>& keypoints,
2011-02-26 12:05:10 +01:00
GpuMat& keypointsGPU);
//! download keypoints from device to host memory
2011-03-14 08:04:41 +01:00
void downloadKeypoints(const GpuMat& keypointsGPU,
2011-02-26 12:05:10 +01:00
vector<KeyPoint>& keypoints);
//! download descriptors from device to host memory
2011-03-14 08:04:41 +01:00
void downloadDescriptors(const GpuMat& descriptorsGPU,
2011-02-26 12:05:10 +01:00
vector<float>& descriptors);
void operator()(const GpuMat& img, const GpuMat& mask,
GpuMat& keypoints);
void operator()(const GpuMat& img, const GpuMat& mask,
GpuMat& keypoints, GpuMat& descriptors,
bool useProvidedKeypoints = false,
bool calcOrientation = true);
void operator()(const GpuMat& img, const GpuMat& mask,
std::vector<KeyPoint>& keypoints);
void operator()(const GpuMat& img, const GpuMat& mask,
std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
bool useProvidedKeypoints = false,
bool calcOrientation = true);
void operator()(const GpuMat& img, const GpuMat& mask,
std::vector<KeyPoint>& keypoints,
std::vector<float>& descriptors,
bool useProvidedKeypoints = false,
bool calcOrientation = true);
2011-08-30 10:27:23 +02:00
void releaseMemory();
2012-04-03 08:49:13 +02:00
// SURF parameters
double hessianThreshold;
int nOctaves;
int nOctaveLayers;
bool extended;
bool upright;
2011-03-14 08:04:41 +01:00
//! max keypoints = keypointsRatio * img.size().area()
float keypointsRatio;
GpuMat sum, mask1, maskSum, intBuffer;
2011-02-26 12:05:10 +01:00
2011-03-14 08:04:41 +01:00
GpuMat det, trace;
2011-02-26 12:05:10 +01:00
GpuMat maxPosBuffer;
};
2011-02-28 22:26:43 +01:00
2011-02-22 21:43:26 +01:00
2011-06-19 22:28:08 +02:00
The class `` SURF_GPU `` implements Speeded Up Robust Features descriptor. There is a fast multi-scale Hessian keypoint detector that can be used to find the keypoints (which is the default option). But the descriptors can also be computed for the user-specified keypoints. Only 8-bit grayscale images are supported.
2011-02-26 12:05:10 +01:00
2012-04-03 08:49:13 +02:00
The class `` SURF_GPU `` can store results in the GPU and CPU memory. It provides functions to convert results between CPU and GPU version ( `` uploadKeypoints `` , `` downloadKeypoints `` , `` downloadDescriptors `` ). The format of CPU results is the same as `` SURF `` results. GPU results are stored in `` GpuMat `` . The `` keypoints `` matrix is :math: `\texttt{nFeatures} \times 7` matrix with the `` CV_32FC1 `` type.
2011-06-19 22:28:08 +02:00
2012-04-03 08:49:13 +02:00
* `` keypoints.ptr<float>(X_ROW)[i] `` contains x coordinate of the i-th feature.
* `` keypoints.ptr<float>(Y_ROW)[i] `` contains y coordinate of the i-th feature.
* `` keypoints.ptr<float>(LAPLACIAN_ROW)[i] `` contains the laplacian sign of the i-th feature.
* `` keypoints.ptr<float>(OCTAVE_ROW)[i] `` contains the octave of the i-th feature.
* `` keypoints.ptr<float>(SIZE_ROW)[i] `` contains the size of the i-th feature.
* `` keypoints.ptr<float>(ANGLE_ROW)[i] `` contain orientation of the i-th feature.
* `` keypoints.ptr<float>(HESSIAN_ROW)[i] `` contains the response of the i-th feature.
2011-06-19 22:28:08 +02:00
The `` descriptors `` matrix is :math: `\texttt{nFeatures} \times \texttt{descriptorSize}` matrix with the `` CV_32FC1 `` type.
2011-03-23 11:56:20 +01:00
2011-03-29 01:05:42 +02:00
The class `` SURF_GPU `` uses some buffers and provides access to it. All buffers can be safely released between function calls.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:class: `SURF`
2011-02-22 21:43:26 +01:00
2011-07-22 14:50:49 +02:00
2011-02-22 21:43:26 +01:00
2012-01-11 08:40:04 +01:00
gpu::FAST_GPU
-------------
.. ocv:class :: gpu::FAST_GPU
Class used for corner detection using the FAST algorithm. ::
class FAST_GPU
{
public:
enum
{
LOCATION_ROW = 0,
RESPONSE_ROW,
ROWS_COUNT
};
// all features have same size
static const int FEATURE_SIZE = 7;
2012-04-03 08:49:13 +02:00
explicit FAST_GPU(int threshold, bool nonmaxSupression = true,
2012-01-11 08:40:04 +01:00
double keypointsRatio = 0.05);
2012-04-03 08:49:13 +02:00
void operator ()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints);
void operator ()(const GpuMat& image, const GpuMat& mask,
2012-01-11 08:40:04 +01:00
std::vector<KeyPoint>& keypoints);
2012-04-03 08:49:13 +02:00
void downloadKeypoints(const GpuMat& d_keypoints,
2012-01-11 08:40:04 +01:00
std::vector<KeyPoint>& keypoints);
2012-04-03 08:49:13 +02:00
void convertKeypoints(const Mat& h_keypoints,
2012-01-11 08:40:04 +01:00
std::vector<KeyPoint>& keypoints);
void release();
bool nonmaxSupression;
int threshold;
double keypointsRatio;
int calcKeyPointsLocation(const GpuMat& image, const GpuMat& mask);
int getKeyPoints(GpuMat& keypoints);
};
The class `` FAST_GPU `` implements FAST corner detection algorithm.
.. seealso :: :ocv:func: `FAST`
gpu::FAST_GPU::FAST_GPU
-------------------------------------
Constructor.
.. ocv:function :: gpu::FAST_GPU::FAST_GPU(int threshold, bool nonmaxSupression = true, double keypointsRatio = 0.05)
:param threshold: Threshold on difference between intensity of the central pixel and pixels on a circle around this pixel.
2012-04-13 23:50:59 +02:00
:param nonmaxSupression: If it is true, non-maximum suppression is applied to detected corners (keypoints).
2012-01-11 08:40:04 +01:00
:param keypointsRatio: Inner buffer size for keypoints store is determined as (keypointsRatio * image_width * image_height).
gpu::FAST_GPU::operator ()
-------------------------------------
Finds the keypoints using FAST detector.
2012-04-03 08:49:13 +02:00
.. ocv:function :: void gpu::FAST_GPU::operator ()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints)
2012-01-11 08:40:04 +01:00
.. ocv:function :: void gpu::FAST_GPU::operator ()(const GpuMat& image, const GpuMat& mask, std::vector<KeyPoint>& keypoints)
:param image: Image where keypoints (corners) are detected. Only 8-bit grayscale images are supported.
:param mask: Optional input mask that marks the regions where we should detect features.
2012-01-16 14:10:50 +01:00
:param keypoints: The output vector of keypoints. Can be stored both in CPU and GPU memory. For GPU memory:
2012-04-03 08:49:13 +02:00
* keypoints.ptr<Vec2s>(LOCATION_ROW)[i] will contain location of i'th point
2012-04-13 23:50:59 +02:00
* keypoints.ptr<float>(RESPONSE_ROW)[i] will contain response of i'th point (if non-maximum suppression is applied)
2012-01-11 08:40:04 +01:00
gpu::FAST_GPU::downloadKeypoints
-------------------------------------
Download keypoints from GPU to CPU memory.
.. ocv:function :: void gpu::FAST_GPU::downloadKeypoints(const GpuMat& d_keypoints, std::vector<KeyPoint>& keypoints)
gpu::FAST_GPU::convertKeypoints
-------------------------------------
Converts keypoints from GPU representation to vector of `` KeyPoint `` .
.. ocv:function :: void gpu::FAST_GPU::convertKeypoints(const Mat& h_keypoints, std::vector<KeyPoint>& keypoints)
gpu::FAST_GPU::release
-------------------------------------
Releases inner buffer memory.
.. ocv:function :: void gpu::FAST_GPU::release()
gpu::FAST_GPU::calcKeyPointsLocation
-------------------------------------
Find keypoints and compute it's response if `` nonmaxSupression `` is true.
2012-03-29 10:07:57 +02:00
.. ocv:function :: int gpu::FAST_GPU::calcKeyPointsLocation(const GpuMat& image, const GpuMat& mask)
2012-01-11 08:40:04 +01:00
:param image: Image where keypoints (corners) are detected. Only 8-bit grayscale images are supported.
:param mask: Optional input mask that marks the regions where we should detect features.
The function returns count of detected keypoints.
gpu::FAST_GPU::getKeyPoints
-------------------------------------
Gets final array of keypoints.
.. ocv:function :: int gpu::FAST_GPU::getKeyPoints(GpuMat& keypoints)
:param keypoints: The output vector of keypoints.
2012-04-13 23:50:59 +02:00
The function performs non-max suppression if needed and returns final count of keypoints.
2012-01-11 08:40:04 +01:00
gpu::ORB_GPU
-------------
.. ocv:class :: gpu::ORB_GPU
Class for extracting ORB features and descriptors from an image. ::
class ORB_GPU
{
public:
enum
{
X_ROW = 0,
Y_ROW,
RESPONSE_ROW,
ANGLE_ROW,
OCTAVE_ROW,
SIZE_ROW,
ROWS_COUNT
};
enum
{
DEFAULT_FAST_THRESHOLD = 20
};
2012-04-03 08:49:13 +02:00
explicit ORB_GPU(int nFeatures = 500, float scaleFactor = 1.2f,
int nLevels = 8, int edgeThreshold = 31,
int firstLevel = 0, int WTA_K = 2,
int scoreType = 0, int patchSize = 31);
2012-01-11 08:40:04 +01:00
2012-04-03 08:49:13 +02:00
void operator()(const GpuMat& image, const GpuMat& mask,
2012-01-11 08:40:04 +01:00
std::vector<KeyPoint>& keypoints);
void operator()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints);
2012-04-03 08:49:13 +02:00
void operator()(const GpuMat& image, const GpuMat& mask,
2012-01-11 08:40:04 +01:00
std::vector<KeyPoint>& keypoints, GpuMat& descriptors);
2012-04-03 08:49:13 +02:00
void operator()(const GpuMat& image, const GpuMat& mask,
2012-01-11 08:40:04 +01:00
GpuMat& keypoints, GpuMat& descriptors);
void downloadKeyPoints(GpuMat& d_keypoints, std::vector<KeyPoint>& keypoints);
void convertKeyPoints(Mat& d_keypoints, std::vector<KeyPoint>& keypoints);
int descriptorSize() const;
void setParams(size_t n_features, const ORB::CommonParams& detector_params);
void setFastParams(int threshold, bool nonmaxSupression = true);
void release();
bool blurForDescriptor;
};
The class implements ORB feature detection and description algorithm.
gpu::ORB_GPU::ORB_GPU
-------------------------------------
Constructor.
2012-04-03 08:49:13 +02:00
.. ocv:function :: gpu::ORB_GPU::ORB_GPU(int nFeatures = 500, float scaleFactor = 1.2f, int nLevels = 8, int edgeThreshold = 31, int firstLevel = 0, int WTA_K = 2, int scoreType = 0, int patchSize = 31)
:param nFeatures: The number of desired features.
:param scaleFactor: Coefficient by which we divide the dimensions from one scale pyramid level to the next.
:param nLevels: The number of levels in the scale pyramid.
2012-01-11 08:40:04 +01:00
2012-04-03 08:49:13 +02:00
:param edgeThreshold: How far from the boundary the points should be.
2012-01-16 14:10:50 +01:00
2012-04-03 08:49:13 +02:00
:param firstLevel: The level at which the image is given. If 1, that means we will also look at the image `scaleFactor` times bigger.
2012-01-16 14:10:50 +01:00
2012-01-11 08:40:04 +01:00
gpu::ORB_GPU::operator()
-------------------------------------
Detects keypoints and computes descriptors for them.
.. ocv:function :: void gpu::ORB_GPU::operator()(const GpuMat& image, const GpuMat& mask, std::vector<KeyPoint>& keypoints)
.. ocv:function :: void gpu::ORB_GPU::operator()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints)
.. ocv:function :: void gpu::ORB_GPU::operator()(const GpuMat& image, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors)
.. ocv:function :: void gpu::ORB_GPU::operator()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors)
:param image: Input 8-bit grayscale image.
2012-04-03 08:49:13 +02:00
2012-01-11 08:40:04 +01:00
:param mask: Optional input mask that marks the regions where we should detect features.
2012-04-03 08:49:13 +02:00
2012-01-16 14:10:50 +01:00
:param keypoints: The input/output vector of keypoints. Can be stored both in CPU and GPU memory. For GPU memory:
* `` keypoints.ptr<float>(X_ROW)[i] `` contains x coordinate of the i'th feature.
* `` keypoints.ptr<float>(Y_ROW)[i] `` contains y coordinate of the i'th feature.
* `` keypoints.ptr<float>(RESPONSE_ROW)[i] `` contains the response of the i'th feature.
* `` keypoints.ptr<float>(ANGLE_ROW)[i] `` contains orientation of the i'th feature.
* `` keypoints.ptr<float>(OCTAVE_ROW)[i] `` contains the octave of the i'th feature.
* `` keypoints.ptr<float>(SIZE_ROW)[i] `` contains the size of the i'th feature.
2012-04-03 08:49:13 +02:00
2012-01-11 08:40:04 +01:00
:param descriptors: Computed descriptors. if ``blurForDescriptor`` is true, image will be blurred before descriptors calculation.
2012-05-28 22:11:38 +02:00
gpu::ORB_GPU::downloadKeyPoints
2012-01-11 08:40:04 +01:00
-------------------------------------
Download keypoints from GPU to CPU memory.
2012-10-18 10:16:04 +02:00
.. ocv:function :: static void gpu::ORB_GPU::downloadKeyPoints( const GpuMat& d_keypoints, std::vector<KeyPoint>& keypoints )
2012-01-11 08:40:04 +01:00
2012-05-28 22:11:38 +02:00
gpu::ORB_GPU::convertKeyPoints
2012-01-11 08:40:04 +01:00
-------------------------------------
Converts keypoints from GPU representation to vector of `` KeyPoint `` .
2012-10-18 10:16:04 +02:00
.. ocv:function :: static void gpu::ORB_GPU::convertKeyPoints( const Mat& d_keypoints, std::vector<KeyPoint>& keypoints )
2012-01-11 08:40:04 +01:00
gpu::ORB_GPU::release
-------------------------------------
Releases inner buffer memory.
.. ocv:function :: void gpu::ORB_GPU::release()
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU
2011-02-22 21:43:26 +01:00
--------------------------
2012-04-24 15:35:58 +02:00
.. ocv:class :: gpu::BFMatcher_GPU
2011-02-22 21:43:26 +01:00
2011-06-19 22:28:08 +02:00
Brute-force descriptor matcher. 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. ::
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
class BFMatcher_GPU
2011-02-26 12:05:10 +01:00
{
public:
2012-04-24 15:35:58 +02:00
explicit BFMatcher_GPU(int norm = cv::NORM_L2);
2011-02-26 12:05:10 +01:00
// Add descriptors to train descriptor collection.
void add(const std::vector<GpuMat>& descCollection);
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
// Get train descriptors collection.
const std::vector<GpuMat>& getTrainDescriptors() const;
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
// Clear train descriptors collection.
void clear();
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
// Return true if there are no train descriptors in collection.
2011-02-26 12:05:10 +01:00
bool empty() const;
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
// Return true if the matcher supports mask in match methods.
bool isMaskSupported() const;
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
void matchSingle(const GpuMat& query, const GpuMat& train,
2011-02-26 12:05:10 +01:00
GpuMat& trainIdx, GpuMat& distance,
2011-08-30 10:27:23 +02:00
const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
static void matchDownload(const GpuMat& trainIdx,
const GpuMat& distance, std::vector<DMatch>& matches);
2011-08-30 10:27:23 +02:00
static void matchConvert(const Mat& trainIdx,
const Mat& distance, std::vector<DMatch>& matches);
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
void match(const GpuMat& query, const GpuMat& train,
2011-02-26 12:05:10 +01:00
std::vector<DMatch>& matches, const GpuMat& mask = GpuMat());
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection,
const vector<GpuMat>& masks = std::vector<GpuMat>());
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
void matchCollection(const GpuMat& query, const GpuMat& trainCollection,
2011-02-26 12:05:10 +01:00
GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,
2011-08-30 10:27:23 +02:00
const GpuMat& maskCollection, Stream& stream = Stream::Null());
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
static void matchDownload(const GpuMat& trainIdx, GpuMat& imgIdx,
const GpuMat& distance, std::vector<DMatch>& matches);
2011-08-30 10:27:23 +02:00
static void matchConvert(const Mat& trainIdx, const Mat& imgIdx,
const Mat& distance, std::vector<DMatch>& matches);
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
void match(const GpuMat& query, std::vector<DMatch>& matches,
2011-02-26 12:05:10 +01:00
const std::vector<GpuMat>& masks = std::vector<GpuMat>());
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
void knnMatchSingle(const GpuMat& query, const GpuMat& train,
2011-02-26 12:05:10 +01:00
GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k,
2011-08-30 10:27:23 +02:00
const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
2011-02-22 21:43:26 +01:00
2012-04-03 08:49:13 +02:00
static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance,
2011-12-27 09:25:47 +01:00
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
2012-04-03 08:49:13 +02:00
static void knnMatchConvert(const Mat& trainIdx, const Mat& distance,
2011-12-27 09:25:47 +01:00
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
void knnMatch(const GpuMat& query, const GpuMat& train,
2011-02-26 12:05:10 +01:00
std::vector< std::vector<DMatch> >& matches, int k,
const GpuMat& mask = GpuMat(), bool compactResult = false);
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
void knnMatch2Collection(const GpuMat& query, const GpuMat& trainCollection,
GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,
const GpuMat& maskCollection = GpuMat(), Stream& stream = Stream::Null());
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
static void knnMatch2Download(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
static void knnMatch2Convert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
void knnMatch(const GpuMat& query, std::vector< std::vector<DMatch> >& matches, int k,
const std::vector<GpuMat>& masks = std::vector<GpuMat>(),
2011-08-30 10:27:23 +02:00
bool compactResult = false);
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
void radiusMatchSingle(const GpuMat& query, const GpuMat& train,
GpuMat& trainIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance,
const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());
static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, const GpuMat& nMatches,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
static void radiusMatchConvert(const Mat& trainIdx, const Mat& distance, const Mat& nMatches,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
void radiusMatch(const GpuMat& query, const GpuMat& train,
2011-02-26 12:05:10 +01:00
std::vector< std::vector<DMatch> >& matches, float maxDistance,
const GpuMat& mask = GpuMat(), bool compactResult = false);
2011-02-22 21:43:26 +01:00
2011-12-27 09:25:47 +01:00
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());
static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, const GpuMat& nMatches,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
static void radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches,
std::vector< std::vector<DMatch> >& matches, bool compactResult = false);
void radiusMatch(const GpuMat& query, std::vector< std::vector<DMatch> >& matches, float maxDistance,
const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false);
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
private:
std::vector<GpuMat> trainDescCollection;
};
2011-02-28 22:26:43 +01:00
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
The class `` BFMatcher_GPU `` has an interface similar to the class :ocv:class: `DescriptorMatcher` . It has two groups 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.
2011-03-23 11:56:20 +01:00
2012-04-24 15:35:58 +02:00
.. seealso :: :ocv:class: `DescriptorMatcher` , :ocv:class: `BFMatcher`
2011-02-22 21:43:26 +01:00
2011-07-22 14:50:49 +02:00
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::match
2011-02-26 12:05:10 +01:00
-------------------------------------
2011-08-30 10:27:23 +02:00
Finds the best match for each descriptor from a query set with train descriptors.
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::match(const GpuMat& query, const GpuMat& train, std::vector<DMatch>& matches, const GpuMat& mask = GpuMat())
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::matchSingle(const GpuMat& query, const GpuMat& train, GpuMat& trainIdx, GpuMat& distance, const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null())
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::match(const GpuMat& query, std::vector<DMatch>& matches, const std::vector<GpuMat>& masks = std::vector<GpuMat>())
2011-08-30 10:27:23 +02:00
2012-05-28 13:22:43 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::matchCollection( const GpuMat& query, const GpuMat& trainCollection, GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, const GpuMat& masks=GpuMat(), Stream& stream=Stream::Null() )
2011-03-23 11:56:20 +01:00
2011-12-27 09:25:47 +01:00
.. seealso :: :ocv:func: `DescriptorMatcher::match`
2011-03-23 11:56:20 +01:00
2011-07-22 14:50:49 +02:00
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::makeGpuCollection
2011-02-22 21:43:26 +01:00
-------------------------------------------------
2012-04-24 15:35:58 +02:00
Performs a GPU collection of train descriptors and masks in a suitable format for the :ocv:func: `gpu::BFMatcher_GPU::matchCollection` function.
2011-03-23 11:56:20 +01:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection, const vector<GpuMat>& masks = std::vector<GpuMat>())
2011-02-22 21:43:26 +01:00
2011-07-22 14:50:49 +02:00
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::matchDownload
2011-03-03 08:29:55 +01:00
---------------------------------------------
2012-04-24 15:35:58 +02:00
Downloads matrices obtained via :ocv:func: `gpu::BFMatcher_GPU::matchSingle` or :ocv:func: `gpu::BFMatcher_GPU::matchCollection` to vector with :ocv:class: `DMatch` .
2011-08-30 10:27:23 +02:00
2012-05-28 13:22:43 +02:00
.. ocv:function :: static void gpu::BFMatcher_GPU::matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector<DMatch>&matches)
2011-02-22 21:43:26 +01:00
2012-05-28 13:22:43 +02:00
.. ocv:function :: static void gpu::BFMatcher_GPU::matchDownload( const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, std::vector<DMatch>& matches )
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::matchConvert
2011-08-30 10:27:23 +02:00
---------------------------------------------
2012-04-24 15:35:58 +02:00
Converts matrices obtained via :ocv:func: `gpu::BFMatcher_GPU::matchSingle` or :ocv:func: `gpu::BFMatcher_GPU::matchCollection` to vector with :ocv:class: `DMatch` .
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::matchConvert(const Mat& trainIdx, const Mat& distance, std::vector<DMatch>&matches)
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::matchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector<DMatch>&matches)
2011-02-22 21:43:26 +01:00
2011-07-22 14:50:49 +02:00
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::knnMatch
2011-02-22 21:43:26 +01:00
----------------------------------------
2012-04-13 23:50:59 +02:00
Finds the `` k `` best matches for each descriptor from a query set with train descriptors.
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::knnMatch(const GpuMat& query, const GpuMat& train, std::vector< std::vector<DMatch> >&matches, int k, const GpuMat& mask = GpuMat(), bool compactResult = false)
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::knnMatchSingle(const GpuMat& query, const GpuMat& train, GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null())
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::knnMatch(const GpuMat& query, std::vector< std::vector<DMatch> >&matches, int k, const std::vector<GpuMat>&masks = std::vector<GpuMat>(), bool compactResult = false )
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::knnMatch2Collection(const GpuMat& query, const GpuMat& trainCollection, GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, const GpuMat& maskCollection = GpuMat(), Stream& stream = Stream::Null())
2011-08-30 10:27:23 +02:00
2011-12-27 09:25:47 +01:00
:param query: Query set of descriptors.
2011-08-30 10:27:23 +02:00
2011-12-27 09:25:47 +01:00
:param train: Training set of descriptors. It is not be added to train descriptors collection stored in the class object.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param k: Number of the best matches per each query descriptor (or less if it is not possible).
2011-03-23 11:56:20 +01:00
2011-03-29 01:05:42 +02:00
:param mask: Mask specifying permissible matches between the input query and train matrices of descriptors.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
:param compactResult: If ``compactResult`` is ``true`` , the ``matches`` vector does not contain matches for fully masked-out query descriptors.
:param stream: Stream for the asynchronous version.
2012-04-13 23:50:59 +02:00
The function returns detected `` k `` (or less if not possible) matches in the increasing order by distance.
2011-08-30 10:27:23 +02:00
2011-07-22 14:50:49 +02:00
The third variant of the method stores the results in GPU memory.
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `DescriptorMatcher::knnMatch`
2011-07-22 14:50:49 +02:00
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::knnMatchDownload
2011-03-03 08:29:55 +01:00
------------------------------------------------
2012-04-24 15:35:58 +02:00
Downloads matrices obtained via :ocv:func: `gpu::BFMatcher_GPU::knnMatchSingle` or :ocv:func: `gpu::BFMatcher_GPU::knnMatch2Collection` to vector with :ocv:class: `DMatch` .
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector< std::vector<DMatch> >&matches, bool compactResult = false)
2011-03-23 11:56:20 +01:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::knnMatch2Download(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, std::vector< std::vector<DMatch> >& matches, bool compactResult = false)
2011-12-27 09:25:47 +01:00
2011-08-30 10:27:23 +02:00
If `` compactResult `` is `` true `` , the `` matches `` vector does not contain matches for fully masked-out query descriptors.
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::knnMatchConvert
2011-08-30 10:27:23 +02:00
------------------------------------------------
2012-04-24 15:35:58 +02:00
Converts matrices obtained via :ocv:func: `gpu::BFMatcher_GPU::knnMatchSingle` or :ocv:func: `gpu::BFMatcher_GPU::knnMatch2Collection` to CPU vector with :ocv:class: `DMatch` .
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::knnMatchConvert(const Mat& trainIdx, const Mat& distance, std::vector< std::vector<DMatch> >&matches, bool compactResult = false)
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::knnMatch2Convert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector< std::vector<DMatch> >& matches, bool compactResult = false)
2011-12-27 09:25:47 +01:00
2011-08-30 10:27:23 +02:00
If `` compactResult `` is `` true `` , the `` matches `` vector does not contain matches for fully masked-out query descriptors.
2011-02-22 21:43:26 +01:00
2011-07-22 14:50:49 +02:00
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::radiusMatch
2011-02-22 21:43:26 +01:00
-------------------------------------------
2011-08-30 10:27:23 +02:00
For each query descriptor, finds the best matches with a distance less than a given threshold.
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::radiusMatch(const GpuMat& query, const GpuMat& train, std::vector< std::vector<DMatch> >&matches, float maxDistance, const GpuMat& mask = GpuMat(), bool compactResult = false)
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::radiusMatchSingle(const GpuMat& query, const GpuMat& train, GpuMat& trainIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance, const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null())
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::radiusMatch(const GpuMat& query, std::vector< std::vector<DMatch> >&matches, float maxDistance, const std::vector<GpuMat>& masks = std::vector<GpuMat>(), bool compactResult = false)
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::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())
2011-08-30 10:27:23 +02:00
2011-12-27 09:25:47 +01:00
:param query: Query set of descriptors.
2011-08-30 10:27:23 +02:00
2011-12-27 09:25:47 +01:00
:param train: Training set of descriptors. It is not added to train descriptors collection stored in the class object.
2011-02-22 21:43:26 +01:00
2011-02-26 12:05:10 +01:00
:param maxDistance: Distance threshold.
2011-02-22 21:43:26 +01:00
2011-03-29 01:05:42 +02:00
:param mask: Mask specifying permissible matches between the input query and train matrices of descriptors.
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
:param compactResult: If ``compactResult`` is ``true`` , the ``matches`` vector does not contain matches for fully masked-out query descriptors.
:param stream: Stream for the asynchronous version.
The function returns detected matches in the increasing order by distance.
2011-07-22 14:50:49 +02:00
The methods work only on devices with the compute capability :math: `>=` 1.1.
2011-08-30 10:27:23 +02:00
2011-07-22 14:50:49 +02:00
The third variant of the method stores the results in GPU memory and does not store the points by the distance.
2011-08-30 10:27:23 +02:00
.. seealso :: :ocv:func: `DescriptorMatcher::radiusMatch`
2011-03-23 11:56:20 +01:00
2011-02-22 21:43:26 +01:00
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::radiusMatchDownload
2011-03-03 08:29:55 +01:00
---------------------------------------------------
2012-04-24 15:35:58 +02:00
Downloads matrices obtained via :ocv:func: `gpu::BFMatcher_GPU::radiusMatchSingle` or :ocv:func: `gpu::BFMatcher_GPU::radiusMatchCollection` to vector with :ocv:class: `DMatch` .
2011-12-27 09:25:47 +01:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, const GpuMat& nMatches, std::vector< std::vector<DMatch> >&matches, bool compactResult = false)
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, const GpuMat& nMatches, std::vector< std::vector<DMatch> >& matches, bool compactResult = false)
2011-02-22 21:43:26 +01:00
2011-08-30 10:27:23 +02:00
If `` compactResult `` is `` true `` , the `` matches `` vector does not contain matches for fully masked-out query descriptors.
2012-04-24 15:35:58 +02:00
gpu::BFMatcher_GPU::radiusMatchConvert
2011-08-30 10:27:23 +02:00
---------------------------------------------------
2012-04-24 15:35:58 +02:00
Converts matrices obtained via :ocv:func: `gpu::BFMatcher_GPU::radiusMatchSingle` or :ocv:func: `gpu::BFMatcher_GPU::radiusMatchCollection` to vector with :ocv:class: `DMatch` .
2011-12-27 09:25:47 +01:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::radiusMatchConvert(const Mat& trainIdx, const Mat& distance, const Mat& nMatches, std::vector< std::vector<DMatch> >&matches, bool compactResult = false)
2011-08-30 10:27:23 +02:00
2012-04-24 15:35:58 +02:00
.. ocv:function :: void gpu::BFMatcher_GPU::radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches, std::vector< std::vector<DMatch> >& matches, bool compactResult = false)
2011-08-30 10:27:23 +02:00
If `` compactResult `` is `` true `` , the `` matches `` vector does not contain matches for fully masked-out query descriptors.
2011-03-29 01:05:42 +02:00