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.

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 libnonfree.so. 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 libnonfree.so:
    Create Android.mk and Application.mk scripts. This Android.mk is used to build libnonfree.so.

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

So far, you have got libnonfree.so along with libopencv_java.so and libgnustl_shared.so 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 libnonfree.so along with libopencv_java.so and libgnustl_shared.so 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 Android.mk and Application.mk inside jni:

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

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 Android.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

 
目录
相关文章
|
2月前
|
Android开发
安卓SO层开发 -- 编译指定平台的SO文件
安卓SO层开发 -- 编译指定平台的SO文件
31 0
|
3月前
|
Java Shell Linux
Android——编译(一):编译make的基础知识
Android——编译(一):编译make的基础知识
68 0
|
1月前
|
存储 资源调度 算法
Opencv(C++)系列学习---SIFT、SURF、ORB算子特征检测
Opencv(C++)系列学习---SIFT、SURF、ORB算子特征检测
|
3月前
|
Java Shell Linux
Android——编译(二):android.mk的相关知识
Android——编译(二):android.mk的相关知识
95 0
|
6月前
|
存储 传感器 定位技术
《移动互联网技术》 第四章 移动应用开发: Android Studio开发环境的使用方法:建立工程,编写源程序,编译链接,安装模拟器,通过模拟器运行和调试程序
《移动互联网技术》 第四章 移动应用开发: Android Studio开发环境的使用方法:建立工程,编写源程序,编译链接,安装模拟器,通过模拟器运行和调试程序
70 0
|
3月前
|
Shell Android开发
RK android13编译环境搭建与常用编译命令
RK android13编译环境搭建与常用编译命令
72 0
|
3月前
|
开发工具 Android开发
QGroundControl Qt安卓环境搭建及编译出现的问题
QGroundControl Qt安卓环境搭建及编译出现的问题
61 0
|
3月前
|
Java Go Android开发
Android——编译(三):android.bp的相关知识
Android——编译(三):android.bp的相关知识
155 0
|
4月前
|
编解码 Ubuntu Java
Android 编译Android7.0版本源码
Android 编译Android7.0版本源码
|
4月前
|
开发工具 Android开发 开发者
Android 项目编译 Gradle 配置说明
Android 项目编译 Gradle 配置说明
150 0