ocl: correct disabling of OpenCL code
This commit is contained in:
@@ -250,6 +250,7 @@ void FAST_t(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bo
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
template<typename pt>
|
||||
struct cmp_pt
|
||||
{
|
||||
@@ -326,16 +327,18 @@ static bool ocl_FAST( InputArray _img, std::vector<KeyPoint>& keypoints,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type)
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
if( ocl::useOpenCL() && _img.isUMat() && type == FastFeatureDetector::TYPE_9_16 &&
|
||||
ocl_FAST(_img, keypoints, threshold, nonmax_suppression, 10000))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_OCL);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch(type) {
|
||||
case FastFeatureDetector::TYPE_5_8:
|
||||
|
@@ -52,6 +52,7 @@ namespace cv
|
||||
|
||||
/////////////////////// ocl functions for BFMatcher ///////////////////////////
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
static void ensureSizeIsEnough(int rows, int cols, int type, UMat &m)
|
||||
{
|
||||
if (m.type() == type && m.rows >= rows && m.cols >= cols)
|
||||
@@ -390,6 +391,7 @@ static bool ocl_radiusMatchDownload(const UMat &trainIdx, const UMat &distance,
|
||||
|
||||
return ocl_radiusMatchConvert(trainIdxCPU, distanceCPU, nMatchesCPU, matches, compactResult);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
* DescriptorMatcher *
|
||||
@@ -693,6 +695,7 @@ Ptr<DescriptorMatcher> BFMatcher::clone( bool emptyTrainData ) const
|
||||
return matcher;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
static bool ocl_match(InputArray query, InputArray _train, std::vector< std::vector<DMatch> > &matches, int dstType)
|
||||
{
|
||||
UMat trainIdx, distance;
|
||||
@@ -714,6 +717,7 @@ static bool ocl_knnMatch(InputArray query, InputArray _train, std::vector< std::
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void BFMatcher::knnMatchImpl( InputArray _queryDescriptors, std::vector<std::vector<DMatch> >& matches, int knn,
|
||||
InputArrayOfArrays _masks, bool compactResult )
|
||||
@@ -744,6 +748,7 @@ void BFMatcher::knnMatchImpl( InputArray _queryDescriptors, std::vector<std::vec
|
||||
utrainDescCollection.clear();
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
int trainDescVectorSize = trainDescCollection.empty() ? (int)utrainDescCollection.size() : (int)trainDescCollection.size();
|
||||
Size trainDescSize = trainDescCollection.empty() ? utrainDescCollection[0].size() : trainDescCollection[0].size();
|
||||
int trainDescOffset = trainDescCollection.empty() ? (int)utrainDescCollection[0].offset : 0;
|
||||
@@ -791,6 +796,7 @@ void BFMatcher::knnMatchImpl( InputArray _queryDescriptors, std::vector<std::vec
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Mat queryDescriptors = _queryDescriptors.getMat();
|
||||
if(trainDescCollection.empty() && !utrainDescCollection.empty())
|
||||
@@ -851,6 +857,7 @@ void BFMatcher::knnMatchImpl( InputArray _queryDescriptors, std::vector<std::vec
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
static bool ocl_radiusMatch(InputArray query, InputArray _train, std::vector< std::vector<DMatch> > &matches,
|
||||
float maxDistance, int dstType, bool compactResult)
|
||||
{
|
||||
@@ -861,6 +868,7 @@ static bool ocl_radiusMatch(InputArray query, InputArray _train, std::vector< st
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void BFMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vector<std::vector<DMatch> >& matches,
|
||||
float maxDistance, InputArrayOfArrays _masks, bool compactResult )
|
||||
@@ -888,6 +896,7 @@ void BFMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vector<std::
|
||||
utrainDescCollection.clear();
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
int trainDescVectorSize = trainDescCollection.empty() ? (int)utrainDescCollection.size() : (int)trainDescCollection.size();
|
||||
Size trainDescSize = trainDescCollection.empty() ? utrainDescCollection[0].size() : trainDescCollection[0].size();
|
||||
int trainDescOffset = trainDescCollection.empty() ? (int)utrainDescCollection[0].offset : 0;
|
||||
@@ -913,6 +922,7 @@ void BFMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vector<std::
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Mat queryDescriptors = _queryDescriptors.getMat();
|
||||
if(trainDescCollection.empty() && !utrainDescCollection.empty())
|
||||
|
@@ -57,6 +57,7 @@ template<typename _Tp> inline void copyVectorToUMat(const std::vector<_Tp>& v, O
|
||||
Mat(1, (int)(v.size()*sizeof(v[0])), CV_8U, (void*)&v[0]).copyTo(um);
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
static bool
|
||||
ocl_HarrisResponses(const UMat& imgbuf,
|
||||
const UMat& layerinfo,
|
||||
@@ -120,7 +121,7 @@ ocl_computeOrbDescriptors(const UMat& imgbuf, const UMat& layerInfo,
|
||||
ocl::KernelArg::PtrReadOnly(pattern),
|
||||
nkeypoints, dsize).run(1, globalSize, 0, true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Function that computes the Harris responses in a
|
||||
@@ -726,6 +727,7 @@ int ORB_Impl::defaultNorm() const
|
||||
return NORM_HAMMING;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
static void uploadORBKeypoints(const std::vector<KeyPoint>& src, std::vector<Vec3i>& buf, OutputArray dst)
|
||||
{
|
||||
size_t i, n = src.size();
|
||||
@@ -758,7 +760,7 @@ static void uploadORBKeypoints(const std::vector<KeyPoint>& src,
|
||||
}
|
||||
copyVectorToUMat(buf, dst);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/** Compute the ORB_Impl keypoints on an image
|
||||
* @param image_pyramid the image pyramid to compute the features and descriptors on
|
||||
@@ -776,6 +778,10 @@ static void computeKeyPoints(const Mat& imagePyramid,
|
||||
int edgeThreshold, int patchSize, int scoreType,
|
||||
bool useOCL, int fastThreshold )
|
||||
{
|
||||
#ifndef HAVE_OPENCL
|
||||
(void)uimagePyramid;(void)ulayerInfo;(void)useOCL;
|
||||
#endif
|
||||
|
||||
int i, nkeypoints, level, nlevels = (int)layerInfo.size();
|
||||
std::vector<int> nfeaturesPerLevel(nlevels);
|
||||
|
||||
@@ -862,6 +868,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
|
||||
// Select best features using the Harris cornerness (better scoring than FAST)
|
||||
if( scoreType == ORB_Impl::HARRIS_SCORE )
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
if( useOCL )
|
||||
{
|
||||
uploadORBKeypoints(allKeypoints, ukeypoints_buf, ukeypoints);
|
||||
@@ -877,6 +884,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
|
||||
}
|
||||
|
||||
if( !useOCL )
|
||||
#endif
|
||||
HarrisResponses(imagePyramid, layerInfo, allKeypoints, 7, HARRIS_K);
|
||||
|
||||
std::vector<KeyPoint> newAllKeypoints;
|
||||
@@ -902,6 +910,8 @@ static void computeKeyPoints(const Mat& imagePyramid,
|
||||
}
|
||||
|
||||
nkeypoints = (int)allKeypoints.size();
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
if( useOCL )
|
||||
{
|
||||
UMat uumax;
|
||||
@@ -922,6 +932,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
|
||||
}
|
||||
|
||||
if( !useOCL )
|
||||
#endif
|
||||
{
|
||||
ICAngles(imagePyramid, layerInfo, allKeypoints, umax, halfPatchSize);
|
||||
}
|
||||
@@ -1147,6 +1158,7 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
|
||||
GaussianBlur(workingMat, workingMat, Size(7, 7), 2, 2, BORDER_REFLECT_101);
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
if( useOCL )
|
||||
{
|
||||
imagePyramid.copyTo(uimagePyramid);
|
||||
@@ -1166,6 +1178,7 @@ void ORB_Impl::detectAndCompute( InputArray _image, InputArray _mask,
|
||||
}
|
||||
|
||||
if( !useOCL )
|
||||
#endif
|
||||
{
|
||||
Mat descriptors = _descriptors.getMat();
|
||||
computeOrbDescriptors(imagePyramid, layerInfo, layerScale,
|
||||
|
Reference in New Issue
Block a user