Android Studio中的Opencv集成,用于应用程序开发
问题描述:
如何在Android Studio中集成opencv?我在Android Studio中导入和安装opencv库时遇到问题
How to integrate opencv in Android Studio? I am facing problem in importing and installing opencv library in android studio
答
在Android Studio中安装openCV 简单步骤:-(间接方法)
- 下载/安装(提取)适用于Android的OpenCV(您可能已经安装了)
下载:-在这里文档:-此处
建议使用版本2.4.11. - 在Android Studio上打开您的Android项目.导入模块(文件>>新建>>导入模块)浏览到OpenCV for Android文件夹内的示例文件夹的路径,然后选择任意一个示例
例如:-OpenCV-2.4.11-android-sdk \ OpenCV-android-sdk \ samples \ 15-puzzle
在导入时,请检查所有内容.
这会自动将OpenCV库模块添加到您的项目中.
现在,您可以删除15个拼图模块(这是可选的).
- 在应用程序的gradle文件中添加依赖项:-编译项目(':openCVLibrary2411')
依赖项{编译项目(':openCVLibrary2411')}
- 现在您可以在项目中导入openCV类
例如:-
- Download/Install(Extract) OpenCV for Android (you might already have it)
Download :-here Documentation :- here
Version 2.4.11 is recommended. - Open you Android Project on Android Studio.
Import Module
(Files >> New >> Import Module)
Browse the path to the samples Folder inside OpenCV for Android Folder and Select any one of the Samples
eg :-OpenCV-2.4.11-android-sdk\OpenCV-android-sdk\samples\15-puzzle
While importing keep everything checked.
This will automatically add OpenCV Libraries Module to your project.
Now you can delete the 15-puzzle module (this is optional).
- In the gradle file of your app add dependency :-
compile project(':openCVLibrary2411')
dependencies { compile project(':openCVLibrary2411') }
- Now you can Import openCV classes in your project
eg:-
导入org.opencv.android.BaseLoaderCallback;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;