OpenCV for Android in Eclipse on GNU/Linux
or the uninitiated, I’ve started working with Android for computer vision research. According to Wikipedia, “OpenCV (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real time computer vision, developed by Intel and now supported by Willow Garage. It is free for use under the open source BSD license. [...] The library was originally written in C[2] and this C interface makes OpenCV portable to some specific platforms such as digital signal processors. Wrappers for languages such as C#, Python,[3] Ruby and Java (using JavaCV[4]) have been developed to encourage adoption by a wider audience.”
The library can be fetched from here (OpenCV-2.4.0-android-bin.tar.bz2
) and it is a very large library that requires cmake to compile:
roy@roy:~$ cmake cmake version 2.8.0
Also see android-cmake
.
For use under Linux and Android (device side), download the Android NDK for Linux:
roy@roy:~$ uname -a Linux roy 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:09:46 UTC 2011 i686 GNU/Linux
Then:
sudo apt-get install swig
Here is what I got (as shown by tabbing):
roy@roy:~$ swig swig swig-1.3
JDK 5 or JDK 6 can be downloaded from the Oracle Java SE Downloads page. Here is where the Linux version can be obtained. Also download the Android SDK and install Ant:
sudo apt-get install ant
Then, set the path as follows (in my case a temporary location):
export ANDROID_NDK=/home/roy/Desktop/Text_Workspace/images/opencv/android-sdk-linux
The four main components are OpenCV, the SDK, NDK, and JDK. Here’s how it looks on my desktop:
Some instructions suggest a route for Eclipse users, in which case the following may be in order:
apt-get install eclipse
Tegra Android Developer Pack, which can be found under Tegra Resources at the NVidia Web site, simplifies much of the process above and integrates all the pertinent bits.
Other resources of interest:
- Introduction to programming with OpenCV
- OpenCV Beginners/Newbie Frequently Asked Questions
- Managing Virtual Devices
- Using OpenCV with Eclipse / CDT plugin
- Eclipse OpenCV Linux
- OpenCV Installation Guide
- OpenCV4Android documentation
- Using Android binary package with Eclipse
- (Outdated) Android 2.3.0
- OpenCV Tutorials