Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

http://silverglint.com/opencv-on-android/

Here are instructions on how to achieve this taken from here:

http://silverglint.com/opencv-on-android/


The detailed instructions here are apply to a development machine running Linux, but the procedure should be very similar on Windows/MacOS(X)

 Clone the main OpenCV repository from GitHub:
git clone https://github.com/opencv/opencv.git {path_to_local_clone_of_opencv_repo}/opencv_github
Change to the opencv platforms dir
cd {path_to_local_clone_of_opencv_repo}/opencv_github/platforms
Add android’s cmake to your PATH environment variable:
export PATH={path_to_local_android_installation}/android/sdk/cmake/3.6.3155560/bin/:$PATH
Note: You may need to modify the cmake version number depending on your android installation
Point ANDROID_NDK to the install location:
export ANDROID_NDK={path_to_local_android_installation}/android/sdk/ndk-bundle/
or
export ANDROID_NDK={path_to_local_crystax_installation}/crystax/crystax-ndk-10.3.2
Configure the build
sh ./scripts/cmake_android_arm.sh .
This creates a build directory and runs a CMake command to populate the directory with a particular configuration of OpenCV.
Note:
(i) You can edit this script if you want a different configuration. eg “cmake -DBUILD_SHARED_LIBS=ON….” if you want shared libs, instead of the default dynamic libs.
(ii) Call one of the other scripts instead if you want to build for a different cpu architecture (abi) eg to build instead for x86:
"./scripts/cmake_android_x86.sh"
Start the build
cd build_android_arm
make -j8
Note: The –j8 flag specifies that the make command will use 8 threads. You could specify a different number if you have reason for doing so.

You should now have the freshly built OpenCV libraries in {path_to_local_clone_of_opencv_repo}/opencv_github/platforms//build_android_arm/lib/armeabi-v7a/

Note: After the first build cmake caches options in the following location: {path_to_local_clone_of_opencv_repo}/opencv_github/platforms/build_android_arm/CMakeCache.txt You can peruse and edit these (and then repeat the previous 2 steps), if you want to perform any customizations of the build.