Bookmark and Share

Designing Visionary Mobile Apps Using the Tegra Android Development Pack

by Shalini Gupta
NVIDIA
This article was originally published at EE Times' Embedded.com Design Line. It is reprinted here with the permission of EE Times.

NVIDIA makes life easier for Android developers by providing all of the software tools needed to develop for Android (see "Developing OpenCV Computer Vision Apps for the Android Platform") on NVIDIA’s Tegra platform in a single easy-to-install TADP (Tegra Android Development Pack). The TADP is available for Windows, Mac OS X, Ubuntu Linux 32-bit and Ubuntu Linux 64-bit. It is targeted for Tegra devices, but will set up your development environment for any Android device.

You can obtain the TADP by registering on NVIDIA’s Developer Zone website and by applying for the Tegra Registered Developer Program. Once approved, typically within 48 hours, you’ll be able to access the TADP by logging into your NVIDIA Developer Zone account and by following the links to DEVELOPER CENTERS > Mobile > TEGRA ANDROID DEVELOPMENT PACK.

Every 1-2 months, Nvidia publishes incremental updates to the TADP containing newer versions of its components. Major updates are published about once a year. These updates may contain a completely restructured package with new components.

OpenCV for Tegra

Beginning with TADP 2.0, NVIDIA provides a software development kit (SDK) for OpenCV for Tegra. OpenCV for Tegra is a fully compatible, optimized backend implementation of OpenCV for Android, which runs 2-20x faster on Tegra 3-based devices.

The OpenCV for Tegra SDK in the TADP contains:

  • OpenCV for Tegra libraries in binary form
  • Pre-configured Android Eclipse example projects for OpenCV for Tegra
  • Step-by-step documentation on How to Use OpenCV for Tegra, including details of its functionality, and
  • An OpenCV for Tegra Demo App, which demonstrates the optimization that can be achieved with OpenCV for Tegra vs. the un-optimized OpenCV for Android library on Tegra 3-based devices .

The OpenCV for Tegra library is packaged into a single Android Application Package (OpenCV_2.4.2_binary_pack_tegra3.apk) located in the OpenCV-2.4.2-Tegra-sdk/apk/ folder of the TADP installation directory. You can also download this .apk, free of cost, from the Google Play store. Once installed, the OpenCV for Tegra libraries are ready to be dynamically linked into your Android applications.

If your application uses the OpenCV Manager service, it will automatically search for and load the OpenCV for Tegra library on your Tegra 3-based device at run time. If the OpenCV for Tegra library is absent on your device, its .apk will either be downloaded automatically from the Google Play store, or, if the latter is inaccessible, the user will be prompted to install the .apk manually.

Alternatively, the native (C/C++) versions of OpenCV for Tegra libraries are also availablein binary form in the OpenCV-2.4.2-Tegra-sdk/sdk/native/libs/tegra3 folder of your TADP installation directory. You can link them statically into the native part of your Android applications by appropriately including the path to the OpenCV-tegra3.mk file in your application’s Android.mk file:

#OPENCV_LIB_TYPE:=STATIC
include ../../sdk/native/jni/OpenCV-tegra3.mk

By default, all the Eclipse OpenCV examples in the TADP come pre-configured to use the OpenCV for Tegra libraries (via static or dynamic linking). Note that if the Tegra optimized libraries are statically linked in, they are not guaranteed to run on non-Tegra 3-based device. Hence, it is advisable to always use dynamic linking via the OpenCV Manager service in your published apps to ensure their compatibility on different hardware platforms.

To determine whether the Tegra optimized functions are indeed being used in your application, check for the presence of the following message in the Android systems logs. You can use the adb logcat command to write out the system logs.

E/OpenCV_for_Tegra(28465): Tegra platform detected, optimizations are switched ON!

Additionally, the OpenCV Manager installed on your device will display the information about your detected Tegra hardware (Figure 1).

Figure 1: The OpenCV Manager displays information about your detected Tegra hardware

To check out the speedups you can get with the OpenCV for Tegra, download and run the OpenCV for Tegra Demo App. You can download it from Google Play or find its OpenCVBenchmark.apk in the OpenCV-2.4.2-Tegra-sdk/apk/ folder of your TADP installation directory. The app continuously grabs preview frames from the camera, processes them in an asynchronous processing thread, and displays the processed frames.

Different processing modes (medianBlur, GaussianBlur, etc.) can be selected from the menu options. OpenCV for Tegra optimizations can be turned on or off by touching on the NVIDIA logo on the lower right of the display. When Tegra optimizations are enabled, the NVIDIA logo will turn green. Check the information displayed in the upper part of the display for your hardware's performance statistics.

Shalini Gupta is a Senior Mobile Computer Vision Engineer at NVIDIA. Her previous experience includes two years as an Imaging and Architecture Scientist at Texas Instruments, along with work at AT&T Laboratories and Advanced Digital Imaging Research, LLC (where she developed successful novel algorithms for 3D facial recognition). Shalini obtained her Bachelors Degree in Electronics and Electrical Communication Engineering at Punjab Engineering College, and her Masters Degree and Ph.D. in Electrical and Computer Engineering at the University of Texas at Austin.