-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export face detect as library project & rename jni library
- Loading branch information
1 parent
e69fd1b
commit 538eb4c
Showing
2,071 changed files
with
583 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
154 changes: 77 additions & 77 deletions
154
app/CMakeLists.txt → opencv_face_detect/CMakeLists.txt
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,78 @@ | ||
# For more information about using CMake with Android Studio, read the | ||
# documentation: https://d.android.com/studio/projects/add-native-code.html | ||
|
||
# Sets the minimum version of CMake required to build the native library. | ||
|
||
cmake_minimum_required(VERSION 3.4.1) | ||
|
||
# Creates and names a library, sets it as either STATIC | ||
# or SHARED, and provides the relative paths to its source code. | ||
# You can define multiple libraries, and CMake builds them for you. | ||
# Gradle automatically packages shared libraries with your APK. | ||
|
||
# 设置native目录 | ||
set(NATIVE_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp) | ||
|
||
# 设置dlib | ||
include(${NATIVE_DIR}/dlib/cmake) | ||
|
||
# 设置opencv include文件夹 | ||
include_directories(${NATIVE_DIR}/opencv/jni/include) | ||
|
||
# 设置opencv so库 | ||
add_library( | ||
libopencv_java3 | ||
SHARED | ||
IMPORTED) | ||
|
||
set_target_properties( | ||
libopencv_java3 | ||
PROPERTIES | ||
IMPORTED_LOCATION | ||
${NATIVE_DIR}/opencv/libs/${ANDROID_ABI}/libopencv_java3.so) | ||
|
||
# 将jni_common目录中所有文件名,存至SRC_LIST中 | ||
AUX_SOURCE_DIRECTORY(${NATIVE_DIR}/jni_common SRC_LIST) | ||
|
||
add_library( # Sets the name of the library. | ||
native-lib | ||
|
||
# Sets the library as a shared library. | ||
SHARED | ||
|
||
# Provides a relative path to your source file(s). | ||
|
||
${SRC_LIST} | ||
src/main/cpp/face_detector.h | ||
src/main/cpp/face_detector.cpp | ||
src/main/cpp/native-lib.cpp) | ||
|
||
# Searches for a specified prebuilt library and stores the path as a | ||
# variable. Because CMake includes system libraries in the search path by | ||
# default, you only need to specify the name of the public NDK library | ||
# you want to add. CMake verifies that the library exists before | ||
# completing its build. | ||
|
||
find_library( # Sets the name of the path variable. | ||
log-lib | ||
|
||
# Specifies the name of the NDK library that | ||
# you want CMake to locate. | ||
log) | ||
|
||
# Specifies libraries CMake should link to your target library. You | ||
# can link multiple libraries, such as libraries you define in this | ||
# build script, prebuilt third-party libraries, or system libraries. | ||
|
||
target_link_libraries( # Specifies the target library. | ||
native-lib | ||
dlib | ||
libopencv_java3 | ||
jnigraphics | ||
# Links the target library to the log library | ||
# included in the NDK. | ||
${log-lib}) | ||
|
||
# 指定release编译选项 | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s -O3 -Wall") | ||
# For more information about using CMake with Android Studio, read the | ||
# documentation: https://d.android.com/studio/projects/add-native-code.html | ||
|
||
# Sets the minimum version of CMake required to build the native library. | ||
|
||
cmake_minimum_required(VERSION 3.4.1) | ||
|
||
# Creates and names a library, sets it as either STATIC | ||
# or SHARED, and provides the relative paths to its source code. | ||
# You can define multiple libraries, and CMake builds them for you. | ||
# Gradle automatically packages shared libraries with your APK. | ||
|
||
# 设置native目录 | ||
set(NATIVE_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp) | ||
|
||
# 设置dlib | ||
include(${NATIVE_DIR}/dlib/cmake) | ||
|
||
# 设置opencv include文件夹 | ||
include_directories(${NATIVE_DIR}/opencv/jni/include) | ||
|
||
# 设置opencv so库 | ||
add_library( | ||
libopencv_java3 | ||
SHARED | ||
IMPORTED) | ||
|
||
set_target_properties( | ||
libopencv_java3 | ||
PROPERTIES | ||
IMPORTED_LOCATION | ||
${NATIVE_DIR}/opencv/libs/${ANDROID_ABI}/libopencv_java3.so) | ||
|
||
# 将jni_common目录中所有文件名,存至SRC_LIST中 | ||
AUX_SOURCE_DIRECTORY(${NATIVE_DIR}/jni_common SRC_LIST) | ||
|
||
add_library( # Sets the name of the library. | ||
facedetec-lib | ||
|
||
# Sets the library as a shared library. | ||
SHARED | ||
|
||
# Provides a relative path to your source file(s). | ||
|
||
${SRC_LIST} | ||
src/main/cpp/face_detector.h | ||
src/main/cpp/face_detector.cpp | ||
src/main/cpp/native-lib.cpp) | ||
|
||
# Searches for a specified prebuilt library and stores the path as a | ||
# variable. Because CMake includes system libraries in the search path by | ||
# default, you only need to specify the name of the public NDK library | ||
# you want to add. CMake verifies that the library exists before | ||
# completing its build. | ||
|
||
find_library( # Sets the name of the path variable. | ||
log-lib | ||
|
||
# Specifies the name of the NDK library that | ||
# you want CMake to locate. | ||
log) | ||
|
||
# Specifies libraries CMake should link to your target library. You | ||
# can link multiple libraries, such as libraries you define in this | ||
# build script, prebuilt third-party libraries, or system libraries. | ||
|
||
target_link_libraries( # Specifies the target library. | ||
facedetec-lib | ||
dlib | ||
libopencv_java3 | ||
jnigraphics | ||
# Links the target library to the log library | ||
# included in the NDK. | ||
${log-lib}) | ||
|
||
# 指定release编译选项 | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s -O3 -Wall") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -O3 -Wall") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 32 | ||
//TODO the NDK must pass build must set spec ndkVersion , can not over 21.X.XXXXXXX | ||
ndkVersion "21.4.7075529"//20.0.5594570 21.0.6113669 21.1.6352462 21.4.7075529 21.4.7075529 //Ref : https://developer.android.com/studio/projects/install-ndk | ||
defaultConfig { | ||
minSdkVersion 21 | ||
targetSdkVersion 32 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' | ||
externalNativeBuild { | ||
cmake { | ||
arguments "-DCMAKE_BUILD_TYPE=Release" | ||
cppFlags "-std=c++11 -frtti -fexceptions" | ||
} | ||
} | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
externalNativeBuild { | ||
cmake { | ||
path "CMakeLists.txt" | ||
} | ||
} | ||
sourceSets { | ||
main { | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'androidx.annotation:annotation:1.5.0' | ||
} |
Oops, something went wrong.