Building OpenCV4Android With OpenGL and OpenCL Support
TL;DR:
What is the "official" way to build OpenCV4Android, from source, with OpenGL and OpenCL support?
I am using the Android NDK, and was using the pre-compiled OpenCV4Android binaries. Everything was going well, until I needed to do some texture handling, and had to use the cv::ogl::Buffer
class. In this case, my code succeeded to build, because the cv::ogl
header was referenced within the core
module that is referenced in the CMake file within the pre-built binaries. However, I got the following error:
E/cv::error()(16616): OpenCV Error: No OpenGL support (The library is compiled without OpenGL support) in void {anonymous}::throw_no_ogl(), file /build/master_pack-android/opencv/modules/core/src/opengl.cpp, line 60
So, to get around this, I thought that I should re-build OpenCV4Android, trying to include the OpenGL flag, and (for posterity) explicitly turn on the OpenCL flag-- I have done custom builds on the desktop, no problem.
Building OpenCV4Android with OpenCL is actually pretty straight forward: after following this tutorial, you pass the -DWITH_OPENCL=ON
to the .sh
script for the target architecture type, and everything works fine.
However, building with OpenGL, seems really difficult. I know that there could be issues with the native OpenGL ES support that Android provides in their NDK, resulting in there being absolutely no-way to support OpenCV implementations of OpenGL. However, I find it weird that the header content for OpenGL would then still be referenced in the source code for Android builds. Also, after looking at the header file for the cv::ogl::Buffer
class, it doesn't look like anything should conflict with the OpenGL ES content present in the Android NDK.
What I have tried so far is modifying the OpenGL flags within the parent CMakeLists.txt
file in the main OpenCV directory, and the flag within the android.toolchain.cmake
file; all with no success.
Any definitive answer on this would really be appreciated! Also, including this information within the development page, would save lots of people trouble! Knowing what they can, and cannot build with is important!
(Also, sorry for not hyperlinking keywords; apparently I have insufficient karma to do so. But, every link I followed was from the openCV website, under the Android Platform list. )