0

I use the following code for feature detection:

auto detector = cv::xfeatures2d::SURF::create();
std::vector<cv::KeyPoint> keypoints;

for (const cv::Mat& image : images) {
    detector->detect(image, keypoints);
    process(keypoints);
}

Now I try to use OpenCL version of SURF. I modified my code to work with cv::UMat. Unfortunately, execution time does not change. HAS_OPENCL is set, cv::ocl::useOpenCL() is true. What could go wrong?

Anton3
  • 577
  • 4
  • 14
  • did you find http://docs.opencv.org/2.4/modules/nonfree/doc/feature_detection.html#ocl-surf-ocl and http://code.opencv.org/attachments/1560/surf.ocl.cpp ?? – Micka Jul 31 '16 at 10:58
  • @Micka Unfortunately, this relates to OpenCL 2.4, not 3.0. `SURF_OCL` doesn't even exist there. – Anton3 Aug 01 '16 at 18:41
  • 1
    Did you try calling `cv::ocl::setUseOpenCL(true);` explicitly? But http://answers.opencv.org/question/63452/opencv-30-the-performance-of-umat/ says that there might be many functions that weren's converted to the new api, so probably the/many non-free functions belong to them. – Micka Aug 01 '16 at 19:31
  • 1
    is it possible to check the OCL device? Maybe you have got multiple devices and a slow one is selected? – Micka Aug 01 '16 at 19:32
  • did you find http://stackoverflow.com/questions/33417451/how-can-i-change-the-device-on-wich-opencl-code-will-be-executed-with-umat-in-op ? – Micka Aug 01 '16 at 19:36
  • 1
    @Micka It is possible, but unfortunately, I've already moved to using `SURF_CUDA` :P – Anton3 Aug 02 '16 at 20:09

1 Answers1

0

I know that I'm a little bit late for this, but looking at surf.cpp, SURF_Impl::detectAndCompute starts with a #ifdef HAVE_OPENCL, so I think that if you built OpenCV with OpenCL enabled, OpenCL is used by default

justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
  • Okay, but then it means that OpenCL implementation was 10 times slower than CUDA on my computer. Seems strange to me. – Anton3 Feb 07 '17 at 16:38
  • @Anton3 just as info: which CUDA SURF implementation are you using? How long does it take for you on avg to describe only **one** image using GPU approach? Please if possible specify also the image size and the used GPU – justHelloWorld Feb 08 '17 at 08:42
  • I use SURF_CUDA from OpenCV. It takes about 0.2 seconds with SURF_CUDA and about 2 seconds with normal SURF class. Image size is 1920x1080, GPU is GTX 970. Edit: well, it took, because I did the tests half a year ago. – Anton3 Feb 09 '17 at 11:51