Merge pull request #2034 from pentschev:ocl_features2d_orb_master

This commit is contained in:
Andrey Pavlenko
2013-12-27 15:49:27 +04:00
committed by OpenCV Buildbot
9 changed files with 1940 additions and 0 deletions

View File

@@ -1515,6 +1515,110 @@ namespace cv
int nonmaxSupressionOCL(oclMat& keypoints);
};
////////////////////////////////// ORB Descriptor Extractor //////////////////////////////////
class CV_EXPORTS ORB_OCL
{
public:
enum
{
X_ROW = 0,
Y_ROW,
RESPONSE_ROW,
ANGLE_ROW,
OCTAVE_ROW,
SIZE_ROW,
ROWS_COUNT
};
enum
{
DEFAULT_FAST_THRESHOLD = 20
};
//! Constructor
explicit ORB_OCL(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);
//! Compute the ORB features on an image
//! image - the image to compute the features (supports only CV_8UC1 images)
//! mask - the mask to apply
//! keypoints - the resulting keypoints
void operator ()(const oclMat& image, const oclMat& mask, std::vector<KeyPoint>& keypoints);
void operator ()(const oclMat& image, const oclMat& mask, oclMat& keypoints);
//! Compute the ORB features and descriptors on an image
//! image - the image to compute the features (supports only CV_8UC1 images)
//! mask - the mask to apply
//! keypoints - the resulting keypoints
//! descriptors - descriptors array
void operator ()(const oclMat& image, const oclMat& mask, std::vector<KeyPoint>& keypoints, oclMat& descriptors);
void operator ()(const oclMat& image, const oclMat& mask, oclMat& keypoints, oclMat& descriptors);
//! download keypoints from device to host memory
static void downloadKeyPoints(const oclMat& d_keypoints, std::vector<KeyPoint>& keypoints);
//! convert keypoints to KeyPoint vector
static void convertKeyPoints(const Mat& d_keypoints, std::vector<KeyPoint>& keypoints);
//! returns the descriptor size in bytes
inline int descriptorSize() const { return kBytes; }
inline int descriptorType() const { return CV_8U; }
inline int defaultNorm() const { return NORM_HAMMING; }
inline void setFastParams(int threshold, bool nonmaxSupression = true)
{
fastDetector_.threshold = threshold;
fastDetector_.nonmaxSupression = nonmaxSupression;
}
//! release temporary buffer's memory
void release();
//! if true, image will be blurred before descriptors calculation
bool blurForDescriptor;
private:
enum { kBytes = 32 };
void buildScalePyramids(const oclMat& image, const oclMat& mask);
void computeKeyPointsPyramid();
void computeDescriptors(oclMat& descriptors);
void mergeKeyPoints(oclMat& keypoints);
int nFeatures_;
float scaleFactor_;
int nLevels_;
int edgeThreshold_;
int firstLevel_;
int WTA_K_;
int scoreType_;
int patchSize_;
// The number of desired features per scale
std::vector<size_t> n_features_per_level_;
// Points to compute BRIEF descriptors from
oclMat pattern_;
std::vector<oclMat> imagePyr_;
std::vector<oclMat> maskPyr_;
oclMat buf_;
std::vector<oclMat> keyPointsPyr_;
std::vector<int> keyPointsCount_;
FAST_OCL fastDetector_;
Ptr<ocl::FilterEngine_GPU> blurFilter;
oclMat d_keypoints_;
oclMat uMax_;
};
/////////////////////////////// PyrLKOpticalFlow /////////////////////////////////////
class CV_EXPORTS PyrLKOpticalFlow