-
Book Overview & Buying
-
Table Of Contents
OpenCV Android Programming By Example
By :
TADP was released by NVIDIA to make the preparation for the Android development environment a seamless process.
NVIDIA has released TADP version 3.0r4 to support Android SDK (23.0.2), NDK (r10c), and OpenCV for Tegra 2.4.8.2, which is a regular OpenCV4Android SDK extended with Tegra-specific optimizations.
To get TADP, visit https://developer.nvidia.com/tegra-android-development-pack and follow the steps to become a registered developer; it is a free membership.
Once you have your membership activated, log in and download the version corresponding to your operating system. NVIDIA supports the following operating systems:
In my case, I have Windows 7 64-bit on my machine, so from now on, all the upcoming steps are tested and working fine on this operating system. However, I don't expect any major changes if you are working with a different operating system.
For the Ubuntu installation, TADP will need you to have root privileges, so make sure that you do.
Once you finish downloading the TADP installer, launch it and perform the following steps:


Note that if you have a previous installation, you will get a warning message that the previous installation needs to be uninstalled. To uninstall the previous installation, go to the previous installation directory and run tadp_uninstall.exe.
Sometimes, the uninstaller doesn't clean everything. In this case, you need to delete the contents of the previous installation directory manually.
Sometimes, the installer window will not respond; this is okay. After a few minutes, the installation will continue in a normal way.
Yes, TADP will download and install everything for you; yet you still need to do some post-installation configuration in order to make sure that everything will work properly.
You need to install a system image for every Android SDK platform installed in case you want to run an emulator with this SDK platform as a target.
To do so, just follow these simple steps:
android-sdk-windows.
Now, you can test your applications on an emulator of any of the installed targets.
You also need to configure Eclipse to run with NDK so that you can build your native apps directly from Eclipse:
As the OpenCV libraries are written in C/C++, the first step to verify that your environment is working is to make sure that you are able to run Android applications that use native code:
C:\NVPACK\android-ndk-r10c\—import the hello-jni sample project from the samples folder as if you are importing any other Android project.HelloJni project.hello-jni; it should be named this by default.hello-jni project in the project explorer. In the context menu, choose Run as | Android application.In your console output, there should be a list of .so files; these are the native shared libraries that NDK has built using Application Binary Interface (ABI), which defines exactly how your machine code should look.
Android NDK supports different architectures. By default, your .so will be built for ARM EABI in addition to MIPS and x86 if you specify so in the application.mk file. We will discuss this subject later in this chapter.
If everything runs smoothly, your emulator should have an app running as follows:

This application is very simple and a good checkpoint to verify that you are able to invoke native code from your Android application.
Basically, what you see on the emulator screen is a string returned from the native code and displayed by the Android framework in a text view.
Change the font size
Change margin width
Change background colour