OpenCV 3.1.0 & OpenCL version?

asked 2016-01-11 22:52:42 -0600

--marc gravatar image

updated 2016-01-11 23:23:00 -0600

Q1. Which version of OpenCL is supported by OpenCV 3.1.0?

My guess is OpenCL 1.2 based on the set(OPENCL_INCLUDE_DIR "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2") statement in the file opencv-3.1.0/cmake/OpenCVDetectOpenCL.cmake.

Also, the cl.h OpenCL include path is opencv-3.1.0/3rdparty/include/opencl/1.2/CL

Q2. If OpenCL 1.2 is a supported version, would the following build errors be a bug to report? or some other action to resolve?

opencv-3.1.0/modules/core/src/opengl.cpp:1644:9: error: use of undeclared identifier
   'clGetGLContextInfoKHR_fn'; did you mean 'clGetContextInfo'?
    clGetGLContextInfoKHR_fn clGetGLContextInfoKHR = (clGetGLContextInfoKHR_fn)
    ^~~~~~~~~~~~~~~~~~~~~~~~
    clGetContextInfo

opencv-3.1.0/modules/core/src/opengl.cpp:1646:14: error: use of undeclared identifier
  'clGetGLContextInfoKHR'; did you mean 'clGetContextInfo'?
    if (!clGetGLContextInfoKHR)
         ^~~~~~~~~~~~~~~~~~~~~
         clGetContextInfo

opencv-3.1.0/modules/core/src/opengl.cpp:1669:52: error: use of undeclared identifier
  'CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR'
    status = clGetGLContextInfoKHR(properties, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR, ...
                                               ^

opencv-3.1.0/modules/core/src/opengl.cpp uses the symbols clGetGLContextInfoKHR, clGetGLContextInfoKHR_fn, CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR

However, /System/Library/Frameworks/OpenCL.framework/Headers/cl.h does not contain those particular 3 symbols.

BUILD FAILS WITH_OPENCL

cmake -D CMAKE_INSTALL_PREFIX=/opt/opencv/3.1.0_test \
  -D WITH_QT=5 \
  -D WITH_OPENGL=ON \
  -D WITH_OPENCL=ON \
  -D CMAKE_BUILD_TYPE=RELEASE  ..

BUILD OTHERWISE SUCCEEDS WITHOUT OPENCL

cmake -D CMAKE_INSTALL_PREFIX=/opt/opencv/3.1.0_test \
  -D WITH_QT=5 \
  -D WITH_OPENGL=ON \
  -D WITH_OPENCL=OFF \
  -D CMAKE_BUILD_TYPE=RELEASE  ..

PLATFORM: OS X 10.10.5, Qt 5.5.1, OpenCL 1.2 (/System/Library/Frameworks/OpenCL.framework/Headers/cl.h)

Device Intel Core i7-4960HQ CPU @ 2.60GHz supports OpenCL 1.2
Device Iris Pro supports OpenCL 1.2 
Device GeForce GT 750M supports OpenCL 1.2
edit retag flag offensive close merge delete

Comments

I'm having the same issue. Compiling without Qt seems to help: -DWITH_QT=OFF

max0r gravatar imagemax0r ( 2016-01-18 16:44:42 -0600 )edit

I tried installed OpenCV via homebrew and am getting the same exact errors as you. After some digging, I found each of them in the source code. clGetGLContextInfoKHR_fn is declared in cl_gl.h (in the same directory as cl.h), clGetGLContextInfoKHR is defined as a macro in opencl_gl_wrappers.hpp (an autogenerated header file), and CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR is also defined as a macro in cl_gl.h. Still not sure why this is happening though, I'm going to open an issue on github if I don't figure it out soon.

psytech140 gravatar imagepsytech140 ( 2016-01-27 17:51:21 -0600 )edit