ocl: fix "off" mode

pull/372/head
Alexander Alekhin 9 years ago
parent 22f5843377
commit ac8dd366e4
  1. 2
      modules/dnn/src/layers/convolution_layer.cpp
  2. 2
      modules/dnn/src/layers/im2col.cpp
  3. 2
      modules/dnn/src/layers/im2col.hpp
  4. 6
      modules/tracking/src/tldDetector.cpp
  5. 4
      modules/tracking/src/tldDetector.hpp
  6. 2
      modules/tracking/src/tldModel.cpp
  7. 2
      modules/tracking/src/tldModel.hpp
  8. 22
      modules/tracking/src/tldTracker.cpp
  9. 2
      modules/xfeatures2d/src/surf.cpp
  10. 2
      modules/xfeatures2d/src/surf.hpp
  11. 4
      modules/xfeatures2d/src/surf.ocl.cpp

@ -153,6 +153,7 @@ namespace dnn
return;
}
#ifdef HAVE_OPENCL
if (useOpenCL && ocl::useOpenCL() && inpBlob.type() == CV_32F && !is1x1())
{
std::vector<Range> ranges(4, Range::all());
@ -165,6 +166,7 @@ namespace dnn
dst.copyTo(colMat);
return;
}
#endif // HAVE_OPENCL
if (inpBlob.type() == CV_32F)
im2col_cpu((float *)srcPtr, inpGroupCn, inpH, inpW, kerH, kerW, padH, padW, strideH, strideW, (float *)colMat.ptr());

@ -49,6 +49,7 @@ namespace cv
namespace dnn
{
#ifdef HAVE_OPENCL
void im2col_ocl(UMat &img,
int channels, int height, int width,
int kernel_h, int kernel_w,
@ -78,6 +79,7 @@ void im2col_ocl(UMat &img,
CV_Assert(im2col_ker.run(1, &globalSize, &localSize, true));
}
#endif // HAVE_OPENCL
}
}

@ -111,12 +111,14 @@ void col2im_cpu(const Dtype* data_col,
}
}
#ifdef HAVE_OPENCL
void im2col_ocl(UMat &img,
int channels, int height, int width,
int kernel_h, int kernel_w,
int pad_h, int pad_w,
int stride_h, int stride_w,
UMat &col);
#endif
}
}

@ -104,6 +104,7 @@ namespace cv
return splus / (sminus + splus);
}
#ifdef HAVE_OPENCL
double TLDDetector::ocl_Sr(const Mat_<uchar>& patch)
{
//int64 e1, e2, e3, e4;
@ -283,6 +284,7 @@ namespace cv
//t = (e2 - e1) / getTickFrequency()*1000.0;
//printf("Sr GPU: %f\n\n", t);
}
#endif
// Calculate Conservative similarity of the patch (NN-Model)
double TLDDetector::Sc(const Mat_<uchar>& patch)
@ -337,6 +339,7 @@ namespace cv
return splus / (sminus + splus);
}
#ifdef HAVE_OPENCL
double TLDDetector::ocl_Sc(const Mat_<uchar>& patch)
{
//int64 e1, e2, e3, e4;
@ -415,6 +418,7 @@ namespace cv
return 0.0;
return splus / (sminus + splus);
}
#endif // HAVE_OPENCL
// Generate Search Windows for detector from aspect ratio of initial BBs
void TLDDetector::generateScanGrid(int rows, int cols, Size initBox, std::vector<Rect2d>& res, bool withScaling)
@ -565,6 +569,7 @@ namespace cv
return true;
}
#ifdef HAVE_OPENCL
bool TLDDetector::ocl_detect(const Mat& img, const Mat& imgBlurred, Rect2d& res, std::vector<LabeledPatch>& patches, Size initSize)
{
patches.clear();
@ -696,6 +701,7 @@ namespace cv
res = maxScRect;
return true;
}
#endif // HAVE_OPENCL
// Computes the variance of subimage given by box, with the help of two integral
// images intImgP and intImgP2 (sum of squares), which should be also provided.

@ -74,10 +74,12 @@ namespace cv
inline double ensembleClassifierNum(const uchar* data);
inline void prepareClassifiers(int rowstep);
double Sr(const Mat_<uchar>& patch);
double ocl_Sr(const Mat_<uchar>& patch);
double Sc(const Mat_<uchar>& patch);
#ifdef HAVE_OPENCL
double ocl_Sr(const Mat_<uchar>& patch);
double ocl_Sc(const Mat_<uchar>& patch);
void ocl_batchSrSc(const Mat_<uchar>& patches, double *resultSr, double *resultSc, int numOfPatches);
#endif
std::vector<TLDEnsembleClassifier> classifiers;
Mat *posExp, *negExp;

