Saturday, October 19, 2013

How to Use Levenberg-Marquardt Library for Android NDK

Installing Levenberg-Marquardt library for Android.

In my augmented reality project, I need to use Levenberg-Marquardt optimization library in order to optimize the homography and the camera pose. Currently, I am working on both PC and mobile devices (Android). I need the library to work for my Android device. I then compiled the Levmar library for Android using Native Development Kit (NDK). The process is simply writing Android.mk for compiling them under the NDK environment. Levmar library requires another libraries such as LAPACK, BLAS and F2C for the math routines.

Here are the steps:
  1. download the Levenberg-Marquardt from http://users.ics.forth.gr/~lourakis/levmar/
  2. download required libraries (LAPACK (BLAS and F2C are included)) from http://www.netlib.org/lapack/
  3. prepare your android environment + NDK (read the tutorial from http://developer.android.com/tools/sdk/ndk/index.html)
  4. copy the levmar and lapack libraries inside jni folder. 
  5. prepare Android.mk and the main JNI file (.cpp) file and compile them.
  6. call the levmar functions inside the JNI file from the JAVA side as usual.
Issues:

I built a simple driver for the testing Levenberq-Marquardt library in Android here : https://github.com/3deggi/levmar-ndk

This is the snapshot of my project using Levenberq-Marquardt for tracking a shape and computing the homography (not in the driver i put in the GitHub). The outline of the shape (red rectangle) is drawn using the computed homography. Tested on Nexus 7 and OpenCV 2.4.6. 


No comments :

Post a Comment