gpt4 book ai didi

android - 在 android studio 上使用 NDK 构建原生 openCV

转载 作者:太空宇宙 更新时间:2023-11-04 13:27:52 25 4
gpt4 key购买 nike

我正在制作一个使用 openCV 的 C++ 项目,我希望使用 android NDK 支持在 android studio 上构建它。
这样做我发现只有 gradle 的实验版本支持 NDK。我目前使用的是 0.2.1 版的 gradle。我将 opencv 作为模块导入,并将库复制到 src/main/下的 jniLibs 文件夹

我试图编译它,但我遇到了某些错误,例如对 libopencv_core.a 的 parallel.cpp 中某些函数的 undefined reference 。他们决定导入第三方库:libtbb.a

但是在运行时出现了以下错误:
java.lang.UnsatisfiedLinkError:dlopen 失败:无法找到“libtracking_bits.so”引用的符号“__gnu_thumb1_case_si”

这是我的 build.gradle :

apply plugin: 'com.android.model.application'

model {
android {
compileSdkVersion = 21
buildToolsVersion = "22.0.1"

defaultConfig.with {
applicationId = "com.example.vlc.receiver"
minSdkVersion.apiLevel = 16
targetSdkVersion.apiLevel = 21
versionCode = 1
versionName = "1.0"


}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
debug {
minifyEnabled = false
}
}
android.ndk {
moduleName = "tracking_bits"

cppFlags += "-fexceptions"
cppFlags += "-frtti"
cppFlags += "-I${file("OpenCV-android-sdk/sdk/native/jni/include")}".toString()
cppFlags += "-I${file("OpenCV-android-sdk/sdk/native/jni/include/opencv")}".toString()

ldLibs += ["android", "EGL", "GLESv2", "dl", "log", "z"]// , "ibopencv_core"
stl = "gnustl_shared"

}


android.productFlavors {
create("arm") {
ndk.with {
abiFilters += "armeabi"

File curDir = file('./')
curDir = file(curDir.absolutePath)
String libsDir = curDir.absolutePath+"\\src\\main\\jniLibs\\armeabi\\" //"-L" +

ldLibs += libsDir + "libopencv_calib3d.a"
ldLibs += libsDir + "libopencv_core.a"
ldLibs += libsDir + "libopencv_features2d.a"
ldLibs += libsDir + "libopencv_flann.a"
ldLibs += libsDir + "libopencv_hal.a"
ldLibs += libsDir + "libopencv_highgui.a"
ldLibs += libsDir + "libopencv_imgcodecs.a"
ldLibs += libsDir + "libopencv_imgproc.a"
ldLibs += libsDir + "libopencv_java3.so"
ldLibs += libsDir + "libopencv_ml.a"
ldLibs += libsDir + "libopencv_objdetect.a"
ldLibs += libsDir + "libopencv_photo.a"
ldLibs += libsDir + "libopencv_shape.a"
ldLibs += libsDir + "libopencv_stitching.a"
ldLibs += libsDir + "libopencv_superres.a"
ldLibs += libsDir + "libopencv_ts.a"
ldLibs += libsDir + "libopencv_video.a"
ldLibs += libsDir + "libopencv_videoio.a"
ldLibs += libsDir + "libopencv_videostab.a"
ldLibs += "OpenCV-android-sdk\\sdk\\native\\3rdparty\\libs\\armeabi\\libtbb.a"
}
}
}

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile project(':openCVLibrary300')
}

我卡住了。请帮忙。

最佳答案

我也添加了所有第 3 方库,这允许为 arm 编译。公平地说,我还在 jniLibs 中添加了第 3 方库,只是为了避免像您在那里所做的那样更改路径。否则,我和你的配置完全一样,以至于我在前一阶段复制并粘贴了你的文件。

        ldLibs += libsDir + "libIlmImf.a"
ldLibs += libsDir + "liblibjpeg.a"
ldLibs += libsDir + "liblibjasper.a"
ldLibs += libsDir +"liblibpng.a"
ldLibs += libsDir +"liblibwebp.a"

关于android - 在 android studio 上使用 NDK 构建原生 openCV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32724232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com