How to Use OpenCV in Android Studio, opencvandroid

Source: Internet
Author: User

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

  • CreatelibrariesFolder underneath your project main directory. For example, if your project isOpenCVExamples, You wocould createOpenCVExamples/librariesFolder.

  • Go to the location where you have SDK "\ OpenCV-2.4.8-android-sdk \ sdk" here you will findjavaFolder, rename itopencv.

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

  • Now createbuild.gradleFile inopencvDirectory 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 shoshould looks like this

  • Right click on your project then click onOpen 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.

  • ChooseModule dependency. It will open a dialog with a list of modules to choose from; select ": libraries: opencv ".

  • CreatejniLibsFolder in/app/src/main/Location and copy the all the folder with *. so files (armeabi, armeabi-v7a, mips, x86) injniLibsFrom the OpenCV SDK.

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



  • Or view this link: http://www.bubuko.com/infodetail-949520.html

  • Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.