This article describes how to use cygwin to build Android opencv 2.2 and cvcamera sample on Windows.
Refer:
Http://opencv.willowgarage.com/wiki/Android2.2
Preparation:
JDK-
Http://www.oracle.com/technetwork/java/javase/downloads/index.html
Cygwin-select the ftp://mirrors.kernel.org image and search for tools such as devel install to install GCC, make, swig
Crystax ndk-http://www.crystax.net/android/ndk-r4.php
Ant-http://ant.apache.org/
Android SDK-http://developer.android.com/sdk/index.html
(Latest Code)-SVN checkout https://code.ros.org/svn/opencv/trunk/opencv)
After the preceding packages are installed, you must add the executable file directories of cygwin, ant, Android SDK, and other packages to the path in the system environment variables.
Construction Process:
1. crystax ndk supports C ++'s rtti, STL ecxeption, and other features. After downloading it, you must decompress it to your home directory (for example, C:/cygwin/home/username ),
In cygwin, use ls to check whether the android-ndk-r4-crystax directory contains the following:
~ Android-ndk-r4-crystax $ ls
Build docs gnumakefile ndk-build ndk-GDB readme. txt samples sources
2. Install the android SDK
To install the android SDK, refer to an article on coolshell, illustrated in the following illustration:
Eclipse development of Android Application entry "http://coolshell.cn/articles/4270.html
The eclipse configuration process and getting started examples are also provided.
In this step, you only need to install the downloaded SDK.
3. Construct Android for opencv (assuming that the main directory of opencv is C:/opencv ):
Enter cygwin
$ Cd c:
$ CD opencv/android
$ Mkdir build
$ CD build
$ Cmake ..
$ Make
4. Build Android-JNI:
Enter cygwin
$ CD opencv/Android-JNI
$ Make
Here, the "local. Env. mk" warning may appear during the first make operation, no matter how long it will be.
Enter the window command line program
In the Android-JNI directory, run Android. BAT in Android SDK/tools:
C:/opencv/Android-JNI> Android update project -- name Android-opencv -- path ./
C:/opencv/Android-JNI> ant compile
Here, if the following error occurs during the ant process:
Build failed
<Android-SDK-root>/tools/ANT/lib_rules.xml: 121: refrence Android. Libraries. SRC not found
Find the build. xml file in the Android-JNI directory and add it after </setup>:
<Path id = "android. Libraries. SRC"> <path refID = "project. Libraries. SRC"/> </path>
<Path id = "android. Libraries. JARS"> <path refID = "project. Libraries. JARS"/> </path>
Execute ant compile again.
(Question reference: http://code.google.com/p/android/issues/detail? Id = 13024)
5. Construct the cvcamera project:
Enter cygwin
CD opencv/Android/apps/cvcamera
Sh build. Sh
Similarly, a warning related to "Local. Env. mk" may appear during the first execution.
Enter the window command line program
In the cvcamera directory, run Android. BAT in Android SDK/tools:
C:/opencv/Android-JNI> Android update project -- name cvcamera -- path ./
C:/opencv/Android-JNI> ant debug
C:/opencv/Android-JNI> ant install
Here I met the build failed
Androidsdk/tools/ANT/main_rules.xml: 639: the following error occurred while executing this line:
Androidsdk/tools/ANT/main_rules.xml: 271: exec returned: 1
View the 271 line of main_rules.xml:
<Exec executable = "$ {ADB}" failonerror = "true"> changed to <exec executable = "$ {ADB}" failonerror = "false">
Ant install is successfully re-installed.
Here, Android opencv2.2 and cvcamera are built.
----------------------------------
Author: Chen Jin)
This article is an original article. If you need to repost and quote it, please specify the original author and link. Thank you.