OpenCV for Tegra Examples

The NVIDIA CodeWorks for Android distribution includes a number of examples that demonstrate how OpenCV for Tegra functions are called in Android applications. These examples run successfully on Android APIs 9 and higher.


The following steps are required to configure your PC’s development environment for writing and building OpenCV for Tegra Android applications. More details about these steps can be found here.

  1. Download the latest NVIDIA CodeWorks for Android package for your operating system (Windows/Ubuntu/Mac) from:

    Install the package at a writable location on your PC (for example, C:\NVPACK\). The preferred location is your home directory.

  2. If Google Play is not accessible on your Tegra device, manually install the OpenCV for Tegra Library package (for Tegra 3 and higher, it is OpenCV_2.4.8.2_Manager_2.17_armv7a-neon.apk, and for Tegra 2, the two packages OpenCV_2.4.8.2_Manager_2.17_armv7a-neon.apk and OpenCV_2.4.8.2_binary_pack_armv7a.apk) on to it, as described in the section Usage Models.
  3. CodeWorks for Android includes a number of OpenCV for Tegra examples. They are pre-configured as Eclipse projects and can be imported and built easily in the Eclipse package that is distributed with CodeWorks for Android. To import the OpenCV for Tegra example projects into Eclipse follow the steps listed below.
    1. Open Eclipse by double clicking on its application binary located at <path to CodeWorks for Android directory>/eclipse/.
    2. Set the Eclipse workspace to <path to CodeWorks for Android directory/nvsample_workspace> and OK.
    3. Right click on project in the Package Explorer > Import > General > Existing Projects into Workspace > Next.
    4. Select root directory > Browse to <path to TADP directory>/OpenCV- > Open.
    5. Select the OpenCV Library, the OpenCV Samples and OpenCV Tutorials that are populated into the Projects window > Finish.
      Everything you need to build your first OpenCV for Tegra Android application is now ready. Wait for Eclipse to finish building all the projects before proceeding to the next step.
    6. Connect your Tegra Android device to your PC via a USB cable and ensure that it is accessible through adb devices.
    7. To run the first OpenCV for Tegra Android application on your Tegra device, right click on any one of the projects titled OpenCV Sample - xxx or OpenCV Tutorial x - xxx > Run As > 1 Android Application.

Note: In order to run successfully, the OpenCV Tutorials 1-4 and the OpenCV Samples require that the OpenCV Manager (and the OpenCV for Tegra library binary pack in case of Tegra 2) be present on your Tegra device. If this is not the case, an attempt will be made to install the required .apk files from Google Play the very first time you run any of these applications on Tegra. If Google Play is not accessible on your Tegra device, these examples will fail to run entirely. In such a case, please install the OpenCV Manager (and the OpenCV binary pack, if needed) manually on to your Tegra device using the procedure outlined in Step 2 and re-run the OpenCV examples.


The OpenCV for Tegra examples belong to two categories – tutorials (called OpenCV Tutorial x – xxx) and samples (called OpenCV Sample – xxx). The tutorials show important aspects for a beginner, including: using OpenCV in Java, C++, working with a camera, and mixing both Java and C++ calls to OpenCV in a single application.

The OpenCV Samples demonstrate how different functions from the OpenCV for Tegra library can be used to achieve a variety of image processing and computer visions tasks.

The OpenCV for Tegra examples are described in detail in the following sections.


NVIDIA® GameWorks™ Documentation Rev. 1.0.220830 ©2014-2022. NVIDIA Corporation and affiliates. All Rights Reserved.