android opencv2.4.10使用SIFT编译出libnonfree.so
My development environment is set up as follows: android-ndk-r10d (install path:D:\adt-bundle-windows-x86_64-20140702\android-ndk-r10d\) OpenCV-2.4.10-android-sdk (install path:D:\CODE\OpenCV-2.4.10-android-sdk\),Download link OpenCV-2.4.10 (install path:D:\CODE\OpenCV-2.4.10\),Download link Building the nonfree module We actually only need to copy a few files fromOpenCV-2.4.10source code toOpenCV-2.4.10-android-sdk, namely: Copy thenonfreefolder fromOpenCV-2.4.10\sources\modules\nonfree\include\opencv2\toOpenCV-2.4.10-android-sdk\sdk\native\jni\include\opencv2. Create a folder to hold our new project forlibnonfree.so. Here, I call itlibnonfree. Create ajnifolder underlibnonfree. Copy the following files fromOpenCV-2.4.10\sources\modules\nonfree\srctolibnonfree\jni\folder: nonfree_init.cpp precomp.hpp sift.cpp(use the original file) surf.cpp(use the original file) Buildinglibnonfree.so: CreateAndroid.mkandApplication.mkscripts. ThisAndroid.mkis used to buildlibnonfree.so. Application.mk Android.mk(you should modifyOPENCV_PATHwhere yourOpenCV-2.4.10-android-sdkis) cdinto the project folderlibnonfreeand typendk-buildto build thelibnonfree.so. So far, you have gotlibnonfree.soalong withlibopencv_java.soandlibgnustl_shared.soinlibnonfree\libs\armeabi-v7afolder. You can easily build any SIFT or SURF applications using those libraries. If you want to use SIFT and SURF in JAVA code in your Android application, you only need to write JNI interfaces for the functions you want to use. Building a sample application Create a project folder calllibnonfree_demo. Create ajnifolder inside the project folder. Then copylibnonfree.soalong withlibopencv_java.soandlibgnustl_shared.sointojni. Create anonfree_jni.cppinjni. It is simple SIFT test program. It basically reads an image and detects the keypoints, then extracts feature descriptors, finally draws the keypoints to an output image. CreateAndroid.mkandApplication.mkinsidejni: Application.mk Android.mk(you should modifyOPENCV_PATHwhere yourOpenCV-2.4.10-android-sdkis) cdinto the project folderlibnonfree_demoand typendk-buildto build thelibnonfree_demo.so. At this point you can easily extend the sample app with yourSVMDetector. Just copy the source and include files int to the folderlibnonfree_demo\jniand add cpp files toLOCAL_SRC_FILESinAndroid.mk. The whole source can be downloaded from:https://github.com/bkornel/opencv_android_nonfree. Original source from:http://web.guohuiwang.com/technical-notes/sift_surf_opencv_android