gpt4 book ai didi

android - 使用JavaCV Android Studio的问题

转载 作者:行者123 更新时间:2023-12-02 17:44:30 24 4
gpt4 key购买 nike

因此,我尝试将JavaCV与Android Studio结合使用。我正在尝试将包装用于FaceRecognizer类。我已经尝试使此代码运行数小时,但到目前为止还没有运气。我不断收到构建错误:

     Error:A problem occurred configuring project ':app'.
> Could not find javacpp-presets-Mac OS X-x86_64.jar
(org.bytedeco:javacpp-presets:1.2).
Searched in the following locations:
https://jcenter.bintray.com/org/bytedeco/javacpppresets/1.2/javacpp-presets-1.2-Mac OS X-x86_64.jar'

我为opencv解压缩了.so文件,并将其分为两个文件:armeabi和x86,所以没问题。

这是我的build.gradle文件:
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
sourceSets.main.jni.srcDirs = []

//task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
// ndkDir = project.plugins.findPlugin('com.android.application').sdkHandler.getNdkFolder()
// //on Windows, you need to add ".cmd" after "ndk-build" below
// commandLine "$ndkDir/ndk-build",
// 'NDK_PROJECT_PATH=build/intermediates/ndk',
// 'NDK_LIBS_OUT=src/main/jniLibs',
// 'APP_BUILD_SCRIPT=src/main/jniLibs/Android.mk',
// 'NDK_APPLICATION_MK=src/main/jniLibs/Application.mk'
//}
//task ndkLibsToJar(type: Zip, dependsOn: 'ndkBuild', description: 'Create a JAR of the native libs') {
// destinationDir new File(buildDir, 'libs')
// baseName 'ndk-libs'
// extension 'jar'
// from(new File(buildDir, 'libs')) { include '**/*.so' }
// into 'lib/'
//}
//tasks.withType(JavaCompile) {
// compileTask -> compileTask.dependsOn ndkBuild
//}
defaultConfig {
applicationId "com.example.manavdutta1.affdexdemo"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
//exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
//exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'

//might need these if you use openCV
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile fileTree(dir: new File(buildDir, 'libs'), include: '*.jar')
testCompile 'junit:junit:4.12'
compile project(path: ':openCVLibrary2411')
compile files('src/main/libs/faceapi.jar')
compile files('src/main/libs/faceppsdk.jar')
//compile files('src/main/libs/artoolkitplus.jar')
//compile files('src/main/libs/ffmpeg.jar')
//compile files('src/main/libs/flandmark.jar')
//compile files('src/main/libs/flycapture.jar')
//compile files('src/main/libs/javacpp.jar')
//compile files('src/main/libs/javacv.jar')
//compile files('src/main/libs/arm/opencv-android-arm.jar')
//compile files('src/main/libs/x86/opencv-android-x86.jar')
//compile files('src/main/libs/libdc1394.jar')
//compile files('src/main/libs/libfreenect.jar')
//compile files('src/main/libs/opencv.jar')
//compile files('src/main/libs/videoinput.jar')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.affectiva.android:affdexsdk:3.0.1'
compile 'com.microsoft.projectoxford:face:1.0.0'
compile 'com.microsoft.projectoxford:emotion:1.0.0'
compile 'com.android.support:design:23.3.0'
compile 'org.bytedeco:javacv:1.2'
compile 'org.bytedeco.javacpp-presets:opencv:3.0.0-1.1:android-x86'
compile 'org.bytedeco.javacpp-presets:opencv:3.0.0-1.1:android-arm'
//compile group: 'org.bytedeco', name: 'javacv', version: '1.2'

//compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '2.4.10-0.10', classifier: 'android-arm'
//compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.5.1-0.10', classifier: 'android-arm'

}

我不确定如何从这里继续。我需要对build.gradle进行哪些修改才能进行编译?我尝试使用javacv 1.1,但在运行时出现错误,.so文件全部来自javacv 1.2。

最佳答案

我有一个类似的问题。 Gradle的依赖项解析中显然存在一个错误。 Javacpp的作者已经提供了一种解决方法,请参见此处:https://github.com/bytedeco/javacv/issues/432

尝试在build.gradle脚本中包含以下代码:

configurations {
all*.exclude group: 'org.bytedeco', module: 'javacpp-presets'
}

它对我有用,希望对您有用。

关于android - 使用JavaCV Android Studio的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38277863/

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