这是我从国外网站上看到的配置教程,it works for me!

Follow the below steps to add Open CV in your project as library.

  1. Create a libraries folder underneath your project main directory. For example, if your project isOpenCVExamples, you would create aOpenCVExamples/libraries folder.

  2. Go to the location where you have SDK "\OpenCV-2.4.8-android-sdk\sdk" here you will find thejava folder, rename it toopencv.

  3. Now copy the complete opencv directory from the SDK into the libraries folder you just created.

  4. Now create a build.gradle file in the opencv directory with the following contents

    apply 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']        }    }}
  5. Edit your settings.gradle file in your application’s main directory and add this line:

    include ':libraries:opencv'
  6. Sync your project with Gradle and it should looks like this

  7. Right click on your project then click on the Open Module Settings then 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.

  8. Choose Module dependency. It will open a dialog with a list of modules to choose from; select “:libraries:opencv”.

  9. Create a jniLibs folder in the /app/src/main/ location and copy the all the folder with *.so files (armeabi, armeabi-v7a, mips, x86) in thejniLibs from the OpenCV SDK.

  10. Click OK. Now everything done, go and enjoy with OpenCV.

顺便附上视频教程

https://youtu.be/OTw_GIQNbD8

原文地址

http://stackoverflow.com/questions/17767557/how-to-use-opencv-in-android-studio-using-gradle-build-tool?lq=1


更多相关文章

  1. Android视频教程分享
  2. 视频教程-FFmpeg+OpenGL ES+OpenSL ES打造Android视频播放器-And
  3. Android开发资料视频教程(光盘6.2G)
  4. 原文:Android Theme XML
  5. Android开发视频教程
  6. Android Fresco图片处理库用法API英文原文文档2-2(Facebook开源An
  7. Android手把手视频教程 | 课程简介
  8. Android 视频分享 Android Studio 视频教程
  9. Mars Android视频教程完整版高清在线观看

随机推荐

  1. android启动过程详解(二)——解析service
  2. android eclipse 通过 wifi 连接 手机
  3. android手写输入
  4. Android(安卓)studio中接收蓝牙模块传输
  5. 【Android】Android(安卓)import和export
  6. Text控件运用小收集
  7. android从一个app点击启动或者唤醒另一个
  8. Android(安卓)回调函数应用
  9. Google Android源代码结构
  10. Android读取/dev/graphics/fb0 屏幕截图