Fix formatting in Android tutorials

This commit is contained in:
Andrey Kamaev 2012-08-17 19:23:45 +04:00
parent ff3aa6cbe1
commit bf4c1df0d0
2 changed files with 183 additions and 151 deletions

View File

@ -36,21 +36,21 @@ The structure of package contents looks as follows:
OpenCV-2.4.2-android-sdk
|_ apk
| |_ OpenCV_2.4.2_binary_pack_XXX.apk
| |_ OpenCV_2.4.2_Manager.apk
| |_ OpenCV_2.4.2_binary_pack_XXX.apk
| |_ OpenCV_2.4.2_Manager.apk
|
|_ doc
|_ samples
|_ sdk
| |_ etc
| |_ java
| |_ native
| |_ 3rdparty
| |_ jni
| |_ libs
| |_ armeabi
| |_ armeabi-v7a
| |_ x86
| |_ etc
| |_ java
| |_ native
| |_ 3rdparty
| |_ jni
| |_ libs
| |_ armeabi
| |_ armeabi-v7a
| |_ x86
|
|_ license.txt
|_ README.android
@ -64,11 +64,11 @@ The structure of package contents looks as follows:
* :file:`sdk/etc` folder contains Haar and LBP cascades distributed with OpenCV.
* :file:`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 dev kits without Market or internet require this packages to be installed manually.
(Install the `Manager.apk` and the corresponding `binary_pack.apk` depending on the device CPU, the Manager GUI provides this info).
**Note**: installation from internet is the preferable way since we may publish updated versions of this packages on the Market.
* :file:`samples` folder contains sample applications projects and their prebuilt packages (APK).
@ -76,7 +76,7 @@ The structure of package contents looks as follows:
* :file:`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/trunk/.
Generally, it's more up-to-date, but can refer to not-yet-released functionality.
@ -94,10 +94,10 @@ Starting version 2.4.2 `OpenCV4Android SDK` uses `OpenCV Manager` API for librar
For additional information on OpenCV Manager see the:
* |OpenCV4Android_Slides|_
* |OpenCV4Android_Reference|_
* |OpenCV4Android_Slides|_
* |OpenCV4Android_Reference|_
..
@ -196,15 +196,15 @@ Open OpenCV library and samples in Eclipse
However, **all these errors are only false-alarms**!
Just give a minute to Eclipse to complete initialization.
In some cases these errors disappear after :menuselection:`Project --> Clean... --> Clean all --> OK`
or after pressing :kbd:`F5` (for Refresh action) when selecting error-label-marked projects in :guilabel:`Package Explorer`.
Sometimes more advanced manipulations are required:
* The provided projects are configured for ``API 11`` target (and ``API 9`` for the library) that can be missing platform in your Android SDK.
After right click on any project select :guilabel:`Properties` and then :guilabel:`Android` on the left pane.
Click some target with `API Level` 11 or higher:
The provided projects are configured for ``API 11`` target (and ``API 9`` for the library) that can be missing platform in your Android SDK.
After right click on any project select :guilabel:`Properties` and then :guilabel:`Android` on the left pane.
Click some target with `API Level` 11 or higher:
.. image:: images/eclipse_8a_target.png
:alt: Updating target
@ -239,10 +239,10 @@ Well, running samples from Eclipse is very simple:
* Connect your device with :command:`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).
* 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 :guilabel:`Package Explorer` and just press :kbd:`Ctrl + F11` or select option :menuselection:`Run --> Run` from the main menu, or click :guilabel:`Run` button on the toolbar.
@ -263,33 +263,33 @@ Well, running samples from Eclipse is very simple:
.. image:: images/android_emulator_opencv_manager_fail.png
:alt: You will see this message if you have no OpenCV Manager installed
:align: center
To get rid of the message you will need to install `OpenCV Manager` and the appropriate `OpenCV binary pack`.
Simply tap :menuselection:`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. Open the console/terminal and type in the following two commands:
.. code-block:: sh
:linenos:
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.2_Manager.apk
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.2_binary_pack_armv7a.apk
If you're running Windows, that will probably look like this:
.. image:: images/install_opencv_manager_with_adb.png
:alt: Run these commands in the console to install OpenCV Manager
:align: center
When done, you will be able to run OpenCV samples on your device/emulator seamlessly.
* Here is ``Tutorial 2 - Use OpenCV Camera`` sample, running on top of stock camera-preview of the emulator.
.. image:: images/emulator_canny.png
:height: 600px
:alt: Tutorial 1 Basic - 1. Add OpenCV - running Canny
:align: center
What's next
===========

View File

