http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/O4A_SDK.html#running-opencv-samples

OpenCV4Android SDK

This tutorial was designed to help you with installation and configuration of OpenCV4Android SDK.

This guide was written with MS Windows 7 in mind, though it should work with GNU Linux and Apple Mac OS as well.

This tutorial assumes you have the following software installed and configured:

  • JDK

  • Android SDK and NDK

  • Eclipse IDE

  • ADT and CDT plugins for Eclipse

If you need help with anything of the above, you may refer to our Introduction into Android Development guide.

If you encounter any error after thoroughly following these steps, feel free to contact us via OpenCV4Android discussion group or OpenCVQ&A forum. We’ll do our best to help you out.

Tegra Android Development Pack users

You may have used Tegra Android Development Pack (TADP) released by NVIDIA for Android development environment setup.

Beside Android development tools the TADP 2.0 includes OpenCV4Android SDK, so it can be already installed in your system and you can skip to Running OpenCV Samples section of this tutorial.

More details regarding TADP can be found in the Introduction into Android Development guide.

General info

OpenCV4Android SDK package enables development of Android applications with use of OpenCV library.

The structure of package contents looks as follows:

OpenCV-2.4.9-android-sdk
|_ apk
| |_ OpenCV_2.4.9_binary_pack_armv7a.apk
| |_ OpenCV_2.4.9_Manager_2.18_XXX.apk
|
|_ doc
|_ samples
|_ sdk
| |_ etc
| |_ java
| |_ native
| |_ 3rdparty
| |_ jni
| |_ libs
| |_ armeabi
| |_ armeabi-v7a
| |_ x86
|
|_ LICENSE
|_ README.android
  • sdk folder contains OpenCV API and libraries for Android:

  • sdk/java folder contains an Android library Eclipse project providing OpenCV Java API that can be imported into developer’s workspace;

  • sdk/native folder contains OpenCV C++ headers (for JNI code) and native Android libraries (*.so and *.a) for ARM-v5, ARM-v7a and x86 architectures;

  • sdk/etc folder contains Haar and LBP cascades distributed with OpenCV.

  • apk folder contains Android packages that should be installed on the target Android device to enable OpenCV library access via OpenCV Manager API (see details below).

    On production devices that have access to Google Play Market (and Internet) these packages will be installed from Market on the first start of an application using OpenCV Manager API. But devkits without Market or Internet connection require this packages to be installed manually. Install the Manager.apk and optional binary_pack.apk if it needed. See How to select the proper version of OpenCV Manager for details.

    Note

    Installation from Internet is the preferable way since OpenCV team may publish updated versions of this packages on the Market.

  • samples folder contains sample applications projects and their prebuilt packages (APK). Import them into Eclipse workspace (like described below) and browse the code to learn possible ways of OpenCV use on Android.

  • doc folder contains various OpenCV documentation in PDF format. It’s also available online at http://docs.opencv.org.

    Note

    The most recent docs (nightly build) are at http://docs.opencv.org/2.4. Generally, it’s more up-to-date, but can refer to not-yet-released functionality.

Starting from version 2.4.3 OpenCV4Android SDK uses OpenCV Manager API for library initialization. OpenCV Manager is an Android service based solution providing the following benefits for OpenCV applications developers:

  • Compact apk-size, since all applications use the same binaries from Manager and do not store native libs within themselves;

  • Hardware specific optimizations are automatically enabled on all supported platforms;

  • Automatic updates and bug fixes;

  • Trusted OpenCV library source. All packages with OpenCV are published on Google Play;

For additional information on OpenCV Manager see the:

Manual OpenCV4Android SDK setup

Get the OpenCV4Android SDK

  1. Go to the OpenCV download page on SourceForge and download the latest available version. Currently it’s OpenCV-2.4.9-android-sdk.zip.

  2. Create a new folder for Android with OpenCV development. For this tutorial we have unpacked OpenCV SDK to the C:\Work\OpenCV4Android\directory.

    Note

    Better to use a path without spaces in it. Otherwise you may have problems with ndk-build.

  3. Unpack the SDK archive into the chosen directory.

    You can unpack it using any popular archiver (e.g with 7-Zip):

    On Unix you can use the following command:

    unzip ~/Downloads/OpenCV-2.4.9-android-sdk.zip
    

