[Android] Building the OpenCV 2.2 for Android

This article is an installing steps for user who wants to build the OpenCV on Android. This work is based on the OpenCV and CrystaX .NET.

Here is my building environment,
OS: Ubuntu 10.04 (lucid)
Linux Kernel: 2.6.32

The CrystaX .NET has been fixed the Android NDK r4 to support the C++ Exceptions, STL, and RTTI features. You can also try to apply the AndroidExperimental to obtain the newest Android NDK r5b supports.

1. Prepare these works,
a. decompress the OpenCV 2.2 source code
b. unzip the fixed Android NDK – crystax ndk r4
c. install swig (sudo apt-get install swig)

2. Run the main building procedure
a. change the directory to OpenCV-2.2.0/android/
b. mkdir build (1)
c. cd build
d. cmake -D NDK_ROOT=${NDK_DIRECTORY} ../  (2)
e. make (3)

note:
(1) The CMake recommand you have a out source building procedure, so we make a new directory for compiling the source code.
(2) The NDK_ROOT means where the directory of NDK is located.
(3) You may get some error such as “not a directory” when you are building. Just remove the directory items, because I found out the description of directory is a file, not a directory.

2. Build android-jni
a. change the directory to android-jni
b. execute “make HOME=${ANDROID_NDK_LOCATION}” (1)
c. sh ./project_create.sh
d. ant compile (2)

note:
(1) ANDROID_NDK_LOCATION is the path of Android NDK that you should give it to the make procedure.
(2) If the system replies you the “Reference android.libraries.src not found” error, you can refer to this issue to solve this problem.

3. Build the sample project – CVCamera
a. change to the directory OpenCV-2.2.0/android/apps/CVCamera/
b. cp sample.local.env.mk local.env.mk
c. modify the local.env.mk (set your ANDROID_NDK_ROOT location)
d. sh build.sh
e. sh project_create.sh
f. ant debug
g. ant install (1)

note:
(1) You have to check your adb server has been started.

Reference:

You can also refer to the presentation in my slideshare.

Presentation

OpenCV Installation Guide

發佈留言