diff --git a/doc/tutorials/introduction/android_binary_package/O4A_SDK.markdown b/doc/tutorials/introduction/android_binary_package/O4A_SDK.markdown deleted file mode 100644 index 092eacff215b..000000000000 --- a/doc/tutorials/introduction/android_binary_package/O4A_SDK.markdown +++ /dev/null @@ -1,255 +0,0 @@ -OpenCV4Android SDK {#tutorial_O4A_SDK} -================== - -@prev_tutorial{tutorial_android_dev_intro} -@next_tutorial{tutorial_dev_with_OCV_on_Android} - -| | | -| -: | :- | -| Original author | Vsevolod Glumov | -| Compatibility | OpenCV >= 3.0 | - -@warning -This tutorial is deprecated. - -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 @ref tutorial_android_dev_intro guide. - -If you encounter any error after thoroughly following these steps, feel free to contact us via -[OpenCV4Android](https://groups.google.com/group/android-opencv/) discussion group or OpenCV [Q&A -forum](https://forum.opencv.org). We'll do our best to help you out. - -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 `Manager Selection` - 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 - . - @note The most recent docs (nightly build) are at . Generally, it's more - up-to-date, but can refer to not-yet-released functionality. - @todo I'm not sure that this is the best place to talk about OpenCV Manager - -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; - - -Manual OpenCV4Android SDK setup -------------------------------- - -### Get the OpenCV4Android SDK - --# Go to the [OpenCV download page on - SourceForge](http://sourceforge.net/projects/opencvlibrary/files/) and download - the latest available version. This tutorial is based on this package: [OpenCV-2.4.9-android-sdk.zip](http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.9/OpenCV-2.4.9-android-sdk.zip/download). --# 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. - --# Unpack the SDK archive into the chosen directory. - - You can unpack it using any popular archiver (e.g with 7-Zip): - - ![](images/android_package_7zip.png) - - On Unix you can use the following command: - @code{.bash} - unzip ~/Downloads/OpenCV-2.4.9-android-sdk.zip - @endcode - -### Import OpenCV library and samples to the Eclipse - --# 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: - - ![](images/eclipse_1_choose_workspace.png) - --# Import OpenCV library and samples into workspace. - - OpenCV library is packed as a ready-for-use [Android Library - Project](http://developer.android.com/guide/developing/projects/index.html#LibraryProjects). 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: - - - Right click on the Package Explorer window and choose Import... option from the context - menu: - - ![](images/eclipse_5_import_command.png) - - - In the main panel select General --\> Existing Projects into Workspace and press Next - button: - - ![](images/eclipse_6_import_existing_projects.png) - - - In the Select root directory field locate your OpenCV package folder. Eclipse should - automatically locate OpenCV library and samples: - - ![](images/eclipse_7_select_projects.png) - - - Click Finish button to complete the import operation. - - @note OpenCV samples are indeed **dependent** on OpenCV library project so don't forget to import it to your workspace as well. - - 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. - - ![](images/eclipse_cdt_cfg4.png) - - Once Eclipse completes build you will have the clean workspace without any build errors: - - ![](images/eclipse_10_crystal_clean.png) - -@anchor tutorial_O4A_SDK_samples -### 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 @ref tutorial_android_dev_intro. - -**warning** - -Please consider that some samples use Android Java Camera API, which is accessible with an AVD. - -@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. - - See [Managing Virtual Devices](http://developer.android.com/guide/developing/devices/index.html) document for help - with Android Emulator. - - See [Using Hardware Devices](http://developer.android.com/guide/developing/device.html) for - help with real devices (not emulators). - -- 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: - - ![](images/eclipse_11_run_as.png) - -- 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](https://docs.google.com/a/itseez.com/presentation/d/1EO_1kijgBg_BsjNp2ymk-aarg-0K279_1VZRcPplSuk/present#slide=id.p) - package installed. In this case you will see the following message: - - ![](images/android_emulator_opencv_manager_fail.png) - - To get rid of the message you will need to install OpenCV Manager and the appropriate - OpenCV binary pack. Simply tap Yes if you have *Google 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 `Manager Selection` for - details. - @code{.sh} - /platform-tools/adb install /apk/OpenCV_2.4.9_Manager_2.18_armv7a-neon.apk - @endcode - - @note armeabi, armv7a-neon, arm7a-neon-android8, mips 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+. - - @note - If using hardware device for testing/debugging, run the following command to learn its CPU - architecture: - @code{.sh} - adb shell getprop ro.product.cpu.abi - @endcode - If you're using an AVD emulator, go Window \> AVD Manager to see the list of available devices. - Click Edit in the context menu of the selected device. In the window, which then pop-ups, find - the CPU field. - - @note - You may also see section `Manager Selection` 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. - - ![](images/emulator_canny.png) - -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 @ref tutorial_dev_with_OCV_on_Android tutorial. diff --git a/doc/tutorials/introduction/android_binary_package/android_dev_intro.markdown b/doc/tutorials/introduction/android_binary_package/android_dev_intro.markdown index 584f9a2f6cf2..21547b4bbabe 100644 --- a/doc/tutorials/introduction/android_binary_package/android_dev_intro.markdown +++ b/doc/tutorials/introduction/android_binary_package/android_dev_intro.markdown @@ -2,24 +2,22 @@ Introduction into Android Development {#tutorial_android_dev_intro} ===================================== @prev_tutorial{tutorial_clojure_dev_intro} -@next_tutorial{tutorial_O4A_SDK} +@next_tutorial{tutorial_dev_with_OCV_on_Android} | | | | -: | :- | -| Original author | Vsevolod Glumov | -| Compatibility | OpenCV >= 3.0 | +| Original author | Rostislav Vasilikhin | +| Compatibility | OpenCV >= 4.0 | @warning -This tutorial is deprecated. - +Windows- and MacOS-related sections of this tutorial are outdated and should be updated This guide was designed to help you in learning Android development basics and setting up your -working environment quickly. It was written with Windows 7 in mind, though it would work with Linux -(Ubuntu), Mac OS X and any other OS supported by Android SDK. +working environment quickly. It was tested on Ubuntu 22.04, the sections related to other OSes +were not updated for a long time and should be considered deprecated. If you encounter any error after thoroughly following these steps, feel free to contact us via -[OpenCV4Android](https://groups.google.com/group/android-opencv/) discussion group or OpenCV [Q&A -forum](https://forum.opencv.org). We'll do our best to help you out. +OpenCV [Forum](https://forum.opencv.org). We'll do our best to help you out. Preface ------- @@ -29,7 +27,7 @@ by Google. See the [Android home site](http://www.android.com/about/) for genera Development for Android significantly differs from development for other platforms. So before starting programming for Android we recommend you make sure that you are familiar with the following -key topis: +key topics: -# [Java](http://en.wikipedia.org/wiki/Java_(programming_language)) programming language that is the primary development technology for Android OS. Also, you can find [Oracle docs on @@ -39,366 +37,53 @@ key topis: JNI](http://docs.oracle.com/javase/7/docs/technotes/guides/jni/) useful. -# [Android Activity](http://developer.android.com/training/basics/activity-lifecycle/starting.html) and its - lifecycle, that is an essential Android API class. + life-cycle, that is an essential Android API class. -# OpenCV development will certainly require some knowledge of the [Android Camera](http://developer.android.com/guide/topics/media/camera.html) specifics. Manual environment setup for Android development ------------------------------------------------ -### Development in Java - -You need the following software to be installed in order to develop for Android in Java: - --# **Sun JDK 6** (Sun JDK 7 is also possible) - - Visit [Java SE Downloads page](http://www.oracle.com/technetwork/java/javase/downloads/) and - download an installer for your OS. - - Here is a detailed JDK (Java Development Kit) [installation - guide](http://source.android.com/source/initializing.html#installing-the-jdk) for Ubuntu and Mac - OS (only JDK sections are applicable for OpenCV) - - @note OpenJDK is not suitable for Android development, since Android SDK supports only Sun JDK. If you use Ubuntu, after installation of Sun JDK you should run the following command to set Sun java environment: - @code{.bash} - sudo update-java-alternatives --set java-6-sun - @endcode - --# **Android SDK** - - Get the latest Android SDK from - - Here is Google's [install guide](http://developer.android.com/sdk/installing.html) for the SDK. - - @note You can choose downloading **ADT Bundle package** that in addition to Android SDK Tools - includes Eclipse + ADT + NDK/CDT plugins, Android Platform-tools, the latest Android platform and - the latest Android system image for the emulator - this is the best choice for those who is setting - up Android development environment the first time! - - @note If you are running x64 version of Ubuntu Linux, then you need ia32 shared libraries for use on amd64 and ia64 systems to be installed. You can install them with the following command: - @code{.bash} - sudo apt-get install ia32-libs - @endcode - For Red Hat based systems the following command might be helpful: - @code{.bash} - sudo yum install libXtst.i386 - @endcode - --# **Android SDK components** - - You need the following SDK components to be installed: - - - *Android SDK Tools, revision 20* or newer. - - Older revisions should also work, but they are not recommended. - - - *SDK Platform Android 3.0* (API 11). - - The minimal platform supported by OpenCV Java API is **Android 2.2** (API 8). This is also - the minimum API Level required for the provided samples to run. See the - \ tag in their **AndroidManifest.xml** files. But for - successful compilation the **target** platform should be set to Android 3.0 (API 11) or - higher. It will not prevent them from running on Android 2.2. - - ![](images/android_sdk_and_avd_manager.png) - - See [Adding Platforms and - Packages](http://developer.android.com/sdk/installing/adding-packages.html) for help with - installing/updating SDK components. - --# **Eclipse IDE** - - Check the [Android SDK System Requirements](http://developer.android.com/sdk/requirements.html) - document for a list of Eclipse versions that are compatible with the Android SDK. For OpenCV - 2.4.x we recommend **Eclipse 3.7 (Indigo)** or **Eclipse 4.2 (Juno)**. They work well for OpenCV - under both Windows and Linux. - - If you have no Eclipse installed, you can get it from the [official - site](http://www.eclipse.org/downloads/). - --# **ADT plugin for Eclipse** - - These instructions are copied from [Android Developers - site](http://developer.android.com/sdk/installing/installing-adt.html), check it out in case of - any ADT-related problem. +In this tutorial we're gonna use an official Android Studio IDE and a set of other freely available tools. - Assuming that you have Eclipse IDE installed, as described above, follow these steps to download - and install the ADT plugin: +### Get tools and dependencies - -# Start Eclipse, then select Help --\> Install New Software... - -# Click Add (in the top-right corner). - -# In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following - URL for the Location: +Here's how to get a ready to work environment: - -# Click OK +1. Download and install Android Studio: + 1. Download Android Studio: https://developer.android.com/studio + 2. Extract the tar.gz archive + 3. Follow the instructions in `Install-Linux-tar.txt`: open `android-studio/bin` folder in terminal and run `./studio.sh` + 4. Perform standard installation through GUI + 5. Optionally you can add a shortcut on a desktop for a quick access by clicking menu Tools -> Create desktop entry. The menu appears after any project is created or opened. - @note If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons). +2. Install fresh Android SDK and NDK: + 1. Open SDK manager in Android Studio (***Customize -> All Settings -> Languages & Frameworks -> Android SDK***) + 2. Enable "Show Package Details" checkbox + ![](images/sdk_ndk_manager.png) + 3. Check SDK and NDK of the latest versions and press OK + 4. Make sure that your device support the chosen SDK versions - -# In the Available Software dialog, select the checkbox next to Developer Tools and click Next. +3. Install all the necessary packages for the build: + - `sudo apt install git cmake ninja-build openjdk-17-jdk openjdk-17-jre` + - the rest required packages are dependencies and should be installed automatically - -# In the next window, you'll see a list of the tools to be downloaded. Click Next. +### Check OpenCV examples - @note If you also plan to develop native C++ code with Android NDK don't forget to enable NDK Plugins installations as well. +1. Download OpenCV from Android SDK from official [release page on Github](https://github.com/opencv/opencv/releases) +or [SourceForge](https://sourceforge.net/projects/opencvlibrary/). +2. Extract zip archive with your OS tools. +3. Open the project `/OpenCV-android-sdk/samples` in Android Studio. +4. Connect your device + * Debugging should be enabled on a device, you can find an instruction about it across the web + * Alternatively you can use a virtual device that comes with the Android studio + ![](images/choose_device.png) +5. Choose a sample from the drop-down menu (for example, `15-puzzle`) and run it. - ![](images/eclipse_inst_adt.png) +Setup Device for Testing and Debugging +-------------------------------------- - -# Read and accept the license agreements, then click Finish. - - @note If you get a security warning saying that the authenticity or validity of the software can't be established, click OK. - - -# When the installation completes, restart Eclipse. - -### Native development in C++ - -You need the following software to be installed in order to develop for Android in C++: - --# **Android NDK** - - To compile C++ code for Android platform you need Android Native Development Kit (*NDK*). - - You can get the latest version of NDK from the [download - page](http://developer.android.com/tools/sdk/ndk/index.html). To install Android NDK just - extract the archive to some folder on your computer. Here are [installation - instructions](http://developer.android.com/tools/sdk/ndk/index.html#Installing). - - @note Before start you can read official Android NDK documentation which is in the Android NDK - archive, in the folder `docs/`. The main article about using Android NDK build system is in the - `ANDROID-MK.html` file. Some additional information you can find in the `APPLICATION-MK.html`, - `NDK-BUILD.html` files, and `CPU-ARM-NEON.html`, `CPLUSPLUS-SUPPORT.html`, `PREBUILTS.html`. - --# **CDT plugin for Eclipse** - - If you selected for installation the NDK plugins component of Eclipse ADT plugin (see the picture - above) your Eclipse IDE should already have CDT plugin (that means C/C++ Development Tooling). - There are several possible ways to integrate compilation of C++ code by Android NDK into Eclipse - compilation process. We recommend the approach based on Eclipse CDT(C/C++ Development Tooling) - Builder. - -Android application structure ------------------------------ - -Usually source code of an Android application has the following structure: - -- `root folder of the project/` - - `jni/` - - `libs/` - - `res/` - - `src/` - - `AndroidManifest.xml` - - `project.properties` - - `... other files ...` - -Where: - -- the `src` folder contains Java code of the application, -- the `res` folder contains resources of the application (images, xml files describing UI layout, - etc), -- the `libs` folder will contain native libraries after a successful build, -- and the `jni` folder contains C/C++ application source code and NDK's build scripts `Android.mk` - and `Application.mk` producing the native libraries, -- `AndroidManifest.xml` file presents essential information about application to the Android - system (name of the Application, name of main application's package, components of the - application, required permissions, etc). - - It can be created using Eclipse wizard or android tool from Android SDK. - -- `project.properties` is a text file containing information about target Android platform and - other build details. This file is generated by Eclipse or can be created with android tool - included in Android SDK. - -@note Both `AndroidManifest.xml` and `project.properties` files are required to compile the C++ part -of the application, since Android NDK build system relies on them. If any of these files does not -exist, compile the Java part of the project before the C++ part. - -`Android.mk` and `Application.mk` scripts ------------------------------------------ - -The script `Android.mk` usually has the following structure: -@code{.make} -LOCAL_PATH := \f$(call my-dir) - -include \f$(CLEAR_VARS) -LOCAL_MODULE := -LOCAL_SRC_FILES := - := -... - := - -include \f$(BUILD_SHARED_LIBRARY) -@endcode -This is the minimal file `Android.mk`, which builds C++ source code of an Android application. Note -that the first two lines and the last line are mandatory for any `Android.mk`. - -Usually the file `Application.mk` is optional, but in case of project using OpenCV, when STL and -exceptions are used in C++, it also should be created. Example of the file `Application.mk`: -@code{.make} -APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -fexceptions -APP_ABI := all -@endcode - -@note We recommend setting APP_ABI := all for all targets. If you want to specify the target -explicitly, use armeabi for ARMv5/ARMv6, armeabi-v7a for ARMv7, x86 for Intel Atom or mips for MIPS. - -@anchor tutorial_android_dev_intro_ndk -Building application native part from command line --------------------------------------------------- - -Here is the standard way to compile C++ part of an Android application: - -**warning** - -We strongly recommend using cmd.exe (standard Windows console) instead of Cygwin on - **Windows**. Use the latter if only you're absolutely sure about, what you're doing. Cygwin is - not really supported and we are unlikely to help you in case you encounter some problems with - it. So, use it only if you're capable of handling the consequences yourself. - --# Open console and go to the root folder of an Android application - @code{.bash} - cd / - @endcode --# Run the following command - @code{.bash} - /ndk-build - @endcode - @note On Windows we recommend to use ndk-build.cmd in standard Windows console (cmd.exe) rather than the similar bash script in Cygwin shell. - ![](images/ndk_build.png) - --# After executing this command the C++ part of the source code is compiled. - -After that the Java part of the application can be (re)compiled (using either *Eclipse* or *Ant* -build tool). - -@note Some parameters can be set for the ndk-build: - **Example 1**: Verbose compilation - @code{.bash} - /ndk-build V=1 - @endcode - **Example 2**: Rebuild all - @code{.bash} - /ndk-build -B - @endcode - -@anchor tutorial_android_dev_intro_eclipse -Building application native part from *Eclipse* (CDT Builder) -------------------------------------------------------------- - -There are several possible ways to integrate compilation of native C++ code by Android NDK into -Eclipse build process. We recommend the approach based on Eclipse CDT(C/C++ Development Tooling) -Builder. - -**important** - -OpenCV for Android package since version 2.4.2 contains sample projects - pre-configured CDT Builders. For your own projects follow the steps below. - --# Define the NDKROOT environment variable containing the path to Android NDK in your system (e.g. - "X:\\Apps\\android-ndk-r8" or "/opt/android-ndk-r8"). - - **On Windows** an environment variable can be set via - My Computer -\> Properties -\> Advanced -\> Environment variables. On Windows 7 it's also - possible to use [setx](http://ss64.com/nt/setx.html) command in a console session. - - **On Linux** and **MacOS** an environment variable can be set via appending a - "export VAR_NAME=VAR_VALUE" line to the `"~/.bashrc"` file and logging off and then on. - - @note It's also possible to define the NDKROOT environment variable within Eclipse IDE, but it - should be done for every new workspace you create. If you prefer this option better than setting - system environment variable, open Eclipse menu - Window -\> Preferences -\> C/C++ -\> Build -\> Environment, press the Add... button and set variable - name to NDKROOT and value to local Android NDK path. \#. After that you need to **restart Eclipse** - to apply the changes. - --# Open Eclipse and load the Android app project to configure. - --# Add C/C++ Nature to the project via Eclipse menu - New -\> Other -\> C/C++ -\> Convert to a C/C++ Project. - ![](images/eclipse_cdt_cfg1.png) - And: - ![](images/eclipse_cdt_cfg2.png) - --# Select the project(s) to convert. Specify "Project type" = Makefile project, "Toolchains" = - Other Toolchain. - ![](images/eclipse_cdt_cfg3.png) - --# Open Project Properties -\> C/C++ Build, uncheck Use default build command, replace "Build - command" text from "make" to - - "${NDKROOT}/ndk-build.cmd" on Windows, - - "${NDKROOT}/ndk-build" on Linux and MacOS. - - ![](images/eclipse_cdt_cfg4.png) - --# Go to Behaviour tab and change "Workbench build type" section like shown below: - - ![](images/eclipse_cdt_cfg5.png) - --# Press OK and make sure the ndk-build is successfully invoked when building the project. - - ![](images/eclipse_cdt_cfg6.png) - --# If you open your C++ source file in Eclipse editor, you'll see syntax error notifications. They - are not real errors, but additional CDT configuring is required. - - ![](images/eclipse_cdt_cfg7.png) - --# Open Project Properties -\> C/C++ General -\> Paths and Symbols and add the following - **Include** paths for **C++**: - @code - # for NDK r8 and prior: - ${NDKROOT}/platforms/android-9/arch-arm/usr/include - ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include - ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include - ${ProjDirPath}/../../sdk/native/jni/include - - # for NDK r8b and later: - ${NDKROOT}/platforms/android-9/arch-arm/usr/include - ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/include - ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include - ${ProjDirPath}/../../sdk/native/jni/include - @endcode - The last path should be changed to the correct absolute or relative path to OpenCV4Android SDK - location. - - This should clear the syntax error notifications in Eclipse C++ editor. - - ![](images/eclipse_cdt_cfg8.png) - -Debugging and Testing ---------------------- - -In this section we will give you some easy-to-follow instructions on how to set up an emulator or -hardware device for testing and debugging an Android project. - -### AVD - -AVD (*Android Virtual Device*) is not probably the most convenient way to test an OpenCV-dependent -application, but sure the most uncomplicated one to configure. - --# Assuming you already have *Android SDK* and *Eclipse IDE* installed, in Eclipse go - Window -\> AVD Manager. --# Press the New button in AVD Manager window. --# Create new Android Virtual Device window will let you select some properties for your new - device, like target API level, size of SD-card and other. - - ![](images/AVD_create.png) - --# When you click the Create AVD button, your new AVD will be available in AVD Manager. --# Press Start to launch the device. Be aware that any AVD (a.k.a. Emulator) is usually much slower - than a hardware Android device, so it may take up to several minutes to start. --# Go Run -\> Run/Debug in Eclipse IDE to run your application in regular or debugging mode. - Device Chooser will let you choose among the running devices or to start a new one. - -### Hardware Device - -If you have an Android device, you can use it to test and debug your applications. This way is more -authentic, though a little bit harder to set up. You need to make some actions for Windows and Linux -operating systems to be able to work with Android devices. No extra actions are required for Mac OS. -See detailed information on configuring hardware devices in subsections below. - -You may also consult the official [Android Developers site -instructions](http://developer.android.com/tools/device.html) for more information. +Usually the recipe above works as expected, but in some cases there are additional actions that must be performed. In this section we'll cover some cases. #### Windows host computer @@ -477,8 +162,8 @@ instructions](http://developer.android.com/tools/device.html) for more informati #### Linux host computer -By default Linux doesn't recognize Android devices, but it's easy to fix this issue. On Ubuntu Linux -you have to create a new **/etc/udev/rules.d/51-android.rules** configuration file that contains +While the latest Ubuntu versions work well with connected Android devices, there can be issues on older versions. +However, most of them can be fixed easily. You have to create a new **/etc/udev/rules.d/51-android.rules** configuration file that contains information about your Android device. You may find some Vendor ID's [here](http://developer.android.com/tools/device.html#VendorIds) or execute lsusb command to view VendorID of plugged Android device. Here is an example of such file for LG device: @@ -488,7 +173,13 @@ SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev" Then restart your adb server (even better to restart the system), plug in your Android device and execute adb devices command. You will see the list of attached devices: -![](images/usb_device_connect_ubuntu.png) +``` +savuor@rostislav-laptop:~/Android/Sdk/platform-tools$ ./adb devices +List of devices attached +R58MB40Q3VP device + +savuor@rostislav-laptop:~/Android/Sdk/platform-tools$ +``` #### Mac OS host computer @@ -497,5 +188,5 @@ No actions are required, just connect your device via USB and run adb devices to What's next ----------- -Now, when you have your development environment set up and configured, you may want to proceed to -installing OpenCV4Android SDK. You can learn how to do that in a separate @ref tutorial_O4A_SDK tutorial. +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 @ref tutorial_dev_with_OCV_on_Android tutorial. diff --git a/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.markdown b/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.markdown index 651d1e944308..d37d1710a37d 100644 --- a/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.markdown +++ b/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.markdown @@ -1,384 +1,113 @@ Android Development with OpenCV {#tutorial_dev_with_OCV_on_Android} =============================== -@prev_tutorial{tutorial_O4A_SDK} +@prev_tutorial{tutorial_android_dev_intro} @next_tutorial{tutorial_android_dnn_intro} | | | | -: | :- | -| Original author | Vsevolod Glumov | -| Compatibility | OpenCV >= 3.0 | - -@warning -This tutorial is deprecated. +| Original authors | Alexander Panov, Rostislav Vasilikhin | +| Compatibility | OpenCV >= 4.9.0 | This tutorial has been created to help you use OpenCV library within your Android project. -This guide was written with Windows 7 in mind, though it should work with any other OS supported by -OpenCV4Android SDK. +This guide was checked on Ubuntu but contains no platform-dependent parts, therefore should be compatible with any OS supported by Android Studio and OpenCV4Android SDK. This tutorial assumes you have the following installed and configured: +- Android Studio - JDK - Android SDK and NDK -- Eclipse IDE -- ADT and CDT plugins for Eclipse +- OpenCV for Android SDK from official [release page on Github](https://github.com/opencv/opencv/releases) + or [SourceForge](https://sourceforge.net/projects/opencvlibrary/). Advanced: as alternative the SDK may be + built from source code by [instruction on wiki](https://github.com/opencv/opencv/wiki/Custom-OpenCV-Android-SDK-and-AAR-package-build). If you need help with anything of the above, you may refer to our @ref tutorial_android_dev_intro guide. -This tutorial also assumes you have OpenCV4Android SDK already installed on your development machine -and OpenCV Manager on your testing device correspondingly. If you need help with any of these, you -may consult our @ref tutorial_O4A_SDK tutorial. - -If you encounter any error after thoroughly following these steps, feel free to contact us via -[OpenCV4Android](https://groups.google.com/group/android-opencv/) discussion group or OpenCV [Q&A -forum](https://forum.opencv.org) . We'll do our best to help you out. - -Using OpenCV Library Within Your Android Project ------------------------------------------------- - -In this section we will explain how to make some existing project to use OpenCV. Starting with 2.4.2 -release for Android, *OpenCV Manager* is used to provide apps with the best available version of -OpenCV. You can get more information here: `Android OpenCV Manager` and in these -[slides](https://docs.google.com/a/itseez.com/presentation/d/1EO_1kijgBg_BsjNp2ymk-aarg-0K279_1VZRcPplSuk/present#slide=id.p). +If you encounter any error after thoroughly following these steps, feel free to contact us via OpenCV [forum](https://forum.opencv.org). We'll do our best to help you out. -### Java +Hello OpenCV sample +------------------- -#### Application Development with Async Initialization +In addition to this instruction you can use some video guide, for example [this one](https://www.youtube.com/watch?v=bR7lL886-uc&ab_channel=ProgrammingHut) -Using async initialization is a **recommended** way for application development. It uses the OpenCV -Manager to access OpenCV libraries externally installed in the target system. +1. Open Android Studio and create empty project by choosing ***Empty Views Activity*** --# Add OpenCV library project to your workspace. Use menu - File -\> Import -\> Existing project in your workspace. + ![](images/create_empty_project.png) - Press Browse button and locate OpenCV4Android SDK (`OpenCV-2.4.9-android-sdk/sdk`). +2. Setup the project: + - Choose ***Java*** language + - Choose ***Groovy DSL*** build configuration language + - Choose ***Minumum SDK*** to the same version number as was used during OpenCV 4 Android build + - If you don't know it, you can find it in file `OpenCV-android-sdk/sdk/build.gradle` at `android -> defaultConfig -> minSdkVersion` - ![](images/eclipse_opencv_dependency0.png) + ![](images/setup_project.png) --# In application project add a reference to the OpenCV Java SDK in - Project -\> Properties -\> Android -\> Library -\> Add select OpenCV Library - 2.4.9. - ![](images/eclipse_opencv_dependency1.png) +3. Click ***File -> New -> Import module...*** and select OpenCV SDK path -In most cases OpenCV Manager may be installed automatically from Google Play. For the case, when -Google Play is not available, i.e. emulator, developer board, etc, you can install it manually using -adb tool. See `Manager Selection` for details. + ![](images/sdk_path.png) -There is a very base code snippet implementing the async initialization. It shows basic principles. -See the "15-puzzle" OpenCV sample for details. -@code{.java} -public class Sample1Java extends Activity implements CvCameraViewListener { +4. Set module name as `OpenCV` and press `Finish` - private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { - @Override - public void onManagerConnected(int status) { - switch (status) { - case LoaderCallbackInterface.SUCCESS: - { - Log.i(TAG, "OpenCV loaded successfully"); - mOpenCvCameraView.enableView(); - } break; - default: - { - super.onManagerConnected(status); - } break; - } - } - }; + ![](images/module_name.png) - @Override - public void onResume() - { - super.onResume(); - OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback); +5. OpenCV also provides experiemental Kotlin support. Please add Android Kotlin plugin to `MyApplication/OpenCV/build.gradle` file: + @code{.gradle} + plugins { + id 'org.jetbrains.kotlin.android' version '1.7.10' #version may differ for your setup } - - ... -} -@endcode -It this case application works with OpenCV Manager in asynchronous fashion. OnManagerConnected -callback will be called in UI thread, when initialization finishes. Please note, that it is not -allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback. Load -your own native libraries that depend on OpenCV after the successful OpenCV initialization. Default -BaseLoaderCallback implementation treat application context as Activity and calls Activity.finish() -method to exit in case of initialization failure. To override this behavior you need to override -finish() method of BaseLoaderCallback class and implement your own finalization method. - -#### Application Development with Static Initialization - -According to this approach all OpenCV binaries are included into your application package. It is -designed mostly for development purposes. This approach is deprecated for the production code, -release package is recommended to communicate with OpenCV Manager via the async initialization -described above. - --# Add the OpenCV library project to your workspace the same way as for the async initialization - above. Use menu File -\> Import -\> Existing project in your workspace, press Browse button and - select OpenCV SDK path (`OpenCV-2.4.9-android-sdk/sdk`). - - ![](images/eclipse_opencv_dependency0.png) - --# In the application project add a reference to the OpenCV4Android SDK in - Project -\> Properties -\> Android -\> Library -\> Add select OpenCV Library - 2.4.9; - - ![](images/eclipse_opencv_dependency1.png) - --# If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV - native libs from `/sdk/native/libs/` to your project - directory to folder `libs/`. - - In case of the application project **with a JNI part**, instead of manual libraries copying you - need to modify your Android.mk file: add the following two code lines after the - "include $(CLEAR_VARS)" and before - "include path_to_OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk" - @code{.make} - OPENCV_CAMERA_MODULES:=on - OPENCV_INSTALL_MODULES:=on @endcode - The result should look like the following: - @code{.make} - include $(CLEAR_VARS) + Like this: + ![](images/gradle_ocv_fix.png) + If you don't do this, you may get an error: + @code + Task failed with an exception. + ----------- + * Where: + Build file '/home/alexander/AndroidStudioProjects/MyApplication/opencv/build.gradle' line: 4 - # OpenCV - OPENCV_CAMERA_MODULES:=on - OPENCV_INSTALL_MODULES:=on - include ../../sdk/native/jni/OpenCV.mk + * What went wrong: + A problem occurred evaluating project ':opencv'. + > Plugin with id 'kotlin-android' not found. @endcode - After that the OpenCV libraries will be copied to your application `libs` folder during the JNI - build.v + The fix was found [here](https://stackoverflow.com/questions/73225714/import-opencv-sdk-to-android-studio-chipmunk) - Eclipse will automatically include all the libraries from the `libs` folder to the application - package (APK). +6. OpenCV project uses `aidl` and `buildConfig` features. Please enable them in + `MyApplication/OpenCV/build.gradle` file to `android` block: --# The last step of enabling OpenCV in your application is Java initialization code before calling - OpenCV API. It can be done, for example, in the static section of the Activity class: - @code{.java} - static { - if (!OpenCVLoader.initDebug()) { - // Handle initialization error - } - } - @endcode - If you application includes other OpenCV-dependent native libraries you should load them - **after** OpenCV initialization: - @code{.java} - static { - if (!OpenCVLoader.initDebug()) { - // Handle initialization error - } else { - System.loadLibrary("my_jni_lib1"); - System.loadLibrary("my_jni_lib2"); - } + @code{.gradle} + buildFeatures{ + aidl true + buildConfig true } - @endcode - -### Native/C++ - -To build your own Android application, using OpenCV as native part, the following steps should be -taken: --# You can use an environment variable to specify the location of OpenCV package or just hardcode - absolute or relative path in the `jni/Android.mk` of your projects. --# The file `jni/Android.mk` should be written for the current application using the common rules - for this file. - - For detailed information see the Android NDK documentation from the Android NDK archive, in the - file `/docs/ANDROID-MK.html`. - --# The following line: - @code{.make} - include C:\Work\OpenCV4Android\OpenCV-2.4.9-android-sdk\sdk\native\jni\OpenCV.mk @endcode - Should be inserted into the `jni/Android.mk` file **after** this line: - @code{.make} - include $(CLEAR_VARS) - @endcode --# Several variables can be used to customize OpenCV stuff, but you **don't need** to use them when - your application uses the async initialization via the OpenCV Manager API. - - @note These variables should be set **before** the "include .../OpenCV.mk" line: - @code{.make} - OPENCV_INSTALL_MODULES:=on + Like this: + ![](images/module_gradle_fix.png) + If you don't do this, you may get an error: + @code + JavaCameraView.java:15: error: cannot find symbol import org.opencv.BuildConfig; ^ symbol: class BuildConfig location: package org.opencv @endcode + The fix was found [here](https://stackoverflow.com/questions/76374886/error-cannot-find-symbol-import-org-opencv-buildconfig-android-studio) and [here](https://forum.opencv.org/t/task-compiledebugjavawithjavac-failed/13667/4) - Copies necessary OpenCV dynamic libs to the project libs folder in order to include them - into the APK. - @code{.make} - OPENCV_CAMERA_MODULES:=off - @endcode - Skip native OpenCV camera related libs copying to the project libs folder. - @code{.make} - OPENCV_LIB_TYPE:=STATIC - @endcode - Perform static linking with OpenCV. By default dynamic link is used and the project JNI lib - depends on libopencv_java.so. - --# The file `Application.mk` should exist and should contain lines: - @code{.make} - APP_STL := gnustl_static - APP_CPPFLAGS := -frtti -fexceptions - @endcode - Also, the line like this one: - @code{.make} - APP_ABI := armeabi-v7a - @endcode - Should specify the application target platforms. - - In some cases a linkage error (like - `"In function 'cv::toUtf16(std::basic_string<...>... undefined reference to 'mbstowcs'"`) - happens when building an application JNI library, depending on OpenCV. The following line in the - `Application.mk` usually fixes it: - @code{.make} - APP_PLATFORM := android-9 - @endcode +7. Add the module to the project: + - Click ***File -> Project structure... -> Dependencies -> All modules -> + (Add Dependency button) -> Module dependency*** + - Choose `app` + - Select `OpenCV` --# Either use @ref tutorial_android_dev_intro_ndk "manual" ndk-build invocation or - @ref tutorial_android_dev_intro_eclipse "setup Eclipse CDT Builder" to build native JNI lib - before (re)building the Java part and creating - an APK. - -Hello OpenCV Sample -------------------- - -Here are basic steps to guide you through the process of creating a simple OpenCV-centric -application. It will be capable of accessing camera output, processing it and displaying the result. - --# Open Eclipse IDE, create a new clean workspace, create a new Android project - File --\> New --\> Android Project --# Set name, target, package and minSDKVersion accordingly. The minimal SDK version for build with - OpenCV4Android SDK is 11. Minimal device API Level (for application manifest) is 8. --# Allow Eclipse to create default activity. Lets name the activity HelloOpenCvActivity. --# Choose Blank Activity with full screen layout. Lets name the layout HelloOpenCvLayout. --# Import OpenCV library project to your workspace. --# Reference OpenCV library within your project properties. - - ![](images/dev_OCV_reference.png) - --# Edit your layout file as xml file and pass the following layout there: - @code{.xml} - - - - - - @endcode --# Add the following permissions to the `AndroidManifest.xml` file: - @code{.xml} - - - - - - - - - @endcode --# Set application theme in AndroidManifest.xml to hide title and system buttons. - @code{.xml} - - @endcode --# Add OpenCV library initialization to your activity. Fix errors by adding required imports. - @code{.java} - private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { - @Override - public void onManagerConnected(int status) { - switch (status) { - case LoaderCallbackInterface.SUCCESS: - { - Log.i(TAG, "OpenCV loaded successfully"); - mOpenCvCameraView.enableView(); - } break; - default: - { - super.onManagerConnected(status); - } break; - } - } - }; - - @Override - public void onResume() - { - super.onResume(); - OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback); - } - @endcode --# Defines that your activity implements CvCameraViewListener2 interface and fix activity related - errors by defining missed methods. For this activity define onCreate, onDestroy and onPause and - implement them according to the code snippet below. Fix errors by adding required imports. - @code{.java} - private CameraBridgeViewBase mOpenCvCameraView; - - @Override - public void onCreate(Bundle savedInstanceState) { - Log.i(TAG, "called onCreate"); - super.onCreate(savedInstanceState); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - setContentView(R.layout.HelloOpenCvLayout); - mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.HelloOpenCvView); - mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); - mOpenCvCameraView.setCvCameraViewListener(this); - } - - @Override - public void onPause() - { - super.onPause(); - if (mOpenCvCameraView != null) - mOpenCvCameraView.disableView(); - } - - public void onDestroy() { - super.onDestroy(); - if (mOpenCvCameraView != null) - mOpenCvCameraView.disableView(); - } - - public void onCameraViewStarted(int width, int height) { - } - - public void onCameraViewStopped() { - } - - public Mat onCameraFrame(CvCameraViewFrame inputFrame) { - return inputFrame.rgba(); - } - @endcode --# Run your application on device or emulator. + ![](images/add_module_1.png) -Lets discuss some most important steps. Every Android application with UI must implement Activity -and View. By the first steps we create blank activity and default view layout. The simplest -OpenCV-centric application must implement OpenCV initialization, create its own view to show preview -from camera and implements CvCameraViewListener2 interface to get frames from camera and process it. + ![](images/add_module_2.png) -First of all we create our application view using xml layout. Our layout consists of the only one -full screen component of class org.opencv.android.JavaCameraView. This class is implemented inside -OpenCV library. It is inherited from CameraBridgeViewBase, that extends SurfaceView and uses -standard Android camera API. + ![](images/add_module_3.png) -After creating layout we need to implement Activity class. OpenCV initialization process has been -already discussed above. In this sample we use asynchronous initialization. Implementation of -CvCameraViewListener interface allows you to add processing steps after frame grabbing from camera -and before its rendering on screen. The most important function is onCameraFrame. It is callback -function and it is called on retrieving frame from camera. The callback input is object of -CvCameraViewFrame class that represents frame from camera. +8. Before using any OpenCV function you have to load the library first. If you application includes other OpenCV-dependent native libraries you should load them ***after*** OpenCV initialization. + Library is loaded at app start: + @snippet samples/android/tutorial-1-camerapreview/src/org/opencv/samples/tutorial1/Tutorial1Activity.java ocv_loader_init + Like this: + ![](images/sample_code.png) -@note Do not save or use CvCameraViewFrame object out of onCameraFrame callback. This object does -not have its own state and its behavior out of callback is unpredictable! +9. Choose a device to check the sample on and run the code by pressing `run` button -It has rgba() and gray() -methods that allows to get frame as RGBA and one channel gray scale Mat respectively. It expects -that onCameraFrame function returns RGBA frame that will be drawn on the screen. + ![](images/run_app.png) diff --git a/doc/tutorials/introduction/android_binary_package/images/AVD_create.png b/doc/tutorials/introduction/android_binary_package/images/AVD_create.png deleted file mode 100644 index f55ea51d7376..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/AVD_create.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/AVD_empty.png b/doc/tutorials/introduction/android_binary_package/images/AVD_empty.png deleted file mode 100644 index 6989f7e16768..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/AVD_empty.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/add_module_1.png b/doc/tutorials/introduction/android_binary_package/images/add_module_1.png new file mode 100644 index 000000000000..2653c433bba2 Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/add_module_1.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/add_module_2.png b/doc/tutorials/introduction/android_binary_package/images/add_module_2.png new file mode 100644 index 000000000000..55ac7bcdfcef Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/add_module_2.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/add_module_3.png b/doc/tutorials/introduction/android_binary_package/images/add_module_3.png new file mode 100644 index 000000000000..b9be8e8bb6e2 Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/add_module_3.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/android_emulator_opencv_manager_fail.png b/doc/tutorials/introduction/android_binary_package/images/android_emulator_opencv_manager_fail.png deleted file mode 100644 index 04839636ec87..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/android_emulator_opencv_manager_fail.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/android_package_7zip.png b/doc/tutorials/introduction/android_binary_package/images/android_package_7zip.png deleted file mode 100644 index 3bd6aa3457f1..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/android_package_7zip.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/android_sdk_and_avd_manager.png b/doc/tutorials/introduction/android_binary_package/images/android_sdk_and_avd_manager.png deleted file mode 100644 index cf5eb7d1abf8..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/android_sdk_and_avd_manager.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/choose_device.png b/doc/tutorials/introduction/android_binary_package/images/choose_device.png new file mode 100644 index 000000000000..76f3c3060fb2 Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/choose_device.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/cmd_adb_devices.png b/doc/tutorials/introduction/android_binary_package/images/cmd_adb_devices.png deleted file mode 100644 index e0e4853deca5..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/cmd_adb_devices.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/create_empty_project.png b/doc/tutorials/introduction/android_binary_package/images/create_empty_project.png new file mode 100644 index 000000000000..609f258d4574 Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/create_empty_project.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/dev_OCV_new_class.png b/doc/tutorials/introduction/android_binary_package/images/dev_OCV_new_class.png deleted file mode 100644 index 3a75b1108136..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/dev_OCV_new_class.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/dev_OCV_reference.png b/doc/tutorials/introduction/android_binary_package/images/dev_OCV_reference.png deleted file mode 100644 index 5179b2343097..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/dev_OCV_reference.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/device_details.png b/doc/tutorials/introduction/android_binary_package/images/device_details.png deleted file mode 100644 index 9c0a94000bad..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/device_details.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_10_crystal_clean.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_10_crystal_clean.png deleted file mode 100644 index 499247a48261..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_10_crystal_clean.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_11_run_as.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_11_run_as.png deleted file mode 100644 index 46c584d43b62..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_11_run_as.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_1_choose_workspace.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_1_choose_workspace.png deleted file mode 100644 index af06bd9b0d3d..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_1_choose_workspace.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_1a_locate_sdk.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_1a_locate_sdk.png deleted file mode 100644 index 95bb41e4bd88..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_1a_locate_sdk.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_2_window_preferences.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_2_window_preferences.png deleted file mode 100644 index 414673547ac2..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_2_window_preferences.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_3_preferences_android.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_3_preferences_android.png deleted file mode 100644 index 76a0589d71e5..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_3_preferences_android.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_4_locate_sdk.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_4_locate_sdk.png deleted file mode 100644 index 9657cc5c4b47..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_4_locate_sdk.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_5_import_command.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_5_import_command.png deleted file mode 100644 index f1117950142a..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_5_import_command.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_6_import_existing_projects.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_6_import_existing_projects.png deleted file mode 100644 index c397a834c656..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_6_import_existing_projects.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_7_select_projects.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_7_select_projects.png deleted file mode 100644 index e152bc4ed2cd..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_7_select_projects.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_8_false_alarm.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_8_false_alarm.png deleted file mode 100644 index 43295daf8be9..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_8_false_alarm.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_8a_target.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_8a_target.png deleted file mode 100644 index cee04cdfde37..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_8a_target.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_8b_fix_props.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_8b_fix_props.png deleted file mode 100644 index 061be3dc6120..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_8b_fix_props.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_9_errors_dissapearing.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_9_errors_dissapearing.png deleted file mode 100644 index 5a9157237be7..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_9_errors_dissapearing.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_NDK_build_success.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_NDK_build_success.png deleted file mode 100644 index 0bf2a85287ee..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_NDK_build_success.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_builder_types.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_builder_types.png deleted file mode 100644 index 61673a369940..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_builder_types.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_builders.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_builders.png deleted file mode 100644 index 69d90d839dfa..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_builders.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg1.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg1.png deleted file mode 100644 index 41e489f97408..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg1.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg2.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg2.png deleted file mode 100644 index e216b58fe17c..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg2.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg3.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg3.png deleted file mode 100644 index fd73103b286d..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg3.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg4.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg4.png deleted file mode 100644 index f8126b5b5695..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg4.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg5.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg5.png deleted file mode 100644 index e4e6f4fc5650..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg5.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg6.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg6.png deleted file mode 100644 index 8212ae700ebd..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg6.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg7.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg7.png deleted file mode 100644 index 205a06593c9b..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg7.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg8.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg8.png deleted file mode 100644 index d5253bd9b5a8..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_cdt_cfg8.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_build_options.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_build_options.png deleted file mode 100644 index 9a4683d5bf26..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_build_options.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_build_resources.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_build_resources.png deleted file mode 100644 index 9c3480ea7657..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_build_resources.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_main.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_main.png deleted file mode 100644 index 4c3bea0c8627..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_main.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_refresh.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_refresh.png deleted file mode 100644 index 4e36593b985d..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_refresh.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_specify_resources.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_specify_resources.png deleted file mode 100644 index bce08a883194..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_edit_configuration_specify_resources.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_adt.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_adt.png deleted file mode 100644 index 94491e0a619a..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_adt.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_cdt.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_cdt.png deleted file mode 100644 index ab34a6783fce..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_cdt.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_cdt_2.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_cdt_2.png deleted file mode 100644 index 3cb773e79b0d..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_inst_cdt_2.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_ndk_build.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_ndk_build.png deleted file mode 100644 index 0fdc59a9fce0..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_ndk_build.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_opencv_dependency0.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_opencv_dependency0.png deleted file mode 100644 index 5c5673b48174..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_opencv_dependency0.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_opencv_dependency1.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_opencv_dependency1.png deleted file mode 100644 index 5fc63da9baa9..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_opencv_dependency1.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/eclipse_windows_environment.png b/doc/tutorials/introduction/android_binary_package/images/eclipse_windows_environment.png deleted file mode 100644 index 5deced55c998..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/eclipse_windows_environment.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/emulator_canny.png b/doc/tutorials/introduction/android_binary_package/images/emulator_canny.png deleted file mode 100644 index d08340be9cee..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/emulator_canny.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/gradle_ocv_fix.png b/doc/tutorials/introduction/android_binary_package/images/gradle_ocv_fix.png new file mode 100644 index 000000000000..abaddce00f2c Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/gradle_ocv_fix.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/module_gradle_fix.png b/doc/tutorials/introduction/android_binary_package/images/module_gradle_fix.png new file mode 100644 index 000000000000..235f012e3c4b Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/module_gradle_fix.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/module_name.png b/doc/tutorials/introduction/android_binary_package/images/module_name.png new file mode 100644 index 000000000000..e0c85b0ec7ed Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/module_name.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/ndk_build.png b/doc/tutorials/introduction/android_binary_package/images/ndk_build.png deleted file mode 100644 index 633d0684e97d..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/ndk_build.png and /dev/null differ diff --git a/doc/tutorials/introduction/android_binary_package/images/run_app.png b/doc/tutorials/introduction/android_binary_package/images/run_app.png new file mode 100644 index 000000000000..97529779b76d Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/run_app.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/sample_code.png b/doc/tutorials/introduction/android_binary_package/images/sample_code.png new file mode 100644 index 000000000000..e800184ae0a1 Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/sample_code.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/sdk_ndk_manager.png b/doc/tutorials/introduction/android_binary_package/images/sdk_ndk_manager.png new file mode 100644 index 000000000000..fcd1ad006072 Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/sdk_ndk_manager.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/sdk_path.png b/doc/tutorials/introduction/android_binary_package/images/sdk_path.png new file mode 100644 index 000000000000..0f8fbd770350 Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/sdk_path.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/setup_project.png b/doc/tutorials/introduction/android_binary_package/images/setup_project.png new file mode 100644 index 000000000000..5586b1786fac Binary files /dev/null and b/doc/tutorials/introduction/android_binary_package/images/setup_project.png differ diff --git a/doc/tutorials/introduction/android_binary_package/images/usb_device_connect_ubuntu.png b/doc/tutorials/introduction/android_binary_package/images/usb_device_connect_ubuntu.png deleted file mode 100644 index fb9f72a45f11..000000000000 Binary files a/doc/tutorials/introduction/android_binary_package/images/usb_device_connect_ubuntu.png and /dev/null differ diff --git a/doc/tutorials/introduction/table_of_content_introduction.markdown b/doc/tutorials/introduction/table_of_content_introduction.markdown index 0e88fe25175c..22d9688291f9 100644 --- a/doc/tutorials/introduction/table_of_content_introduction.markdown +++ b/doc/tutorials/introduction/table_of_content_introduction.markdown @@ -21,7 +21,6 @@ Introduction to OpenCV {#tutorial_table_of_content_introduction} - @subpage tutorial_java_eclipse - @subpage tutorial_clojure_dev_intro - @subpage tutorial_android_dev_intro -- @subpage tutorial_O4A_SDK - @subpage tutorial_dev_with_OCV_on_Android - @subpage tutorial_android_dnn_intro - @subpage tutorial_android_ocl_intro diff --git a/samples/android/tutorial-1-camerapreview/src/org/opencv/samples/tutorial1/Tutorial1Activity.java b/samples/android/tutorial-1-camerapreview/src/org/opencv/samples/tutorial1/Tutorial1Activity.java index 68493bde57fc..1912eab78509 100644 --- a/samples/android/tutorial-1-camerapreview/src/org/opencv/samples/tutorial1/Tutorial1Activity.java +++ b/samples/android/tutorial-1-camerapreview/src/org/opencv/samples/tutorial1/Tutorial1Activity.java @@ -34,6 +34,7 @@ public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "called onCreate"); super.onCreate(savedInstanceState); + //! [ocv_loader_init] if (OpenCVLoader.initLocal()) { Log.i(TAG, "OpenCV loaded successfully"); } else { @@ -41,6 +42,7 @@ public void onCreate(Bundle savedInstanceState) { (Toast.makeText(this, "OpenCV initialization failed!", Toast.LENGTH_LONG)).show(); return; } + //! [ocv_loader_init] getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);