Import OpenCV library and samples to the Eclipse

  1. Start Eclipse and choose your workspace location.

    We recommend to start working with OpenCV for Android from a new clean workspace. A new Eclipse workspace can for example be created in the folder where you have unpacked OpenCV4Android SDK package:

  2. Import OpenCV library and samples into workspace.

    OpenCV library is packed as a ready-for-use Android Library Project. You can simply reference it in your projects.

    Each sample included into the OpenCV-2.4.9-android-sdk.zip is a regular Android project that already references OpenCV library. Follow the steps below to import OpenCV and samples into the workspace:

    Note

    OpenCV samples are indeed dependent on OpenCV library project so don’t forget to import it to your workspace as well.

    • Right click on the Package Explorer window and choose Import... option from the context menu:

    • In the main panel select General ‣ Existing Projects into Workspace and press Next button:

    • In the Select root directory field locate your OpenCV package folder. Eclipse should automatically locate OpenCV library and samples:

    • Click Finish button to complete the import operation.

    After clicking Finish button Eclipse will load all selected projects into workspace, and you have to wait some time while it is building OpenCV samples. Just give a minute to Eclipse to complete initialization.

    Warning

    After the initial import, on a non-Windows (Linux and Mac OS) operating system Eclipse will still show build errors for applications with native C++ code. To resolve the issues, please do the following:

    Open Project Properties -> C/C++ Build, and replace “Build command” text to "${NDKROOT}/ndk-build" (remove .cmd at the end).

    Note

    In some cases the build errors don’t disappear, then try the following actions:

    • right click on OpenCV Library project -> Android Tools -> Fix Project Properties, then menu Project -> Clean... -> Clean all
    • right click on the project with errors -> Properties -> Android, make sure the Target is selected and is Android 3.0 or higher
    • check the build errors in the Problems view window and try to resolve them by yourselves

    Once Eclipse completes build you will have the clean workspace without any build errors:

Running OpenCV Samples

At this point you should be able to build and run the samples. Keep in mind, that face-detection and Tutorial 2 - Mixed Processing include some native code and require Android NDK and NDK/CDT plugin for Eclipse to build working applications. If you haven’t installed these tools, see the corresponding section of Introduction into Android Development.

Warning

Please consider that some samples use Android Java Camera API, which is accessible with an AVD. But most of samples use OpenCV Native Camera which may not work with an emulator.

Note

Recent Android SDK tools, revision 19+ can run ARM v7a OS images but they available not for all Android versions.

Well, running samples from Eclipse is very simple:

  • Connect your device with adb tool from Android SDK or create an emulator with camera support.

  • Select project you want to start in Package Explorer and just press Ctrl + F11 or select option Run ‣ Run from the main menu, or click Run button on the toolbar.

    Note

    Android Emulator can take several minutes to start. So, please, be patient.

  • On the first run Eclipse will ask you about the running mode for your application:

  • Select the Android Application option and click OK button. Eclipse will install and run the sample.

    Chances are that on the first launch you will not have the OpenCV Manager package installed. In this case you will see the following message:

    To get rid of the message you will need to install OpenCV Manager and the appropriate OpenCV binary pack. Simply tap Yes if you haveGoogle Play Market installed on your device/emulator. It will redirect you to the corresponding page on Google Play Market.

    If you have no access to the Market, which is often the case with emulators - you will need to install the packages from OpenCV4Android SDK folder manually. See How to select the proper version of OpenCV Manager for details.

    1
    <Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.9_Manager_2.18_armv7a-neon.apk
    

    Note

    armeabiarmv7a-neonarm7a-neon-android8mips and x86 stand for platform targets:

    • armeabi is for ARM v5 and ARM v6 architectures with Android API 8+,
    • armv7a-neon is for NEON-optimized ARM v7 with Android API 9+,
    • arm7a-neon-android8 is for NEON-optimized ARM v7 with Android API 8,
    • mips is for MIPS architecture with Android API 9+,
    • x86 is for Intel x86 CPUs with Android API 9+.

    If using hardware device for testing/debugging, run the following command to learn its CPU architecture:

    adb shell getprop ro.product.cpu.abi
    

    If you’re using an AVD emulator, go Window > AVD Manager to see the list of availible devices. Click Edit in the context menu of the selected device. In the window, which then pop-ups, find the CPU field.

    You may also see section How to select the proper version of OpenCV Manager for details.

    When done, you will be able to run OpenCV samples on your device/emulator seamlessly.

  • Here is Sample - image-manipulations sample, running on top of stock camera-preview of the emulator.

What’s next

Now, when you have your instance of OpenCV4Adroid SDK set up and configured, you may want to proceed to using OpenCV in your own application. You can learn how to do that in a separate Android Development with OpenCV tutorial.

Help and Feedback

