Ask Your Question
0

Performance issue with Android arm64-v8a custom build [closed]

asked 2018-07-16 09:43:05 -0600

Evren gravatar image

updated 2018-07-17 10:11:59 -0600

Hello,

I have successfully built OpenCV for Android using the c++_static STL and clang on an Ubuntu 16.04 machine. Functionality I have tested so far appears to be OK.

On armeabi-v7a, execution performance (as in time it takes to run inferences within the DNN module) matches the performance that I get if I use the official 3.4.1 Android libraries. However, when I build for arm64-v8a, performance of the custom build is about 3x slower than the official OpenCV Android libraries for the same ABI. I can't figure out what the variance (apart from c++_static) in my build configuration may be.

The only reason I'm running my own build is that I require a c++_static build due to other dependencies in my project which I'm unable to change.

If anyone is able to and willing to review and help, below is the CMAKE configuration that I'm using to build the arm64-v8a library. Why is my custom built library slower than the official OpenCV Android arm64-v8a release? What can I do to match performance?

ANDROID_ABI:STRING=arm64-v8a

ANDROID_ARM_NEON:BOOL=ON

//Build binaries of Android examples with native libraries
ANDROID_EXAMPLES_WITH_LIBS:BOOL=OFF

ANDROID_PLATFORM:STRING=android-25

ANDROID_STL:STRING=c++_static

//Build examples for Android platform
BUILD_ANDROID_EXAMPLES:BOOL=OFF

//Build Android projects providing .apk files
BUILD_ANDROID_PROJECTS:BOOL=OFF

//Build OpenCV Manager for Google Play
BUILD_ANDROID_SERVICE:BOOL=OFF

//Build CUDA modules stubs when no CUDA SDK
BUILD_CUDA_STUBS:BOOL=OFF

//Create build rules for OpenCV Documentation
BUILD_DOCS:BOOL=OFF

//Build all examples
BUILD_EXAMPLES:BOOL=OFF

//Build libjasper from source
BUILD_JASPER:BOOL=ON

//Enable Java support
BUILD_JAVA:BOOL=ON

//Build libjpeg from source
BUILD_JPEG:BOOL=ON

//Build only listed modules (comma-separated, e.g. 'videoio,dnn,ts')
BUILD_LIST:STRING=

//Build openexr from source
BUILD_OPENEXR:BOOL=ON

//Enables 'make package_source' command
BUILD_PACKAGE:BOOL=ON

//Build performance tests
BUILD_PERF_TESTS:BOOL=OFF

//Build libpng from source
BUILD_PNG:BOOL=OFF

//Force to build libprotobuf from sources
BUILD_PROTOBUF:BOOL=ON

//Build shared libraries (.dll/.so) instead of static ones (.lib/.a)
BUILD_SHARED_LIBS:BOOL=ON

//Download and build TBB from source
BUILD_TBB:BOOL=ON

//Build accuracy & regression tests
BUILD_TESTS:BOOL=OFF

//Build libtiff from source
BUILD_TIFF:BOOL=ON

//Use symlinks instead of files copying during build (and !!INSTALL!!)
BUILD_USE_SYMLINKS:BOOL=OFF

//Build WebP from source
BUILD_WEBP:BOOL=ON

//Include debug info into release binaries ('OFF' means default
// settings)
BUILD_WITH_DEBUG_INFO:BOOL=OFF

//Enables dynamic linking of IPP (only for standalone IPP)
BUILD_WITH_DYNAMIC_IPP:BOOL=OFF

//Build zlib from source
BUILD_ZLIB:BOOL=OFF

//Build utility applications (used for example to train classifiers)
BUILD_opencv_apps:BOOL=OFF

//Include opencv_calib3d module into the OpenCV build
BUILD_opencv_calib3d:BOOL=ON

//Include opencv_core module into the OpenCV build
BUILD_opencv_core:BOOL=ON

//Include opencv_dnn module into the OpenCV build
BUILD_opencv_dnn:BOOL=ON

//Include opencv_features2d module into the OpenCV build
BUILD_opencv_features2d:BOOL=ON

//Include opencv_flann module into the OpenCV build
BUILD_opencv_flann:BOOL=ON

//Include opencv_highgui module into the OpenCV build
BUILD_opencv_highgui:BOOL=ON

//Include opencv_imgcodecs module into the OpenCV build
BUILD_opencv_imgcodecs:BOOL=ON

//Include opencv_imgproc ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Evren
close date 2018-07-19 02:50:12.471704

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-07-18 12:07:28 -0600

Evren gravatar image

OK, I found my mistake and solved the issue. I was building libopencv_world.so as I didn't have the CMAKE option build_opencv_java.

Going through the output of CMAKE Configure, I noticed that CMAKE wasn't picking up ANT. So I added the path to ANT by specifying ANT_EXECUTABLE in CMAKE. This gave me the options BUILD_FAT_JAVA_LIB and BUILD_OPENCV_JAVA. I made sure these were selected and also deselected BUILD_OPENCV_WORLD and BUILD_SHARED_LIBS.

I also changed the parallelization framework from OpenMP to TBB. All is fine now and performance is just as good as the official OpenCV releases for Android both on armeabi-v7a and arm64-v8a.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-07-16 09:43:05 -0600

Seen: 1,382 times

Last updated: Jul 18 '18