Add ocl's good features to track implementation.
Additional notes with this commit: 1. Add cornerHarris_dxdy and cornerMinEigenVal_dxdy to get the interim dx and dy output of Sobel operator; 2. Add minMax_buf to allow user to reuse buffers in minMax; 3. Fix an error when either min or max pointer fed into minMax is NULL; 4. Corner sorter temporarily uses C++ STL's quick sort. A parallel selection sort in OpneCL is contained in the implementation but disabled due to poor performance at the moment. 5. Accuracy test for ocl gfft.
This commit is contained in:
@@ -122,8 +122,9 @@ namespace cv
|
||||
CV_EXPORTS void setBinpath(const char *path);
|
||||
|
||||
//The two functions below enable other opencl program to use ocl module's cl_context and cl_command_queue
|
||||
//returns cl_context *
|
||||
CV_EXPORTS void* getoclContext();
|
||||
|
||||
//returns cl_command_queue *
|
||||
CV_EXPORTS void* getoclCommandQueue();
|
||||
|
||||
//explicit call clFinish. The global command queue will be used.
|
||||
@@ -461,6 +462,7 @@ namespace cv
|
||||
// support all C1 types
|
||||
|
||||
CV_EXPORTS void minMax(const oclMat &src, double *minVal, double *maxVal = 0, const oclMat &mask = oclMat());
|
||||
CV_EXPORTS void minMax_buf(const oclMat &src, double *minVal, double *maxVal, const oclMat &mask, oclMat& buf);
|
||||
|
||||
//! finds global minimum and maximum array elements and returns their values with locations
|
||||
// support all C1 types
|
||||
@@ -789,7 +791,11 @@ namespace cv
|
||||
CV_EXPORTS void integral(const oclMat &src, oclMat &sum, oclMat &sqsum);
|
||||
CV_EXPORTS void integral(const oclMat &src, oclMat &sum);
|
||||
CV_EXPORTS void cornerHarris(const oclMat &src, oclMat &dst, int blockSize, int ksize, double k, int bordertype = cv::BORDER_DEFAULT);
|
||||
CV_EXPORTS void cornerHarris_dxdy(const oclMat &src, oclMat &dst, oclMat &Dx, oclMat &Dy,
|
||||
int blockSize, int ksize, double k, int bordertype = cv::BORDER_DEFAULT);
|
||||
CV_EXPORTS void cornerMinEigenVal(const oclMat &src, oclMat &dst, int blockSize, int ksize, int bordertype = cv::BORDER_DEFAULT);
|
||||
CV_EXPORTS void cornerMinEigenVal_dxdy(const oclMat &src, oclMat &dst, oclMat &Dx, oclMat &Dy,
|
||||
int blockSize, int ksize, int bordertype = cv::BORDER_DEFAULT);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////CascadeClassifier//////////////////////////////////////////////////////////////////
|
||||
@@ -1253,6 +1259,52 @@ namespace cv
|
||||
public:
|
||||
explicit BFMatcher_OCL(int norm = NORM_L2) : BruteForceMatcher_OCL_base(norm == NORM_L1 ? L1Dist : norm == NORM_L2 ? L2Dist : HammingDist) {}
|
||||
};
|
||||
|
||||
class CV_EXPORTS GoodFeaturesToTrackDetector_OCL
|
||||
{
|
||||
public:
|
||||
explicit GoodFeaturesToTrackDetector_OCL(int maxCorners = 1000, double qualityLevel = 0.01, double minDistance = 0.0,
|
||||
int blockSize = 3, bool useHarrisDetector = false, double harrisK = 0.04);
|
||||
|
||||
//! return 1 rows matrix with CV_32FC2 type
|
||||
void operator ()(const oclMat& image, oclMat& corners, const oclMat& mask = oclMat());
|
||||
//! download points of type Point2f to a vector. the vector's content will be erased
|
||||
void downloadPoints(const oclMat &points, vector<Point2f> &points_v);
|
||||
|
||||
int maxCorners;
|
||||
double qualityLevel;
|
||||
double minDistance;
|
||||
|
||||
int blockSize;
|
||||
bool useHarrisDetector;
|
||||
double harrisK;
|
||||
void releaseMemory()
|
||||
{
|
||||
Dx_.release();
|
||||
Dy_.release();
|
||||
eig_.release();
|
||||
minMaxbuf_.release();
|
||||
tmpCorners_.release();
|
||||
}
|
||||
private:
|
||||
oclMat Dx_;
|
||||
oclMat Dy_;
|
||||
oclMat eig_;
|
||||
oclMat minMaxbuf_;
|
||||
oclMat tmpCorners_;
|
||||
};
|
||||
|
||||
inline GoodFeaturesToTrackDetector_OCL::GoodFeaturesToTrackDetector_OCL(int maxCorners_, double qualityLevel_, double minDistance_,
|
||||
int blockSize_, bool useHarrisDetector_, double harrisK_)
|
||||
{
|
||||
maxCorners = maxCorners_;
|
||||
qualityLevel = qualityLevel_;
|
||||
minDistance = minDistance_;
|
||||
blockSize = blockSize_;
|
||||
useHarrisDetector = useHarrisDetector_;
|
||||
harrisK = harrisK_;
|
||||
}
|
||||
|
||||
/////////////////////////////// PyrLKOpticalFlow /////////////////////////////////////
|
||||
class CV_EXPORTS PyrLKOpticalFlow
|
||||
{
|
||||
|
@@ -120,6 +120,33 @@ namespace cv
|
||||
cl_mem CV_EXPORTS bindTexture(const oclMat &mat);
|
||||
void CV_EXPORTS releaseTexture(cl_mem& texture);
|
||||
|
||||
//Represents an image texture object
|
||||
class CV_EXPORTS TextureCL
|
||||
{
|
||||
public:
|
||||
TextureCL(cl_mem tex, int r, int c, int t)
|
||||
: tex_(tex), rows(r), cols(c), type(t) {}
|
||||
~TextureCL()
|
||||
{
|
||||
openCLFree(tex_);
|
||||
}
|
||||
operator cl_mem()
|
||||
{
|
||||
return tex_;
|
||||
}
|
||||
cl_mem const tex_;
|
||||
const int rows;
|
||||
const int cols;
|
||||
const int type;
|
||||
private:
|
||||
//disable assignment
|
||||
void operator=(const TextureCL&);
|
||||
};
|
||||
// bind oclMat to OpenCL image textures and retunrs an TextureCL object
|
||||
// note:
|
||||
// for faster clamping, there is no buffer padding for the constructed texture
|
||||
Ptr<TextureCL> CV_EXPORTS bindTexturePtr(const oclMat &mat);
|
||||
|
||||
// returns whether the current context supports image2d_t format or not
|
||||
bool CV_EXPORTS support_image2d(Context *clCxt = Context::getContext());
|
||||
|
||||
@@ -132,7 +159,7 @@ namespace cv
|
||||
};
|
||||
template<DEVICE_INFO _it, typename _ty>
|
||||
_ty queryDeviceInfo(cl_kernel kernel = NULL);
|
||||
//info should have been pre-allocated
|
||||
|
||||
template<>
|
||||
int CV_EXPORTS queryDeviceInfo<WAVEFRONT_SIZE, int>(cl_kernel kernel);
|
||||
template<>
|
||||
|
Reference in New Issue
Block a user