@ -75,7 +75,7 @@ You need the following software to be installed in order to develop for Android
sudo update-java-alternatives --set java-6-sun
**TODO:** add a note on Sun/Oracle Java installation on Ubuntu 12.
.. **TODO:** add a note on Sun/Oracle Java installation on Ubuntu 12.
#. **Android SDK**
@ -241,27 +241,29 @@ where:
The script :file:`Android.mk` usually has the following structure:
.. code-block:: make
:linenos:
LOCAL_PATH := $(call my-dir)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := <module_name>
LOCAL_SRC_FILES := <list of .c and .cpp project files>
<some variable name> := <some variable value>
...
<some variable name> := <some variable value>
include $(CLEAR_VARS)
LOCAL_MODULE := <module_name>
LOCAL_SRC_FILES := <list of .c and .cpp project files>
<some variable name> := <some variable value>
...
<some variable name> := <some variable value>
include $(BUILD_SHARED_LIBRARY)
include $(BUILD_SHARED_LIBRARY)
This is the minimal file :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 :file:`Android.mk`.
Usually the file :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 :file:`Application.mk`:
.. code-block:: make
:linenos:
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
.. _NDK_build_cli:
@ -332,75 +334,76 @@ We recommend the approach based on Eclipse :abbr:`CDT(C/C++ Development Tooling)
#. Open Eclipse and load the Android app project to configure.
#. Add C/C++ Nature to the project via Eclipse menu :guilabel:`New -> Other -> C/C++ -> Convert to a C/C++ Project`.
.. image:: images/eclipse_cdt_cfg1.png
:alt: Configure CDT
:align: center
` `
.. image:: images/eclipse_cdt_cfg1.png
:alt: Configure CDT
:align: center
.. image:: images/eclipse_cdt_cfg2.png
:alt: Configure CDT
:align: center
And:
.. image:: images/eclipse_cdt_cfg2.png
:alt: Configure CDT
:align: center
#. Select the project(s) to convert. Specify "Project type" = ``Makefile project``, "Toolchains" = ``Other Toolchain``.
.. image:: images/eclipse_cdt_cfg3.png
:alt: Configure CDT
:align: center
#. Open :guilabel:`Project Properties -> C/C++ Build`, unckeck ``Use default build command``, replace "Build command" text from ``"make"`` to
``"${NDKROOT}/ndk-build.cmd"`` on Windows,
#. Open :guilabel:`Project Properties -> C/C++ Build`, unckeck ``Use default build command``, replace "Build command" text from ``"make"`` to
``"${NDKROOT}/ndk-build"`` on Linux and MacOS.
.. image:: images/eclipse_cdt_cfg4.png
:alt: Configure CDT
:align: center
``"${NDKROOT}/ndk-build.cmd"`` on Windows,
``"${NDKROOT}/ndk-build"`` on Linux and MacOS.
.. image:: images/eclipse_cdt_cfg4.png
:alt: Configure CDT
:align: center
#. Go to :guilabel:`Behaviour` tab and change "Workbench build type" section like shown below:
.. image:: images/eclipse_cdt_cfg5.png
:alt: Configure CDT
:align: center
.. image:: images/eclipse_cdt_cfg5.png
:alt: Configure CDT
:align: center
#. Press :guilabel:`OK` and make sure the ``ndk-build`` is successfully invoked when building the project.
.. image:: images/eclipse_cdt_cfg6.png
:alt: Configure CDT
:align: center
.. image:: images/eclipse_cdt_cfg6.png
:alt: Configure CDT
:align: center
#. 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.
.. image:: images/eclipse_cdt_cfg7.png
:alt: Configure CDT
:align: center
.. image:: images/eclipse_cdt_cfg7.png
:alt: Configure CDT
:align: center
#. Open :guilabel:`Project Properties -> C/C++ General -> Paths and Symbols` and add the following **Include** paths for **C++**:
::
::
${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
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.
.. image:: images/eclipse_cdt_cfg8.png
:alt: Configure CDT
:align: center
The last path should be changed to the correct absolute or relative path to OpenCV4Android SDK location.
.. note:: The latest Android NDK **r8b** has a bit different STL headers path. So if you use this NDK version please use the following modified **Include** paths list:
This should clear the syntax error notifications in Eclipse C++ editor.
::
.. image:: images/eclipse_cdt_cfg8.png
:alt: Configure CDT
:align: center
${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
.. note:: The latest Android NDK **r8b** uses different STL headers path. So if you use this NDK release add the following **Include** paths list instead:
::
${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
Debugging and Testing
@ -412,12 +415,16 @@ 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 :guilabel:`Window -> AVD Manager`.
**TBD:** how to start AVD Manager without Eclipse...
.. **TBD:** how to start AVD Manager without Eclipse...
#. Press the :guilabel:`New` button in :guilabel:`AVD Manager` window.
#. :guilabel:`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.
.. image:: images/AVD_create.png
:alt: Configure builders
:align: center
.. image:: images/AVD_create.png
:alt: Configure builders
:align: center
#. When you click the :guilabel:`Create AVD` button, your new AVD will be availible in :guilabel:`AVD Manager`.
#. Press :guilabel:`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 :guilabel:`Run -> Run/Debug` in Eclipse IDE to run your application in regular or debugging mode. :guilabel:`Device Chooser` will let you choose among the running devices or to start a new one.
@ -435,81 +442,106 @@ Windows host computer
#. Attach the Android device to your PC with a USB cable.
#. Go to :guilabel:`Start Menu` and **right-click** on :guilabel:`Computer`. Select :guilabel:`Manage` in the context menu. You may be asked for Administrative permissions.
#. Select :guilabel:`Device Manager` in the left pane and find an unknown device in the list. You may try unplugging it and then plugging back in order to check whether it's your exact equipment appears in the list.
.. image:: images/usb_device_connect_01.png
:alt: Unknown device
:align: center
.. image:: images/usb_device_connect_01.png
:alt: Unknown device
:align: center
#. Try your luck installing `Google USB drivers` without any modifications: **right-click** on the unknown device, select :guilabel:`Properties` menu item --> :guilabel:`Details` tab --> :guilabel:`Update Driver` button.
.. image:: images/usb_device_connect_05.png
:alt: Device properties
:align: center
.. image:: images/usb_device_connect_05.png
:alt: Device properties
:align: center
#. Select :guilabel:`Browse computer for driver software`.
.. image:: images/usb_device_connect_06.png
:alt: Browse for driver
:align: center
.. image:: images/usb_device_connect_06.png
:alt: Browse for driver
:align: center
#. Specify the path to :file:`<Android SDK folder>/extras/google/usb_driver/` folder.
.. image:: images/usb_device_connect_07.png
:alt: Browse for driver
:align: center
.. image:: images/usb_device_connect_07.png
:alt: Browse for driver
:align: center
#. If you get the prompt to install unverified drivers and report about success - you've finished with USB driver installation.
.. image:: images/usb_device_connect_08.png
:alt: Install prompt
:align: center
` `
.. image:: images/usb_device_connect_08.png
:alt: Install prompt
:align: center
` `
.. image:: images/usb_device_connect_09.png
:alt: Installed OK
:align: center
.. image:: images/usb_device_connect_09.png
:alt: Installed OK
:align: center
#. Otherwise (getting the failure like shown below) follow the next steps.
.. image:: images/usb_device_connect_12.png
:alt: No driver
:align: center
.. image:: images/usb_device_connect_12.png
:alt: No driver
:align: center
#. Again **right-click** on the unknown device, select :guilabel:`Properties --> Details --> Hardware Ids` and copy the line like ``USB\VID_XXXX&PID_XXXX&MI_XX``.
.. image:: images/usb_device_connect_02.png
:alt: Device properties details
:align: center
.. image:: images/usb_device_connect_02.png
:alt: Device properties details
:align: center
#. Now open file :file:`<Android SDK folder>/extras/google/usb_driver/android_winusb.inf`. Select either ``Google.NTx86`` or ``Google.NTamd64`` section depending on your host system architecture.
.. image:: images/usb_device_connect_03.png
:alt: "android_winusb.inf"
:align: center
.. image:: images/usb_device_connect_03.png
:alt: "android_winusb.inf"
:align: center
#. There should be a record like existing ones for your device and you need to add one manually.
.. image:: images/usb_device_connect_04.png
:alt: "android_winusb.inf"
:align: center
.. image:: images/usb_device_connect_04.png
:alt: "android_winusb.inf"
:align: center
#. Save the :file:`android_winusb.inf` file and try to install the USB driver again.
.. image:: images/usb_device_connect_05.png
:alt: Device properties
:align: center
` `
.. image:: images/usb_device_connect_05.png
:alt: Device properties
:align: center
.. image:: images/usb_device_connect_06.png
:alt: Browse for driver
:align: center
` `
` `
.. image:: images/usb_device_connect_06.png
:alt: Browse for driver
:align: center
` `
.. image:: images/usb_device_connect_07.png
:alt: Browse for driver
:align: center
.. image:: images/usb_device_connect_07.png
:alt: Browse for driver
:align: center
#. This time installation should go successfully.
.. image:: images/usb_device_connect_08.png
:alt: Install prompt
:align: center
` `
.. image:: images/usb_device_connect_08.png
:alt: Install prompt
:align: center
` `
.. image:: images/usb_device_connect_09.png
:alt: Installed OK
:align: center
.. image:: images/usb_device_connect_09.png
:alt: Installed OK
:align: center
#. And an unknown device is now recognized as an Android phone.
.. image:: images/usb_device_connect_10.png
:alt: "Known" device
:align: center
.. image:: images/usb_device_connect_10.png
:alt: "Known" device
:align: center
#. Successful device USB connection can be verified in console via ``adb devices`` command.
.. image:: images/usb_device_connect_11.png
:alt: "adb devices"
:align: center
.. image:: images/usb_device_connect_11.png
:alt: "adb devices"
:align: center
#. Now, in Eclipse go :guilabel:`Run -> Run/Debug` to run your application in regular or debugging mode. :guilabel:`Device Chooser` will let you choose among the devices.
@ -519,13 +551,13 @@ By default Linux doesn't recognize Android devices, but it's easy to fix this is
.. code-block:: guess
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"
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 :command:`adb devices` command. You will see the list of attached devices:
.. image:: images/usb_device_connect_ubuntu.png
:alt: List of attached devices
:align: center
.. image:: images/usb_device_connect_ubuntu.png
:alt: List of attached devices
:align: center
MacOS host computer
^^^^^^^^^^^^^^^^^^^