What are the steps necessary for me to integrate,
into a pure C++(No Java Code) Android NDK project, such as Android NDK Google tutorial:
official documentation for android integration refers to much older version :OpenCV-2.4 and folder structures are no longer the same.
I am using Android Studio on Linux.
All help is highly Appreciated.
Download opencv Android package (eg opencv-4.0.1-android-sdk ) and unpack to, say, ~/android
.
To the bottom of CMakeLists.txt , add
set( OpenCV_DIR "~/android/OpenCV-android-sdk/sdk/native/jni" ) find_package( OpenCV REQUIRED ) target_link_libraries(game opencv_java)
The package will define the following variables:
OpenCV_LIBS : The list of all imported targets for OpenCV modules.
OpenCV_INCLUDE_DIRS : The list of OpenCV include directories. With CMake >= 2.8.11 you don't even need to write
include_directories(${OpenCV_INCLUDE_DIRS})
This version of prebuilt OpenCV SDK defines also
OpenCV_VERSION : The version of this OpenCV build: "4.0.1"
OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API: "16" .
This means that your app manifest needs minSdkVersion 16 or higher (the original sample needs a fix here ).
Instead of the shared library that contains all OpenCV functionality, you can use static libraries ( opencv_imgcodecs , opencv_stitching , et al ). These static libraries assume the default ANDROID_STL=c++_static .
For best results, use NDK r.18 or r.19 .
UPDATE: NDK r.21 works well for opencv 4.3.0 .
If you would like to create shared objects (.so)
and compile without using Android studio, here is my blog . This is often useful when you would like to create a native third-party library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.