为Android Studio设置AruCo [英] Setting up AruCo for Android Studio

查看:390
本文介绍了为Android Studio设置AruCo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算创建一个简单的Android应用程序,该应用程序可以检测标记及其彼此之间的相对位置.基本的App正在运行,唯一缺少的是实际的标记检测.

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.

在进行互联网研究期间,我发现Android版OpenCV能够做到这一点.而且,Aruco库将提供更简单的编码来对检测进行编程.

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.

但是那是我挣扎的地方.即使花了很长时间在网上搜索线索,我仍然找不到如何使Aruco在Android Studio中工作的方法. 有人可以告诉我如何做到这一点,或将我指向网络中的正确方向吗?

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?

推荐答案

以下是在Android Studio中使用OpenCV的基本步骤.

  • 下载OpenCV
  • 将OpenCV作为模块导入
  • 将OpenCV模块添加为依赖项
  • 正确的gradle差异
  • 如果需要本机功能,请设置jni

1.下载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.将OpenCV导入为模块

  • 打开您的Android Studio项目
  • 导航到文件->新建->导入模块
  • 现在,您需要浏览计算机以查找OpenCV库,然后选择要导入的名为"java"的文件夹.
  • 此文件夹应位于文件位置"yourOpenCVDir/OpenCV-android-sdk/sdk/java
  • 您可以根据需要命名模块.例如,"OpenCV"就可以.

3.将OpenCV模块添加为依赖项

  • 导航到文件->项目结构
  • 将出现一个窗口
  • 在窗口的左窗格上将是一个模块"部分,单击您的项目名称
  • 单击依赖关系"选项卡
  • 在窗口右侧,单击绿色+号,然后单击模块依赖项"
  • 选择OpenCV,然后单击确定"

4.更正所有Gradle差异

  • 如果尚未打开,请单击最左侧的项目选项卡 android studio窗口的侧面.
  • 展开Gradle脚本标签以查看所有gradle文件
  • 查看两个模块的Gradle文件,并确保两个文件中的compileSdkVersion,buildToolsVersion和targetSdkVersion都相同(如果不确定应使用哪个版本,请导航至SDK管理器并查看您使用的API已安装并且可用)
  • 在撰写本文时,最新版本是:
    • compileSdkVersion:23
    • buildToolsVersion:23.0.3
    • targetSdkVersion:23
    • 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.如果需要本机功能,请设置jni

      • 某些Android OpenCV需要调用C ++函数
      • 如果需要本机代码,请在appDir/src/main中的项目文件夹内添加一个名为"jniLibs"的文件夹
      • 导航至您的OpenCV库所在的位置,然后将OpenCVDir/OpenCv-android-sdk/sdk/native/libs的内容复制到您刚创建的jniLibs文件夹中
      • 浏览jniLibs文件夹中包含的每个文件夹(即"arm64-v8a","mips"等),并删除除"libopencv_java.so"之外的所有文件 -确保您已安装android NDK.导航到SDK管理器,然后单击"SDK工具"选项卡
      • 选中"NDK"旁边的框,然后单击确定"
      • 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

      您现在应该可以使用OpenCV!

      You should be able to use OpenCV now!

      这篇关于为Android Studio设置AruCo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