Android Studio 4.1.2或以上版本。链接:Android Studio
OpenCV for Android 4.5.0,链接:OpenCV
cmake_minimum_required(VERSION 3.10.2)
project("opencv450")
set(libs ${CMAKE_SOURCE_DIR}/..)
include_directories(${libs}/cpp/include)
add_library(libcpufeatures STATIC IMPORTED)
set_target_properties(libcpufeatures PROPERTIES
IMPORTED_LOCATION "${libs}/jniLibs/${ANDROID_ABI}/libcpufeatures.a")
add_library(ittnotify STATIC IMPORTED)
set_target_properties(ittnotify PROPERTIES
INTERFACE_LINK_LIBRARIES "dl"
)
set_target_properties(ittnotify PROPERTIES
IMPORTED_LOCATION "${libs}/jniLibs/${ANDROID_ABI}/libittnotify.a")
add_library(tegra_hal STATIC IMPORTED)
set_target_properties(tegra_hal PROPERTIES
IMPORTED_LOCATION "${libs}/jniLibs/${ANDROID_ABI}/libtegra_hal.a")
add_library(tbb STATIC IMPORTED)
set_target_properties(tbb PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "TBB_USE_GCC_BUILTINS=1;__TBB_GCC_BUILTIN_ATOMICS_PRESENT=1;TBB_SUPPRESS_DEPRECATED_MESSAGES=1"
INTERFACE_LINK_LIBRARIES "c;m;dl"
)
set_target_properties(tbb PROPERTIES
IMPORTED_LOCATION "${libs}/jniLibs/${ANDROID_ABI}/libtbb.a")
add_library(opencv_core STATIC IMPORTED)
set_target_properties(opencv_core PROPERTIES
INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:dl>;\$<LINK_ONLY:m>;\$<LINK_ONLY:log>;\$<LINK_ONLY:tegra_hal>;\$<LINK_ONLY:tbb>;\$<LINK_ONLY:z>;\$<LINK_ONLY:libcpufeatures>;\$<LINK_ONLY:ittnotify>;\$<LINK_ONLY:tegra_hal>"
)
set_target_properties(opencv_core PROPERTIES
IMPORTED_LOCATION "${libs}/jniLibs/${ANDROID_ABI}/libopencv_core.a")
add_library(opencv_imgproc STATIC IMPORTED)
set_target_properties(opencv_imgproc PROPERTIES
INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:opencv_core>;opencv_core;\$<LINK_ONLY:dl>;\$<LINK_ONLY:m>;\$<LINK_ONLY:log>;\$<LINK_ONLY:tegra_hal>"
)
set_target_properties(opencv_imgproc PROPERTIES
IMPORTED_LOCATION "${libs}/jniLibs/${ANDROID_ABI}/libopencv_imgproc.a")
add_library(
native-lib
SHARED
native-lib.cpp)
find_library(
log-lib
log)
target_link_libraries(
native-lib
opencv_core
opencv_imgproc
${log-lib})
externalNativeBuild {
cmake {
abiFilters 'armeabi-v7a','arm64-v8a'
cppFlags "-std=c++11","-frtti", "-fexceptions -lz"
}
}
ndk {
abiFilters 'armeabi-v7a','arm64-v8a'
}
// android 节点下
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
// 新建jniLibs存放静态库
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs', 'lib']
}
}
JNI是Java Native Interface(Java本地接口)的缩写。JNI作为java和操作系统间的一个直接接口,可以通过JNI使得java直接调用操作系统的资源。目前JNI只能通过c/C++实现,因为jni只是对操作系统资源调用的一个桥接过程。java代码编译之后是运行在一个jvm里,所以java的任何操作对操作系统而言都是隔着一层虚拟机外壳,这点也正式java的优点,帮助java实现了“Write Once, Run Everywhere”的可移植性。但是使用了jni之后必须要明白这个“Write Once, Run Everywhere”要被打破,必须要实现不同的操作系统的各种jni版本。
4. 对比度,图片的对比度是指一幅图像中明暗区域最亮的白和最暗的黑不同亮度层级的测量,对比度中画面黑与白的比值差异范围越大代表对比越大,反之越小。增强对比度的方法有多种,本设计采用“自适应直方图均衡”的方式处理,对比度参考文献。
implementation project(path: ':opencv450')
include ':opencv450'
1. 先进入gradle下载网页下载对应的gradle,本项目使用的是gradle-6.5-bin。
distributionUrl=file:///D:/.gradle/wrapper/dists/gradle-6.5-bin.zip
# GitHub Start
192.30.253.112 Build software better, together
192.30.253.119 gist.github.com
151.101.184.133 assets-cdn.github.com
151.101.184.133 raw.githubusercontent.com
151.101.184.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.184.133 camo.githubusercontent.com
151.101.184.133 avatars0.githubusercontent.com
151.101.184.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
151.101.184.133 avatars3.githubusercontent.com
151.101.184.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
151.101.184.133 avatars8.githubusercontent.com
# GitHub End
如果还是不行,可以下载markdown编辑器阅读本文的。这里推荐一款比较好用的markdown编辑器:Typora。下载安装完成之后用Typora打开Readme.md文件即可。