Sep 20, 2013

Android Augmented Reality: Introduction of Vuforia SDK

The Vuforia™ SDK allows you to build vision-based augmented reality applications. It is available for Android, iOS and as an Extension to Unity - a cross-platform game engine.

High-level system overview
  • Multiple trackables (tracking types):
  • Image Targets
  • Multi-Targets
  • Cylinder Targets
  • Word Targets
  • Frame Markers
  • Real-world Interactions
  • Virtual Buttons

source :

1. Setup Vuforia SDK v2.6

I assume that you already have Android SDK and NDK setup in computer.

Step 1: Download Vuforia SDK v2.6 For Android

Step 2: Extract vuforia-sdk-android-2-6-10 in desire folder

Step 3: Download Samples from following link

Step 4: Extract sample zip file vuforia-sampleapps-android-2-6-7

Step 5: Copy all samples from extracted folder and paste in <vuforia_sdk>/samples folder
<vuforia_sdk> is directory location where you extracted SDK in step 2

2. Compile and execute ImageTargats sample app

Sample has NDK and SDK coding, so normally I compile NDK from terminal and SDK using eclipse

Step 1: Open Terminal & go to <vuforia_sdk>/sample/ImageTargats-2-6-7/, 

Step 2: Execute "ndk-build" to compile NDK code, make sure you have environment variable which point to Android NDK directory otherwise terminal will give you "comment not found" error

Step 3: Open eclipse and import ImageTargats-2-6-7 project

Step 4: Set class path variable in eclipse

In Eclipse, go to Window->Preferences.
Navigate to Java->Build Path->Classpath Variables using the hierarchy browser.
Create a new variable by selecting New...

into the Name: field, and navigate using Folder... to the vuforia-sdk-android-xx-yy-zz directory

Step 5: Right click on "ImageTargats" project -> select run -> Android Application

Step 6: Take Print of target image

Step 7: Open ImageTargets Android application in device and place device in front of printed target image, you will see nice 3d teapot

3. Understand code of ImageTargats app

Files & Description
  • SDK
    • Display about content, start ImageTarget activity
    • Exposes functionality for logging, support class for logging
    • This class is responsible for almost everything (i.e. managing camera, surface view for rendering, loading texture, etc)
    • extends GLSurfaceView.Renderer which is used to render OpenGL graphics, this class is also act as bridge between native code and java code, actual rendering is happening in native code using "renderFrame()" method
    • display simple image for 2000 milliseconds and open activity
    • This class extends GLSurfaceView, it is responsible for setting up and configuring the OpenGL surface view.
    • Texture is a support class for the QCAR samples applications, It load texture image from asset to memory
  • NDK
    • standard android build script for module
    • standard android build script for application
    • CubeShader.h: Defines OpenGL shaders as char* strings. OpenGL Shading Language (abbreviated: GLSL or GLslang), is a high-level shading language based on the syntax of the C programming language. It was created by the OpenGL ARB to give developers more direct control of the graphics pipeline without having to use ARB assembly language or hardware-specific languages. More.
    • ImageTargets.cpp: It is used to bridge between native and java code, This class has JNI methods, "startCamera" method actually start capturing frame from camera and identify tracker using QCAR tracker manager API
    • SampleUtil.h/cpp: A utility class which define common & static function like printMatrix, checkGLError, setRotationMatrix...
    • Teapot.h: This class define teapot OpenGL co-ordinate, vertices and indices,Vuforia API only identify marker, for content we can use OpenGL, Content generation and display is most important part of Augmented Reality, I personally thing that Metaio has more robust and powerful content generation system.
    • Texture.h/cpp: another utility class, It load Texture buffer from object.