Skip to content

Instantly share code, notes, and snippets.

@d2rk
Last active November 18, 2018 13:18
Show Gist options
  • Save d2rk/e23996345545b61bbc5387f58a2f7cba to your computer and use it in GitHub Desktop.
Save d2rk/e23996345545b61bbc5387f58a2f7cba to your computer and use it in GitHub Desktop.
Build OpenCV for Android with LLVM C++

Download OpenCV:

$ export OPENCV_VERSION=3.4.3
$ git co opencv_contrib && cd opencv_contrib && git co $OPENCV_VERSION
$ git co opencv
$ cd opencv
$ git co $OPENCV_VERSION
$ mkdir build-arm

Run ./cmake-gui to generate Makefile's.

  1. Click the Browse Source button and give the OpenCV source folder.
  2. Click the Browse Build button and give the build folder: build-arm
  3. Click Configure button, select Specify toolchain file for cross-compiling. In the next prompt window, make sure to select the android.toolchain.cmake under $HOME_NDK/build/cmake/. Make sure not to use the file under opencv folder.
  4. Add entries:
  • Set ANDROID_PLATFORM to android-23 (or any other)
  • Set ANDROID_STL to c++_static
  • Set BUILD_ANDROID_PROJECTS to false (skip Gradle problems)
  • Set BUILD_ANDROID_EXAMPLES to false
  • Set CMAKE_BUILD_TYPE to Release
  • Set OPENCV_EXTRA_MODULES_PATH to opencv_contrib/modules
  • Set OPENCV_ENABLE_NONFREE to true
  1. Click Configure and Generate

Build and install:

$ cd build-arm
$ make -j1
$ make install

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment