Augmented Reality is everywhere, but what is it exactly?

Nowadays popularity of augmented reality is still increasing. We can find a lot of games using AR in mobile markets like Google Play. We constantly hear that the augmented reality is a future technology but what is AR exactly? Word augmented comes from augment, which means to add something. In instance of augmented reality, graphics, sounds or even scent are added into real world. It seems that AR is recent technology however prototype of AR device was invented in 1968 (https://www.youtube.com/watch?v=NtwZXGprxag). What is curious is that an augmented reality is used not only in entertainment industry. AR is also used in medical, aircraft, automotive, learning and marketing industries. The easiest way to start developing AR applications is to use one of following SDKs:

  • ARToolKit
  • Augmented
  • Layar SDK
  • Vuforia.

The best option to choose to work with Unity is obviously Vuforia.

Vuforia SDK

Vuforia SDK is available for platforms: Android, iOS, UWP and Unity. Vuforia offers to developers features:

  • Recognition of objects, images, user-defined images, cylinders, text, boxes and VuMarks
  • Smart Terrain™
  • Extended Tracking
  • Background Effects
  • Video Playback
  • Virtual Buttons
  • Occlusion Management

Unity integration

Since 2017.2 version of Unity you can install Vuforia Augmented Reality Support directly from Unity Installator.

Instalation of Vuforia

If you still using an older version of Unity you have to download Vuforia SDK package from developer portal (https://developer.vuforia.com/downloads/sdk) and later import it to Unity.

At first you need to register an account. Go to: https://developer.vuforia.com/vui/user/register and enter required informations. Next step is to create a license key for your application. On Vuforia Developer Portal select section Develop and License Manager then click Get Development Key button. Now enter App Name and confirm that you agree to the terms and conditions of The Vuforia Developer Agreement. Basic license is free however it provides some limits:

  • 1,000 cloud recognitions per month
  • 1,000 cloud targets cap
  • 1 active VuMark template
  • 100 VuMarks.

Alright, we have created an account and license key so we can start set Vuforia up with Unity now. At first create a new project in Unity. In this tutorial we use Unity 2017.2 with built-in Vuforia support. To import Vuforia select Edit/Project Settings/Player then go to section XR Settings and check Vuforia Augmented Reality Supported.

After you selected that option Unity should import VuforiaConfiguration file. Select this file and paste proviously generated App License Key. On that configuration file we can change several options like:

  • Camera Device Mode
  • Max Simultaneous Tracked Images
  • Enable/Disable datasets
  • Enable/Disable Smart Terrain Tracker.

Finally, we should remove Main Camera from scene and replace it with AR Camera. Click right mouse button at Hierarchy Window and choose Vuforia/AR Camera and then Import. Unity should import required files. Congratulations! You have integrated Vuforia SDK with Unity.

Image targets tracking

Okay, we have integrated SDK but besides camera view nothing special happens. So I'll show you how to use Vuforia's image tracking behaviour. At first we need to create targets database. Go back to Developer Portal and select Target Manager section for this purpose. We need a database, so click Add Database, enter the name and select Device type. Click Create.

In Vuforia we have several types of targets:

  • Single Image
  • Cuboid
  • Cylinder
  • 3D Object.

We will use Single Image in our project. Open created database, click Add Target. Next select image from your computer, enter width of target and it name. Click Add.

The best image target for tracking should have:

  • good contrast
  • rich details
  • no repetitive patterns.

I've uploaded one of Vuforia's sample image - https://howtofoldandotherstuff.files.wordpress.com/2012/11/chips.jpg. Which is great example of image target. We have simple database with one target, so click Download Database (All) and select Unity Editor platform. Import downloaded package to the Unity. After import you should notice new dataset in VuforiaConfiguration file. Select recently uploaded dataset and check Activate option.

The last step is to add ImageTarget prefab to scene. Click right mouse button on Hierarchy Window and select Vuforia/Image. In Image Target Behaviour component choose upload previously database and image.

To see tracking behaviour in action we should add any 3D model to ImageTarget gameobject. I've added simple cube with Rotate script:

public class Rotate : MonoBehaviour {  
    private float speed = 20f;

    private void Update() {
        transform.Rotate(Vector3.one * speed * Time.deltaTime);
    }
}

Now you can test your first AR application in Unity Editor or build Android application for more convenient testing. Focus camera on printed image target and boom! Vuforia shows rotating cube when you place target on camera view.

Conclusion

Augmented Reality technology gives us advantage to develop creative games and apps. However AR is applicable not only in entertainment industry, bu also sectors that relating to architecture and design, medicine or even aircraft.

Developing of basic AR application is quite easy as I've tried to show you. You can use Unity, Vuforia SDK and your imagination to create augmented worlds even if you aren't programmer.

I hope it’s useful for you. If you have any comments or questions, please write them here!

Best regards,
University of Games Team



Show Comments