OpenCV : build with Glade on Android Studio


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


Android Studio 0.8.2+ and above, could easily import modules. Thanks to TGMCains answer, is simplified, by using Android Studio itself to import OpenCV as a module.

  1. Downloadlatest OpenCV sdk for Android fromOpenCV.organd decompress the zip file.
  2. Import OpenCV to Android Studio, FromFile -> Import Module, choosesdk/javafolder in the unzipped opencv archive.
  3. Update build.gradleunder imported OpenCV module to update 4 fields to match your project build.gradle a) compileSdkVersion b) buildToolsVersion c) minSdkVersion and 4) targetSdkVersion.
  4. Add module dependencybyApplication -> Module Settings, and select theDependenciestab. Click+icon at bottom, chooseModule Dependencyand select the imported OpenCV module.
  5. Copylibsfolder undersdk/nativeto Android Studio underapp/src/main.
  6. In Android Studio,rename the copiedlibsdirectory tojniLibsand we are done.

Step (6) is since Android studio expects native libs inapp/src/main/jniLibsinstead of olderlibsfolder. For those new to Android OpenCV, don't miss below steps

  • includestatic{ System.loadLibrary("opencv_java"); }
  • For step(5), if you ignore any platform libs like x86, make sure your device/emulator is not on that platform.

OpenCV written is in C/C++. Java wrappers are

  1. Android OpenCV SDK- OpenCV.org maintained Android Java wrapper. I suggest this one.
  2. OpenCV Java- OpenCV.org maintained auto generated desktop Java wrapper.
  3. JavaCV- Popular Java wrapper maintained by independent developer(s). Not Android specific. This librarymightget out of sync with OpenCV newer versions.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android初学者冷知识
  2. android项目 编译出现"Unsupported major
  3. Android主流机型分辨率总结
  4. Android程序的入口
  5. Android防注入研究
  6. Android(安卓)studio cmd命令行操作数据
  7. Android的五种布局
  8. ANDROID 背光调节
  9. android中实现tab标签切换时的一些效果
  10. Android解析ClassLoader(一)Java中的ClassL