Don't say much nonsense.
Preparatory work:
1. Download Source codes: http://opencv.org/
Build platform: ubuntu14.04
OpenCV 2.4.6.1
I use such a method to compile the Opecv 2.4.9 no problem, the problem is less than opencv2.4.6.1, in fact, their principle is the same.
OpenCV Source Code root folder----${opencv_home}
2.
Change ${opencv_home}/platforms/scripts/cmake_android_arm.sh file, add compile options-dbuild_shared_libs=on and-DWITH_OPENCL=ON
The modified cmake_android_arm.sh file is as follows:
#!/bin/shcd ' dirname '/. Mkdir-p BUILD_ANDROID_ARMCD build_android_armcmake-dcmake_build_with_install_rpath=on-dcmake_toolchain_file=. /android/android.toolchain.cmake [email protected]. /.. -dbuild_shared_libs=on-dwith_opencl=on
3.
Change ${opencv_home}/cmake/opencvdetectopencl.cmake
To generate compile options that support compiling OpenCL:
Add after Opencvdetectopencl.cmake 40 line
Set (Opencl_found YES) set (Opencl_include_dir your_ocl_include_dir) #set (opencl_library You_opencl_lib_file_ Path
One is to set the OCL header file, a set of OpenCL library files, and the above to stare him off because I want to use a dynamic display called the way to invoke the OpenCL library API. This does not have to be compiled into the device-related OpenCL library.
4.
Change ${opencv_home}/"Include OpenCL Runtimesupport" on IF (not IOS))
This step looks like the source code in the opencv2.4.9 version number is not set to be able.
The main purpose of this is to enable the next generation of OpenCL-enabled options.
5. Run ${opencv_home}/platforms/scripts/cmake_android_arm.sh
Assume that there is a problem running. To set the NDK path:
Terminal operation: Export ndkroot=/xxxx/android-ndk-r9d
can see:
-- Other Third-party libraries:
-- use IPP: & nbsp NO
-- use Eigen: &NBS P NO
-- use TBB: NO
-- use OpenMP: no
-- & nbsp Use GCD no
– use Concurrency no
-- use c=: no
-- use Cuda: no
-- use OpenCL: yes
This makes it possible to compile the relevant libraries. Just assume there's no setting
Set (Opencl_library You_opencl_lib_file_path)
This may lead to some test compilation just go, no relationship, OCL's related library has been able to compile.
6. Switch to the ${opencv_home}/platforms/build_android_arm folder:
Run: Make
Wait for the compilation to complete ...
7. Finally Andorid Dynamic Library is generated under ${opencv_home}/platforms/build_android_arm/lib/armeabi-v7a
For Android x86, the same way Android Arm library is compiled, just step 2, 5 action script is ${opencv_home}/platforms/scripts/cmake_android_ X86.sh
I wish you a pleasant use. What's the problem. Welcome to point out. For correction.
Build OpenCV libraries for Android arm, x86 ubuntu