JavaCV + Android的工作室+ gradle-可能吗? [英] JavaCV + Android Studio + gradle- possible?
问题描述
我试图与Android Studio和摇篮使用JavaCV。我写了这样的code片段:
I'm trying use JavaCV with Android Studio and Gradle. I wrote such code fragment:
repositories {
mavenCentral()
maven {
url "http://maven2.javacv.googlecode.com/git/"
}
}
dependencies {
compile files('libs/android-support-v4.jar')
compile group: 'com.googlecode.javacpp', name: 'javacpp', version: '0.5'
compile group: 'com.googlecode.javacv', name: 'javacv', version: '0.5'
}
和我看到DIR外部库导入库。所以,我想运行此:
and I see imported libraries in dir External Libraries. So I tried to run this:
...
IplImage zdjecie=cvLoadImage(Environment.getExternalStorageDirectory().getPath()+ "/1.bmp");
cvSaveImage(Environment.getExternalStorageDirectory().getPath()
+ "/2.bmp", zdjecie);
...
和我有错误:
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jniopencv_core: findLibrary returned null
......,因为我不知道我应该怎么做的OpenCV的(及其他).so文件。
...because I don't know what should I do with opencv's (and others) .so files.
那么我们应该怎么使用JavaCV在Android的工作室?
So how should we use JavaCV in Android Studio?
推荐答案
1.WARNING: 这是不够的:
1.WARNING: That's not enough!:
dependencies { compile group: 'org.bytedeco', name: 'javacv', version: '0.9'}
2.EDIT:对不起,错,我最近的解决方案,
我张贴在这里并告诉只有约线之上是错误的。但我检查出来,这对我的作品:
2. Sorry for mistake, my recent solution which
I posted here and which told only about line above was wrong. But I checked it out and this works for me:
一)添加依赖
dependencies {
compile group: 'org.bytedeco', name: 'javacv', version: '0.9'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '2.4.9-0.9', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.3-0.9', classifier: 'android-arm'
}
二)创建的 jniLibs 目录的项目中(在同一水平上正常库目录编辑:如果
你有一些麻烦尝试移动jniLibs到应用程序/ src目录/主)。
c)增加要求。所以从OpenCV中,Android的arm.jar和ffmpeg的,Android的arm.jar(或只有这个文件,你真的需要)来创建jniLibs目录提取文件。 (如果你不知道什么
我说你可以从 JavaCV页面和里面下载javacv-0.9-bin.zip
你可以找到这两个.jar文件)。
b) Create jniLibs dir inside your project (on the same level as normal libs dir. If
you have some troubles try moving jniLibs to app/src/main).
c) Add required .so files extracted from opencv-android-arm.jar and ffmpeg-android-arm.jar (or only this files which you really need) to created jniLibs dir. (If you don't know about what
I'm talking you can download javacv-0.9-bin.zip from JavaCV page and inside it
you can find these 2 .jars).
这篇关于JavaCV + Android的工作室+ gradle-可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!