How to Use OpenCV in Android Studio,opencvandroid

來源:互聯網
上載者:User

How to Use OpenCV in Android Studio,opencvandroid
How to Use OpenCV in Android Studio

  • Create a libraries folder underneath your project main directory. For example, if your project is OpenCVExamples, you would create a OpenCVExamples/libraries folder.

  • Go to the location where you have SDK "\OpenCV-2.4.8-android-sdk\sdk" here you will find the java folder, rename it to opencv.

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

  • 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']        }    }}
  • 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 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.

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

  • 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 the jniLibs from the OpenCV SDK.

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



  • 或查看此連結:http://www.bubuko.com/infodetail-949520.html

  • 著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.