#Tutorial 1: Get started developing AR Apps with Unity and Vuforia [ImageTarget]

Augmented Reality Tutorial: 1 [ImageTarget]


Literature review

Vuforia (AR SDK) is a software platform for creating Augmented Reality applications. Developers can easily add advanced computer vision functionality to any application, allowing it to recognize images and objects, or reconstruct environments in the real world.

Whether you are building an enterprise app to deliver step by step instructions and training, or an interactive marketing campaign, or product visualization to enable shopping experiences, Vuforia has all of the functionality and performance to meet your needs.

Image Targets: Image Targets represent images that the Vuforia SDK can detect and track. Unlike traditional fiducial markers and QR codes, Image Targets do not need special black and white regions or codes to be recognized. The SDK detects and tracks the features that are naturally found in the image itself by comparing these natural features against a known target resource database. 

Use Cases: Common uses of Image Targets include recognizing and augmenting printed media and product packaging for marketing campaigns, gaming and visualizing products in the environment where the product was intended to be used.  

Getting Started

This vuforia ImaeTarget tutorial is meant for newcomers to get started with developing Augmented Reality applications. In upcoming tutorials, we will focus on advanced AR applications and implementation.

Prerequisite (Tools Needed):

We will be using Vuforia AR SDK and Unity 3D engine and Android SDK for this tutorial. Make sure you have downloaded the following before proceeding further.

  1. Unity Engine (Version 5.6.0f3 I’m using now)
  2. Vuforia SDK for Unity Platform ( Vuforia 6.2)
  3. Android SDK & Android Studio (Optional)
  4.  Java Development Kit (JDK)

In this tutorial, there is not even single line of coding so to implement same on your mobile it’s not necessary to have coding knowledge 🙂

 

Step by Step Implementation

1. Setup a Simple Unity Project:

  • Unity is a powerful and widely used game engine. Let’s start by creating a new Unity3D project by the name of “Tutorial1”. (Disable Unity Analytics for now)

Create New Project

 

2. Download the Vuforia Unity Extension (Vuforia SDK for Unity Platform)

 

  • Download The SDK and Sample “Core Features Download for Unity” from Sample (for Unity) Projects. And Store both on your desktop/Laptop. (Here I’m stored in Vuforia_SDK folder)

  • Extract The “vuforia-samples-core-unity-6-2-10.ZIP” to obtain two different UnityPackages: 
    1. ImageTargets-6-2-10.unitypackage (Useful in this Tut)  &
    2. VuforiaSamples-6-2-10.unitypackage
  • Here 6.2.10 indicate version and it may change according to update posted by Vuforia.

 

3. Import the Vuforia SDK Unity packages & sample project inside Unity Project:

  • Import the Vuforia Unity Extension/Vuforia SDK (vuforia-unity-6-2-10.unitypackage) & Sample Project (ImageTargets-6-2-10.unitypackage) which we just downloaded from Vuforia’s developer portal.
  • This can be done by importing custom UnityPackage, here I stored both inside Vuforia_SDK folder in my machine.
  • To import a new custom package:
    1. Choose Assets > Import Package > Custom Package… to bring up File Explorer (Windows) or Finder (Mac).
    2. Select the package you want from Explorer or Finder, and the Import Unity Package dialog box displays, with all the items in the package pre-checked, ready to install. (See Fig 4: New install Import Unity Package dialog box.)
    3. Select Import and Unity puts the contents of the package into the Assets folder, which you can access from your Project View.

  • If any “API Update” related dialog box appears, just click on “I Made a Backup” and go ahead.

Once imported, our Assets folder will look like this, inside Unity:

 

4. Open Unity-Scene “ImageTargets” from Vuforia inside Unity Project:

  • Open Scene ImageTarget inside Project window
  • Project >> Scene >> Vuforia-3-ImageTargets.unity
  • Then you are now able to see some game objects “ARCamera“, “ImageTargetChips“, “ImageTargetStone” etc. inside Hierarchy window

 

5.Create a Vuforia’s license key for our application:

Vuforia apps utilize a license key that uniquely identifies the app and enables it to access to the Vuforia Platform. License keys are created in the License Manager.

  • Go to Vuforia Developer Portal: 
  • Add a license key, if you are creating a new project or you can use an existing one. Fill in the details and give a name to it. It does not need to be same as of your Unity’s project.
  • Go to Develop >> License Manager >> Add License Key
  • Inside License Manager: Select Option Development >> Add Project Details 
  • Select “Next” and then “Confirm”. Your new license will appear in the License Manager.

 

 

Once we select “AR_Demo”(Our Project name in License Manager), we will get the license key.Copy the License Key and paste it somewhere, this key will be used later in Unity.

 

 

6. Add License Key to our Unity-Project:

Our license key should be added to the App License Key field on the VuforiaConfiguration asset accessible from the ARCamera’s Inspector panel via the Open Vuforia Configuration button. 

 

7. Android Deployment Setup to Run App on Device:

We are almost done. Let’s save the scene: File >> Save Scene and move towards deployment step.

The last step is to build the project for Android. We need to go to “File >> Build Settings”. We need to add the current scene by selecting “Add Open Scene”. Then, we need to select a platform (Android) and then select “Switch Platform“. Here, we will have multiple options:

  • Export Project: This will allow us to export the current Unity project to Android Studio so it can be edited and used to add more elements.
  • Development Build: Enabling this will enable Profiler functionality and also make the Autoconnect Profiler and Script Debugging options available.

Unity provides a number of settings when building for Android devices – select from the menu (File > Build Settings… > Player Settings…) to see/modify the current settings.

 

Before pressing the Build And Run, we need to make some more changes in the “Player Settings” options in the Inspector panel.

  • The Company Name needs to be changed; e.g. to “ARReverie”.
  • Need to change the “Package Name” under “Identification” say, to “com.arreverie.tutorial”.

Now, we can proceed to “Build and Run”. Other changes like Minimum API Level etc. can be made as per additional requirements. We will need to connect an Android mobile device via USB and enable USB debugging.

NOTE: We will also need to have an Android developer environment set up before we can test our Unity games on the device. This involves downloading and installing the Android SDK with the different Android platforms and adding our physical device to our system (this is done a bit differently depending on whether we are developing on Windows or Mac).

If you get stuck at any point or want to view the source code, you can find it on Github. You will just have to enter your Vuforia App License Key to build the app.


4+

Sanket Prabhu

About Sanket Prabhu

Sanket Prabhu is Technology Evangelist in XR (MR/AR/VR), Unity3D technology, a software engineer specializing in Unity 3D, Extended Reality (MR/AR/VR) application and game development. Currently working as a technology evangelist at Mobiliya, India. On the side, He runs a website (arreverie.com) which is the online blog and technical consultancy. The main goal of ARReverie is to develop complete open source AR SDK and currently working on ARToolKit-6.

Leave a comment

Your email address will not be published. Required fields are marked *