OpenCV进行Android的 - 不是OpenCV的,Android的SDK [英] openCV for Android - NOT opencv-android-sdk
问题描述
我想在我的Android应用程序中使用某些本地C ++ code /库。 C ++的一部分,在很大程度上基于OpenCV。
I want to use some native c++ code/library in my Android application. The c++ part is heavily based on openCV.
我知道的OpenCV-Android的SDK,并已看到很多详尽的教程就如何与Android工作室做到这一点(如<一个href=\"http://hujiaweibujidao.github.io/blog/2014/10/22/android-ndk-and-opencv-development-with-android-studio/\"相对=nofollow>这个),但这些都只是用OpenCV的,Android的SDK只支持的OpenCV函数的有限子集(我不是在谈论那些不使移动设备上的感像GPU相关的功能,但根本就没有在OpenCV的,Android的SDK存在和其他一些功能,我需要他们的C ++ code)。
I am aware of opencv-android-sdk and have seen plenty of detailed tutorials on how to do it with Android Studio (like this one), but these all just use the opencv-android-sdk that only supports a limited subset of openCV functions (I am not talking about those that do not make sense on a mobile device, like gpu-related functionalities, but some other functions that simply do not exist in the opencv-android-sdk and I need them for the c++ code).
不管怎样,我的问题是:我可以采用某种编译和使用(使用NDK等)中的全部模块的在我的Android Studio项目的OpenCV
Anyway, my question is: can I somehow compile and use the "full set of modules" of openCV in my Android Studio project (using NDK, etc.)?
我看了也这个,并声称 [它]将打造最OpenCV的模块[Android游戏],但它不是我清楚如何使用它...
I saw also this one, and it claims that "[it] will build most of the OpenCV modules [for android]", but it is not clear to me how to use it...
任何暗示将是非常美联社preciated!
Any hint would be highly appreciated!
推荐答案
OK!我想我想通了!
基本上是需要遵循<一个href=\"http://hujiaweibujidao.github.io/blog/2014/10/22/android-ndk-and-opencv-development-with-android-studio/\"相对=nofollow>本教程,只是替换Android.mk路径指向编译后的完整版本,而不是OpenCV的,Android的SDK(以及一些其他小的变化的OpenCV;对于那些我只是在这里我有什么复制 Android.mk
和 Application.mk
)。
OK! I guess I figured it out!
Basically one needs to follow this tutorial, but just replace the path in Android.mk to point to the compiled full version of openCV, instead of openCV-Android-SDK (as well as some other small changes; for those I just copy here what I have in Android.mk
and Application.mk
).
最后,我的 Android.mk
看起来像这样( OPENCVROOT
需要正确设置):
Eventually, my Android.mk
looks like this (OPENCVROOT
need to be set properly):
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCVROOT:= /path/to/opencv-2.4.10/platforms/build_android_arm
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/OpenCV.mk
LOCAL_SRC_FILES := main.cpp
LOCAL_LDLIBS += -llog
LOCAL_MODULE := hello
include $(BUILD_SHARED_LIBRARY)
和 Application.mk
是这样的:
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-19
刚上了Android NDK编译OpenCV的一个简短的说明:
Just a short note on compiling openCV with Android NDK:
有关编译使用NDK全OpenCV的,人们仍然可以使用方法中提到 ;该描述是基于NDK-R8E,但如果需要的话,可以下载NDK-r10d并用它来代替。我不得不关闭CUDA相关的部分在OpenCV的源代码,以便与NDK(只需添加 -D WITH_CUDA = OFF
成功编译它 OpenCV的-2.4.10 /平台/脚本/ cmake_android_arm.sh
,在最后一行,后 cmake的
,没有工作!)。如果你需要有非自由的模块(如海浪和过筛,不要从GitHub克隆它,只需下载它从的此处;我的方式使用的版本2.4.10)
For compiling full openCV using NDK, one can still use the method mentioned here; the description is based on NDK-r8e, but if needed, one can download NDK-r10d and use it instead. I had to turn-off cuda-related parts in openCV source, in order to successfully compile it with NDK (just adding -D WITH_CUDA=OFF
to opencv-2.4.10/platforms/scripts/cmake_android_arm.sh
, in the last line, after cmake
, does the job!). In case you need to have the nonfree modules (like SURF and SIFT, do NOT clone it from github, just download it in a single zip from here; I used version 2.4.10 by the way).
现在我有机会获得几乎所有的OpenCV函数在本地C ++ code,我融入我的Android应用程序!
Now I have access to almost all openCV functions in the native c++ code that I am integrating into my Android App!
我希望这可以帮助别人呢!
I hope this helps others, too!
这篇关于OpenCV进行Android的 - 不是OpenCV的,Android的SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!