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:
- download the Levenberg-Marquardt from http://users.ics.forth.gr/~lourakis/levmar/
- download required libraries (LAPACK (BLAS and F2C are included)) from http://www.netlib.org/lapack/
- prepare your android environment + NDK (read the tutorial from http://developer.android.com/tools/sdk/ndk/index.html)
- copy the levmar and lapack libraries inside jni folder.
- prepare Android.mk and the main JNI file (.cpp) file and compile them.
- call the levmar functions inside the JNI file from the JAVA side as usual.
Issues:
- installing LAPACK for Android may output error (error 206 : the file list are too long). It is necessary to divide LAPACK library into several parts so that the archiving into .a will work successfully. See for detail https://groups.google.com/forum/#!topic/android-ndk/oKOAj0O53MQ
- linking static libraries from BLAS inside LAPACK library will vary depending on the architecture. Refer the FAQ page of Levenberg Marquardt page for the solution (http://users.ics.forth.gr/~lourakis/levmar/faq.html#Q27)
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.
- download the Levenberg-Marquardt from http://users.ics.forth.gr/~lourakis/levmar/
- download required libraries (LAPACK (BLAS and F2C are included)) from http://www.netlib.org/lapack/
- prepare your android environment + NDK (read the tutorial from http://developer.android.com/tools/sdk/ndk/index.html)
- copy the levmar and lapack libraries inside jni folder.
- prepare Android.mk and the main JNI file (.cpp) file and compile them.
- call the levmar functions inside the JNI file from the JAVA side as usual.
- installing LAPACK for Android may output error (error 206 : the file list are too long). It is necessary to divide LAPACK library into several parts so that the archiving into .a will work successfully. See for detail https://groups.google.com/forum/#!topic/android-ndk/oKOAj0O53MQ
- linking static libraries from BLAS inside LAPACK library will vary depending on the architecture. Refer the FAQ page of Levenberg Marquardt page for the solution (http://users.ics.forth.gr/~lourakis/levmar/faq.html#Q27)
I built a simple driver for the testing Levenberq-Marquardt library in Android here : https://github.com/3deggi/levmar-ndk.
Comments
Post a Comment