You did not find what you were looking for?

  • Ask a question on the Q&A forum.
  • If you think something is missing or wrong in the documentation, please file a bug report.

installation and configuration of OpenCV4Android SDK的更多相关文章

  1. !! This tutorial was designed to help you with installation and configuration of OpenCV4Android SDK.

    ref: http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/O4A_SDK.html#running-o ...

  2. P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1

    P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1       May ...

  3. P6 EPPM Installation and Configuration Guide 16 R1 April 2016

    P6 EPPM Installation and Configuration Guide 16 R1         April 2016 Contents About Installing and ...

  4. HHVM Installation and Configuration(HHVM 安装及配置)

    Installation and Configuration¶ General Installation Considerations Installation on Linux systems Ub ...

  5. 在Android Studio2.3中配置OpenCV4Android SDK

    在Android Studio2.3中配置OpenCV4Android SDK 一,OpenCV4Android下载地址 [2.4.11]http://onhdz331f.bkt.clouddn.co ...

  6. SharePoint 2013 Installation and Configuration Issues

    # Issue 1: During Installing SharePoint 2013 Prerequisites there was an error in installing Applicat ...

  7. Installation and Configuration MySQL Cluster 7.2 on CentOS 5 (include MySQL 5.5)

    Architecture Manager Node mysql-mag1   192.168.1.31 mysql-mag2   192.168.1.32 SQL Node mysql-sql1   ...

  8. HAProxy Installation and Configuration on CentOS 6.4 to Mitigate The Effects of Abusive Clients--转

    ref:http://thoughts.z-dev.org/2013/05/07/haproxy-installation-and-configuration-on-centos-6-4-to-mit ...

  9. Installation and Configuration Guide

    Harbor can be installed by one of three approaches: Online installer: The installer downloads Harbor ...

随机推荐

  1. Netsharp快速入门(之18) 平台常用功能(工作区相关)

    作者:秋时  转载须说明出处 第6章     平台功能 6.1     部件二次开发设置 6.1.1  工具栏管理 1.从单据二次开发-工具栏管理进入 2.主要设置显示,对应的方法名或设置权限相关操作 ...

  2. NSIS中判断.net framework 是否安装

    在网上找了几个脚本,原理都是读取注册表进行判断,都可以用. 1.CheckDotNetFramework /* * Name: CheckDotNetFramework.nsh * Version: ...

  3. 【转】EXT VTYPE自定义举例

    原文地址:http://www.blogjava.net/xiaohuzi2008/archive/2012/12/08/392676.html 近日来对Ext特别感兴趣,也许是它那种OO的设计思想吸 ...

  4. 【BZOJ】【1901】【Zju2112】 Dynamic Rankings

    再填个坑. 动态维护区间第K大(带单点修改) 首先裸的区间第K大我们是用的[前缀和]思想,实现O(n)预处理,O(1)找树查询,那么如果是动态的呢?我们可以利用树状数组(BIT)的思想,进行O(log ...

  5. Matlab稀疏矩阵

    一.矩阵存储方式 MATLAB的矩阵有两种存储方式,完全存储方式和稀疏存储方式 1.完全存储方式 将矩阵的全部元素按列存储,矩阵中的全部零元素也存储到矩阵中. 2.稀疏存储方式 仅存储矩阵所有的非零元 ...

  6. html5 webApp常用Meta标签

    Html5 webApp常用Meta标签 <meta charset="UTF-8"> <meta name="viewport" conte ...

  7. UML状态图(转载)

    概述: 图表本身的名称,阐明该图的目的和其他细节.它描述了在一个系统中的一个组成部分不同的状态.状态是特定的一个系统的组件/对象. 状态图描述了一个状态机.我们阐明的状态机可以被定义为一台机器,它定义 ...

  8. slot的含义

    1) slot就是槽的意思,是一个资源单位,只有给task分配了一个slot之后,这个task才可以运行.slot分两种,map slot沪蓉reduce slot.另外,slot是一个逻辑概念,一个 ...

  9. POJ 3150 Cellular Automaton(矩阵乘法+二分)

    题目链接 题意 : 给出n个数形成环形,一次转化就是将每一个数前后的d个数字的和对m取余,然后作为这个数,问进行k次转化后,数组变成什么. 思路 :下述来自here 首先来看一下Sample里的第一组 ...

  10. Linux网络编程5——使用UDP协议实现群聊

    引言 本文实现的功能类似于我之前所写的一篇博文(Linux之select系统调用_2),区别在于进程之间的通信方式有所不同.之前的文章中,我所使用的是管道,而本文我将会使用socket接口. 需求 客 ...