Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Custom OpenCL Kernel in OpenCV 3.x

I am trying to build my own ocl kernel in opencv 3.x. I was looking into both opencv source code and found out that the host source code calls ocl module (in *.cl file) using ocl::Kernel and ocl::ProgramSource (as mentioned in LINK and DOC).

It seems that in opencv module there is auto-generated *.hpp and *.cpp file (e.g. for modules/imgproc -> opencl_kernels_imgproc.hpp and opencl_kernels_imgproc.cpp) These files seemed to be generated based on *.cl file.

My question is, how to auto-generate these files for your custom kernel? I am guessing that it might be a CMAKE trick, but I cannot really found it. Would very much appreciated, if anyone could point me to the code/configure that do that.

Thank you.

Custom OpenCL Kernel in OpenCV 3.x

I am trying to build my own ocl kernel in opencv 3.x. I was looking into both opencv source code and found out that the host source code calls ocl module (in *.cl file) using ocl::Kernel and ocl::ProgramSource (as mentioned in LINK and DOC).

It seems that in opencv module there is auto-generated *.hpp and *.cpp file (e.g. for modules/imgproc -> opencl_kernels_imgproc.hpp and opencl_kernels_imgproc.cpp) These files seemed to be generated based on *.cl file.

My question is, how to auto-generate these files for your custom kernel? I am guessing that it might be a CMAKE trick, but I cannot really found it. Would very much appreciated, if anyone could point me to the code/configure that do that.

Thank you.

** UPDATE ***

Seems to have something to do with

  • cmake/cl2cpp.cmake
  • cmake/OpenCVModule.cmake

Any idea to make use of it easily in your own application that will not be compiled with OpenCV?