android opencv2.4.10使用SIFT编译出

  1. 云栖社区>
  2. 博客>
  3. 正文

android opencv2.4.10使用SIFT编译出

keller.zhou 2017-02-16 10:18:41 浏览927

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

  1. We actually only need to copy a few files from OpenCV-2.4.10 source code to OpenCV-2.4.10-android-sdk, namely:
    Copy the nonfree folder from OpenCV-2.4.10\sources\modules\nonfree\include\opencv2\to OpenCV-2.4.10-android-sdk\sdk\native\jni\include\opencv2.

  2. Create a folder to hold our new project for Here, I call it libnonfree. Create a jni folder under libnonfree. Copy the following files from OpenCV-2.4.10\sources\modules\nonfree\src to libnonfree\jni\ folder:

  3. Building
    Create and scripts. This is used to build

    cd into the project folder libnonfree and type ndk-build to build the

So far, you have got along with and in libnonfree\libs\armeabi-v7a folder.
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

  1. Create a project folder call libnonfree_demo. Create a jni folder inside the project folder. Then copy along with and into jni.

  2. Create a nonfree_jni.cpp in jni. 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.

  3. Create and inside jni:

    cd into the project folder libnonfree_demo and type ndk-build to build the

At this point you can easily extend the sample app with your SVMDetector. Just copy the source and include files int to the folder libnonfree_demo\jni and add cpp files to LOCAL_SRC_FILES in

The whole source can be downloaded from:

Original source from:



+ 关注