@ -246,6 +246,7 @@ namespace cv
dfprintf((stdout, "\n"));*/
}
#ifdef HAVE_OPENCL
void TrackerTLDModel::ocl_integrateAdditional(const std::vector<Mat_<uchar> >& eForModel, const std::vector<Mat_<uchar> >& eForEnsemble, bool isPositive)
{
int positiveIntoModel = 0, negativeIntoModel = 0, positiveIntoEnsemble = 0, negativeIntoEnsemble = 0;
@ -315,6 +316,7 @@ namespace cv
dfprintf((stdout, "positiveIntoEnsemble = %d ", positiveIntoEnsemble));
dfprintf((stdout, "\n"));*/
}
#endif // HAVE_OPENCL
//Push the patch to the model
void TrackerTLDModel::pushIntoModel(const Mat_<uchar>& example, bool positive)

@ -58,7 +58,9 @@ namespace cv
void setBoudingBox(Rect2d boundingBox){ boundingBox_ = boundingBox; }
void integrateRelabeled(Mat& img, Mat& imgBlurred, const std::vector<TLDDetector::LabeledPatch>& patches);
void integrateAdditional(const std::vector<Mat_<uchar> >& eForModel, const std::vector<Mat_<uchar> >& eForEnsemble, bool isPositive);
#ifdef HAVE_OPENCL
void ocl_integrateAdditional(const std::vector<Mat_<uchar> >& eForModel, const std::vector<Mat_<uchar> >& eForEnsemble, bool isPositive);
#endif
Size getMinSize(){ return minSize_; }
void printme(FILE* port = stdout);
Ptr<TLDDetector> detector;

@ -123,9 +123,11 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
if (i == 1)
{
#ifdef HAVE_OPENCL
if (ocl::haveOpenCL())
DETECT_FLG = tldModel->detector->ocl_detect(imageForDetector, image_blurred, tmpCandid, detectorResults, tldModel->getMinSize());
else
#endif
DETECT_FLG = tldModel->detector->detect(imageForDetector, image_blurred, tmpCandid, detectorResults, tldModel->getMinSize());
}
@ -211,17 +213,21 @@ bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox)
tldModel->integrateRelabeled(imageForDetector, image_blurred, detectorResults);
//dprintf(("%d relabeled by nExpert\n", negRelabeled));
pExpert.additionalExamples(examplesForModel, examplesForEnsemble);
if (ocl::haveOpenCL())
tldModel->ocl_integrateAdditional(examplesForModel, examplesForEnsemble, true);
else
tldModel->integrateAdditional(examplesForModel, examplesForEnsemble, true);
#ifdef HAVE_OPENCL
if (ocl::haveOpenCL())
tldModel->ocl_integrateAdditional(examplesForModel, examplesForEnsemble, true);
else
#endif
tldModel->integrateAdditional(examplesForModel, examplesForEnsemble, true);
examplesForModel.clear(); examplesForEnsemble.clear();
nExpert.additionalExamples(examplesForModel, examplesForEnsemble);
if (ocl::haveOpenCL())
tldModel->ocl_integrateAdditional(examplesForModel, examplesForEnsemble, false);
else
tldModel->integrateAdditional(examplesForModel, examplesForEnsemble, false);
#ifdef HAVE_OPENCL
if (ocl::haveOpenCL())
tldModel->ocl_integrateAdditional(examplesForModel, examplesForEnsemble, false);
else
#endif
tldModel->integrateAdditional(examplesForModel, examplesForEnsemble, false);
}
else
{

@ -892,6 +892,7 @@ void SURF_Impl::detectAndCompute(InputArray _img, InputArray _mask,
CV_Assert(!_img.empty() && CV_MAT_DEPTH(imgtype) == CV_8U && (imgcn == 1 || imgcn == 3 || imgcn == 4));
CV_Assert(_descriptors.needed() || !useProvidedKeypoints);
#ifdef HAVE_OPENCL
if( ocl::useOpenCL() )
{
SURF_OCL ocl_surf;
@ -918,6 +919,7 @@ void SURF_Impl::detectAndCompute(InputArray _img, InputArray _mask,
return;
}
}
#endif // HAVE_OPENCL
Mat img = _img.getMat(), mask = _mask.getMat(), mask1, sum, msum;

@ -64,6 +64,7 @@ public:
bool upright;
};
#ifdef HAVE_OPENCL
class SURF_OCL
{
public:
@ -145,6 +146,7 @@ protected:
int status;
};
#endif // HAVE_OPENCL
/*
template<typename _Tp> void copyVectorToUMat(const std::vector<_Tp>& v, UMat& um)

@ -43,6 +43,9 @@
//
//M*/
#include "precomp.hpp"
#ifdef HAVE_OPENCL
#include "surf.hpp"
#include <cstdio>
@ -461,3 +464,4 @@ bool SURF_OCL::calcOrientation(UMat &keypoints)
}
}
#endif // HAVE_OPENCL

Loading…
Cancel
Save