Install Android-OpenCV2.2 in Ubuntu10.04

Source: Internet
Author: User
Android-OpenCV was originally set up in Ubuntu10.10, and the update was made the day before yesterday, and the driver was gone to Ubuntu11.04. Reinstall Ubuntu11.04 and find that the 2.6.38 kernel of Ubuntu11.04 has removed videodev. h. You must change the header to run OpenCV (or keep synchronization with trunk, see AndroidTrunk, click to download ). Or switch back to Ubuntu10.04LTS. Now the kernel is 2.6.32. (

Android-OpenCV was originally set up in Ubuntu 10.10, and the update was clicked the day before yesterday, and the drive to Ubuntu 11.04 was gone.

Reinstall Ubuntu 11.04 and find that the 2.6.38 kernel of Ubuntu 11.04 has removed videodev. h. You must change the header to run OpenCV (or keep synchronization with trunk, see AndroidTrunk, click to download ). Or switch back to Ubuntu 10.04 LTS. Now the kernel is 2.6.32. (No update will be triggered before December 31, June .)

Basically it is done according to this (http://opencv.willowgarage.com/wiki/Android2.2. 10.04 is not a big problem (much more convenient than 11.04)

1. NDK

Linux edition http://www.crystax.net/android/ndk-r4.php

Root directory

2. SDK

Http://developer.android.com/sdk/index.html

Linux

Root directory

3. JDK

Sudo add-apt-repository "deb http://archive.canonical.com/natty partner"

// 11.04 is natty. The previous version is changed by yourself. 10.04 is lucid

Sudo apt-get update

Sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk

Java-version

Let's see if it's still open-jdk.

Sudo update-alternatives -- config java

And

Sudo update-alternatives -- config javac

Change openjdk to sunjdk

4. Change Environment Variables

Sudo gedit/etc/environment

If the version number is changed, add java path, sdk tools, and platform-tools.

PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: /usr/lib/jvm/java-6-sun-1.6.0.24/bin:/home/alpha/android-sdk-linux_x86/tools:/home/alpha/android-sdk-linux_x86/platform-tools: /home/alpha/android-ndk-r4-crystax"

CLASSPATH = "/usr/lib/jvm/java-6-sun-1.6.0.24/lib"

JAVA_HOME = "/usr/lib/jvm/java-6-sun-1.6.0.24"

Sudo gedit/etc/profile

Insert on umask

Export JRE_HOME =/usr/lib/jvm/java-6-sun-1.6.0.24/jre

Export PATH = $ PATH: $ JRE_HOME/bin

Export CLASSPATH = $ CLASSPATH:/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib

(It seems to be repeated here ..)

./Etc/environment make the configuration take effect (try running android and adb)

5. opencv2.2

Http://sourceforge.net/projects/opencvlibrary/

Put it in the root directory

6. eclipse

Sudo apt-get install eclipse

Help-install new software-address fill https://dl-ssl.google.com/android/eclipse/

Window-preferences-android-sdk location select SDK location


3.5.2 the problem that ADT cannot be installed depends on the http://www.linuxidc.com/Linux/2011-05/35437.htm

7. swig

Sudo apt-get install swig

8. opencv on Ubuntu

First install the database for backup

Http://www.linuxidc.com/Linux/2011-01/31305.htm

(At least these build-essential libv4l-0 libv4l-dev python-numpy libgtk2.0-dev pkg-config libjpeg-progs. Libjpeg-prog is renamed libjpeg-progs)

Follow this procedure

Http://www.linuxidc.com/Linux/2011-05/35438.htm

After compiling opencv, we mainly put the library of opencv in/usr/local/include, and then call it during android compilation. Try facedetect. Try without a camera./facedetect lena.jpg

This problem occurs.

./Facedetect: error while loading shared libraries: libopencv_core.so.2.2: cannot open shared object file: No such file or directory

For more information, see

Http://www.linuxidc.com/Linux/2011-05/35439.htm

(Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/lib)

(For other LD_LIBRARY_PATH documents, see http://www.linuxidc.com/linux/2011-05/35440.htm. it is not recommended to modify bashrc)

Linux/videodev. h was missing in kernel 2.6.38 of 11.04 because the linux-headers-2.6.38 removed videodev. h ..

Http://www.linuxidc.com/Linux/2011-05/35441.htm

Need to launch this patch http://www.linuxidc.com/Linux/2011-05/35442.htm

Then you can run it. But it seems that something went wrong with this later, and I switched back to 10.04 again.


Look at http://opencv.willowgarage.com/wiki/InstallGuide again

9. Then we can follow the steps in the http://opencv.willowgarage.com/wiki/Android2.2.

Build opencv/android (more than half an hour ..), Run android-jni, And the CVCamera ant package and there will be an apk. It is a program for detecting camera features on android.

Note the last Trouble. Modify build. xml before ant compile of android-jni.

10.04 may need to upgrade ant to 1.8 or above (http://www.linuxidc.com/Linux/2011-05/35443.htm)

10. android-opencv in eclipse

If you do not want to package Android. mk in the command line, you can run it in eclipse.

A simple edge detection test program to store a camera.jpg file in the SDK root directory ..

Click here to download http://www.linuxidc.net/thread-2181-1-1.html

Change the root and cpp names of opencv-Android in android. mk


OPENCV_BUILD_ROOT: =/home/alpha/opencv/android/build
LOCAL_MODULE: = ImgToGray
LOCAL_SRC_FILES: = ImgToGray. cpp

JNI cpp is like

Extern "C "{
JNIEXPORT jintArray JNICALL Java_com_CWY_cvtest_LibFuns_ImgToGray (
JNIEnv * env, jobject obj, jintArray buf, int w, int h );
}
;
JNIEXPORT jintArray JNICALL Java_com_CWY_cvtest_LibFuns_ImgToGray (
JNIEnv * env, jobject obj, jintArray buf, int w, int h ){

For details, refer to the JNI book ..

Write cpp and Android. mk and run ndk-build in the project root directory (the ndk directory is added in the PATH before)

Ps .. Wait for me to adjust OpenCV .. Brush under the http://opencv.willowgarage.com/wiki/Android found more tutorials .. Md years old.

From 0 onwards, the children's shoes of Java, android, OpenCV, and Ubuntu cannot afford to hurt ..

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.