Ask Your Question
0

build OpenCV 3.1 for android with openCL support

asked 2017-02-10 09:14:05 -0600

BenNG gravatar image

Hi All!

I tried OpenCL on my OpenCV project and the result is a huge improvement in terms of performance so I would like to try OpenCL on android.

I use this article to guide me. Here is my cmake command:

cmake -GNinja -DCMAKE_MAKE_PROGRAM="/usr/bin/ninja" -DCMAKE_TOOLCHAIN_FILE="../opencv-3.1.0/platforms/android/android.toolchain.cmake" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON  -DWITH_OPENCL=YES -DANDROID_ABI="armeabi-v7a" ../opencv-3.1.0

and I use this command

ninja install/strip

I have no errors neither on compilation nor installation. And an install folder has been created. I think all is perfectly fine except that I can't find the libopencv_java3.so file !!!!! so:

  1. Do you know how I can generate libopencv_java3.so ?
  2. Do you know how I can target several abis ? I tried -DANDROID_ABI="armeabi-v7a" -DANDROID_ABI="x86" and -DANDROID_ABI="armeabi-v7a x86" but it is not correct.

Thank you !

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-02-13 08:44:37 -0600

BenNG gravatar image

Turn out that there is a python script call build_sdk.py located at: /opencv-3.1.0/platforms/android.
With this script you will be able to created your own android sdk.
Before started I had to install ant (a build tool in the java ecosystem).
For the NDK I used the version r10e.

I wanted to turn ON OpenCL to have some performance improvement. So inside the script look for DWITH_OPENCL and change the flag from OFF to ON. I also had to turn off DBUILD_ANDROID_EXAMPLES and DINSTALL_ANDROID_EXAMPLES because I had some issue with them.

I created a folder opencv-build-android and inside this folder I invoke the script like this:

../opencv-3.1.0/platforms/android/build_sdk.py --ndk_path $ANDROID_NDK --sdk_path $ANDROID_SDK . ../opencv-3.1.0

be careful to the . before ../opencv-3.1.0

I hope It will help you !

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-10 09:14:05 -0600

Seen: 1,577 times

Last updated: Feb 13 '17