这是我从国外网站上看到的配置教程,it works for me!
Follow the below steps to add Open CV in your project as library.
-
Create a
librariesfolder underneath your project main directory. For example, if your project isOpenCVExamples, you would create aOpenCVExamples/librariesfolder. -
Go to the location where you have SDK "\OpenCV-2.4.8-android-sdk\sdk" here you will find the
javafolder, rename it toopencv. -
Now copy the complete opencv directory from the SDK into the libraries folder you just created.
-
Now create a
build.gradlefile in theopencvdirectory with the following contentsapply plugin: 'android-library' buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.9.+' } } android { compileSdkVersion 19 buildToolsVersion "19.0.1" defaultConfig { minSdkVersion 8 targetSdkVersion 19 versionCode 2480 versionName "2.4.8" } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] res.srcDirs = ['res'] aidl.srcDirs = ['src'] } } } -
Edit your settings.gradle file in your application’s main directory and add this line:
include ':libraries:opencv' -
Sync your project with Gradle and it should looks like this

-
Right click on your project then click on the
Open Module Settingsthen Choose Modules from the left-hand list, click on your application’s module, click on the Dependencies tab, and click on the + button to add a new module dependency.
-
Choose
Module dependency. It will open a dialog with a list of modules to choose from; select “:libraries:opencv”.
-
Create a
jniLibsfolder in the/app/src/main/location and copy the all the folder with *.so files (armeabi, armeabi-v7a, mips, x86) in thejniLibsfrom the OpenCV SDK.
-
Click OK. Now everything done, go and enjoy with OpenCV.
顺便附上视频教程
原文地址
http://stackoverflow.com/questions/17767557/how-to-use-opencv-in-android-studio-using-gradle-build-tool?lq=1
本文提供了一套详细的步骤来帮助你在Android项目中集成OpenCV库。首先需要创建一个专门的libraries文件夹,并将OpenCV SDK中的相关文件重命名并复制到该文件夹下。接着通过设置Gradle构建文件来指定依赖项,最后调整项目设置完成集成。
598

被折叠的 条评论
为什么被折叠?



