Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to build custom opencv for android (and test application using c++ client code as well as java ui)

Hello.

How can I build opencv myself on android such that I can write other native c++ application code that interacts with it?

Im using Android studio 2.2 with ndk installed. Most examples/documentation seems to be geared toward eclipse and the older .mk build system rather tham Android Studio and gradle.

More details:

I have a windows c++ application thst uses opencv. I want to port this application to android. So I need to port not only my application (c++) code but also opencv to android. My application code can be split into 2 parts: User interface part and the lower level part that interacts directly with opencv. The part of my application code that interacts with opencv I want to leave in c++, and just create a user interface in java. So I want an android (java) ui, that "talks" to my other c++ native code, which in turn "talks" to the opencv library code. (This way I can presumably port more easily later to iOS).

Is there an exmaple anywhere of this (ideally using Android Studio, and gradle)?

I have downloaded the opencv android sdk (linked from http://opencv.org/downloads.html)

https://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.9/OpenCV-2.4.9-android-sdk.zip/download

to create an application with Android Studio solely in java that talks to opencv. I followed the advice here: http://stackoverflow.com/questions/17767557/how-to-use-opencv-in-android-studio-using-gradle-build-tool

To do this I had to copy the precompiled libraries that came with the sdk (sdk/native/libs/libopencv_core.a etc) to my android project dir. One probblem I have with this is that the precompiled libraries are not available for my android test device (which requires "arm64-v8a") . So Id like to be able to compile them myself and specify that it should also build for arm64-v8a, and not just: "armeabi" "armeabi-v7a" "mips" "x86". (The opencv sdk 3.1.0 has "arm64-v8a" "armeabi" "armeabi-v7a" "mips" "mips64" "x86" "x86_64") but I need to use earlier versions of opencv too. the other problem is that it wasnt quite clear how to write other c++ code that interacts with opencv here (only java).

Id be very grateful for any help.

Thanks in Advance.