Setting up AruCo for Android Studio

本秂侑毒 提交于 2019-12-22 16:40:53

问题


I'm planing to create a simple Android App, that can detect markers and their relative position to each other. The basic App is running and the only thing that is missing is the actual marker detection.

During my Internet research i found OpenCV for Android is able to just that. And further the Aruco library will provide an easier coding to programm the detection.

But that is where i struggle. Even after a long time spent searching the web for clues, I can't find out how to get Aruco working in Android Studio. Can anybody tell me how to do just that or point me into the right direction in the web?


回答1:


Here are the basic steps to using OpenCV in android studio.

  • Download OpenCV
  • Import OpenCV as a Module
  • Add the OpenCV Module as a dependency
  • Correct gradle discrepancies
  • Setup jni if native functions are required

1. Download OpenCV

  • Download OpenCV via this link:
  • http://opencv.org/downloads.html
  • Download the version you want that says "OpenCV for Android"
  • Put the zip file in some directory on your computer

2. Import OpenCV as a Module

  • Open your Android Studio Project
  • Navigate to File -> New -> Import Module
  • Now you need to browse your computer for your OpenCV Library and choose the folder named "java" to import.
  • This folder should be in the file location "yourOpenCVDir/OpenCV-android-sdk/sdk/java
  • You can name the Module whatever you would like. For example "OpenCV" will do.

3. Add the OpenCV Module as a dependency

  • Navigate to File -> Project Structure
  • A window will appear
  • On the left pane of the window will be a Modules Section, click on your project name
  • Click on the Dependencies Tab
  • On the right side of the window, click the green + sign and click "Module Dependency
  • Choose OpenCV and Click OK

4. Correct any Gradle Discrepencies

  • If it is not already open, click the project tab on the very left side of the android studio window.
  • Expand the Gradle Scripts tab to view all the gradle files
  • View the Gradle files for the both Modules and ensure that the compileSdkVersion, buildToolsVersion,and targetSdkVersion are the same in both files (If you aren't sure which version you should have, navigate to the SDK manager and see which APIs you have installed and which are available)
  • At the time of this post, the most recent versions are:
    • compileSdkVersion: 23
    • buildToolsVersion: 23.0.3
    • targetSdkVersion: 23

5. Setup jni if native functions are required

  • Some Android OpenCV require a call to a C++ function
  • If you require the native code, add a folder named "jniLibs" inside your project folder in appDir/src/main
  • Navigate to wherever your OpenCV Library is located and copy the contents of yourOpenCVDir/OpenCv-android-sdk/sdk/native/libs into the jniLibs folder you just created
  • Go through each of the folders contained in your jniLibs folder (i.e. "arm64-v8a", "mips" etc.) and delete all the files except for "libopencv_java.so -Make sure you have the android NDK installed. Navigate to the SDK manager and click the SDK Tools tab
  • Check the box next to "NDK" and click OK

You should be able to use OpenCV now!



来源:https://stackoverflow.com/questions/31472919/setting-up-aruco-for-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!