Build OpenCV library from source for Android [closed]

asked 2020-03-23 16:11:04 -0600

CharlesC gravatar image

Hello, I recently jumped on a OpenCV project and am trying to cross-compile OpenCV shared library .so from source for Android on Windows. I set up the environment with various tools. In CMake, I chose the source code location and build directory, and the following options,

ANDROID_ABI=arm64-v8a, ANDROID_NDK, ANDROID_SDK_ROOT, ANDROID_NATIVE_API_LEVEL, BUILD_SHARED_LIB, BUILD_ANDROID, ARM64_V8A, ANDROID_TOOLCHAIN_NAME=aarch64-linux-android-4.9, CMAKE_MAKE_PROGRAM=ndk/16.x.xxxxxxx/prebuilt/windows-x86_64/bin/make.exe

After the Configure and Generate steps, on Windows, in the build directory, the build started with executing in command line ming32-make.exe. I got 14 .so library files with libopencv_java4.so, but the libopencv_java4.so does not contain all modules, with its size being 1.47 MB only. I know there are subject-experts in this forum. Can someone tell why I did not get an opencv library that contains all modules?

The libraries I got are these

libopencv_calib3d.so libopencv_features2d.so libopencv_imgcodecs.so
libopencv_ml.so
libopencv_stitching.so libopencv_core.so
libopencv_flann.so
libopencv_imgproc.so
libopencv_objdetect.so
libopencv_video.so libopencv_dnn.so
libopencv_highgui.so
libopencv_java4.so
libopencv_photo.so
libopencv_videoio.so

The libopencv_java4.so has a size of 2.14MB. I downloaded the OpenCV-android-sdk from OpenCV.org, and its size is 27.9MB. Why is my libopencv_java4.so of a so small size?

Thanks Charles

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by CharlesC
close date 2020-03-26 10:45:51.322323

Comments

cmake -DBUILD_SHARED_LIBS=OFF should get you a "fat" opencv_java so, which contains all others

berak gravatar imageberak ( 2020-03-24 04:50:07 -0600 )edit

I found that setting BUILD_opencv_world created the library expected.

CharlesC gravatar imageCharlesC ( 2020-03-26 10:45:40 -0600 )edit