Android's OpenCV

Source: Internet
Author: User

These days to implement OPENCV-related features on the Android platform, read a few blogs, papers, and finally achieved a simple example of OPENCV development on Android. In the period encountered a lot of large and small problems, now summed up. Of course, there are a lot of problems I do not very understand, I hope everyone is not hesitate to enlighten.

first , the preparatory work

  1. Build Android development environment under Windows platform

Here is a special mention of the configuration of the Android SDK environment variable (before Android development did not configure the SDK environment variables, feel very weak AH)

   1.1 and configure the JDK environment variable, open the environment variable, advanced system settings, properties----"android_sdk_home" in the System environment variables column, and set the variable value to the path of the SDK directory under the Adt-bundle-windows directory, mine is E:\ADT-BUNDLE-WINDOWS-X86_64_20140101\SDK

   1.2 Add "%android_sdk_home%\tools;%android_sdk_home%\platform-tools" to path. Note semicolon-delimited

1.3 Check that the SDK is configured successfully, cmd command line input android–h, the following results show that the configuration is successful

    

  2. Installation and configuration of the Android NDK

: https://developer.android.com/tools/sdk/ndk/index.html

Use the latest NDK, directly discard Cygwin (seemingly version above R7), previously do Android projects to use the NDK must download the NDK, download install Cygwin (simulated Linux environment), download the CDT (Eclipse C + + development plug-in), Also to configure the compiler, environment variables, especially troublesome, the new version is not required.

As the NDK version parameter I downloaded

  

Double-click the. exe file, run will prompt to select the decompression directory, can be arbitrarily extracted to a directory, I chose to extract the E-packing directory.

In Eclipse, select Windows->preference->android->ndk, and then add the path to the NDK directory you just unzipped, as shown in

  

3. Configuring the OpenCv for Android environment

: Http://sourceforge.net/projects/opencvlibrary/files/opencv-android/(i downloaded Opencv-2.4.9-android-sdk.rar)

  Unzip the file. The extracted directory under the SDK renamed: OPENCVSDK (can be arbitrary, also can not change, convenient is good).

Open Eclipse, select File->import, select Existing project into workspace ... Import the SDK project. The engineer will refer to the third-party class library When we do the OPENCV development, so we'll set its properties:

  

In this case, we can directly call Android for our packaged OpenCV interface for development.

Second, theNDK development of the example, referring to the online information learning the first entry project.

  Create a new Android project, named Testopencv.

1. Create a new class for creating local function calls Imageproc.java

1  Package My.example.ndkopencv; 2 3  Public class Imageproc {4      Public Static native int [] Grayproc (intint int h); 5 }

2. Generate C + + header files

Open cmd and go to the Bin/classes directory under the directory where the project is located, execute the COM.EXAMPLE.TESTOPENCV.IMAGEPROC command:

  

At this point, build the Com_example_testopencv_imageproc.h file under the D:\WorkSpace\TestOpenCv\bin\classes directory and rename the file to ImageProc.h.

3. Generating local JNI references

Right-click on the project, select Android Tools->add Native support

  

Android's OpenCV

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.