Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
OpenCV Android Programming By Example

You're reading from   OpenCV Android Programming By Example Leverage OpenCV to develop vision-aware and intelligent Android applications.

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781783550593
Length 202 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Installing Tegra Android Development Pack

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.

Downloading and installing TADP

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:

  • Windows 64-bit
  • Mac OS X
  • Ubuntu Linux (32/64-bit)

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.

Note

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:

  1. Follow the onscreen instructions after you read and accept the license agreement.
  2. You will need to choose the type of installation. Select a Custom installation and click on the Next button:
    Downloading and installing TADP
  3. Select the components to be installed as depicted and click on the Next button:
    Downloading and installing TADP
  4. You need to name the installation and download the directory.

    Note

    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.

  5. Now you are ready to install the selected components. Click on the Next button.
  6. In case you are behind a proxy, you can enter the proxy details; otherwise, click on the Next button.
  7. The installer will start to download all the selected components; this may take a while depending on your Internet connection.
  8. After the download has finished, click Next to start installing the selected components.

    Note

    Sometimes, the installer window will not respond; this is okay. After a few minutes, the installation will continue in a normal way.

  9. Select the post-installation action that you want and click on the Finish button.

TADP post-installation configuration

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.

Installing emulator system images

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:

  1. Go to the installation directory that you selected while installing TADP.
  2. Open the SDK folder; in this case, it is android-sdk-windows.
  3. Run the SDK Manager.
  4. For every installed Android X.X, select a system image for the emulator, such as ARM EABI V7a System Image:
    Installing emulator system images
  5. Click Install packages.
  6. Read and accept the license agreement for the selected components.
  7. Click Install.

Now, you can test your applications on an emulator of any of the installed targets.

Configuring Eclipse to work with NDK

You also need to configure Eclipse to run with NDK so that you can build your native apps directly from Eclipse:

  1. Launch Eclipse from the installation directory that you specified earlier.
  2. Open Window | Preferences.
  3. In the pane on the left-hand side, open Android Tree.
  4. Select the tree node labeled NDK.
  5. In the right pane, click Browse and select the NDK directory; you will find it under the installation directory.
  6. Click OK.

NDK verification

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:

  1. Launch Eclipse.
  2. From the NDK installation directory—in my case, C:\NVPACK\android-ndk-r10c\—import the hello-jni sample project from the samples folder as if you are importing any other Android project.
  3. Right-click on the HelloJni project.
  4. In the context menu, choose Android Tools | Add Native Support.
  5. Make sure that the library name is set to hello-jni; it should be named this by default.
  6. Start the emulator with the target of your choice.
  7. Right click on the 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:

NDK verification

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.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image