0

I've been trying to figure out if a specific OpenCV (3.4) method has an OpenCL implementation backing it. I found this thread:

How to know if an OpenCV 3.0 algorithm has an OpenCL implementation in the transparent API

Which I interpret as 'run the code with a GPU profiler and see what happens' but that seems like a very inefficient approach. Is there a more systematic way I could find opencl implementations?

The reason I would like this information is that I'd like to avoid passing data to device when no gain can be achieved.

  • I'm not very familiar with OpenCV but from what I read, to use OpenCL you need to use `cv::UMat` type. So if some algorithm is good on GPU then use `cv::Mat` type. https://stackoverflow.com/questions/33602675/what-is-the-difference-between-umat-and-mat-in-opencv might be useful. – kanna Jun 13 '18 at 14:33
  • @kanna Thanks, the issue with always using UMat is that image data is constantly being copied to and from the device memory which can be very costly. I would like to have more control. – Patrik Malm Jun 15 '18 at 12:13

1 Answers1

1

I used the Debugger to step into the functions, There is a switch at the start, calling the ocl implementation if you have compiled OpenCV with OpenCL and the executable runs on a machine with a GPU.

Other Options:

  • take a look at the ocl namespace documentation for OpenCV 2.x
  • search the source code for ocl implementation. In most cases the ocl functions are in a subdirectory of the modules. E.g. modules\photo\src\opencl\nlmeans.cl
  • Having spent more time I think the best way is to look at the sourcecode and see if an ocl switch exists. Thanks! – Patrik Malm Jun 15 '18 at 12:16