Augmented Reality: more Vuforia

This is the second article about creating Augmented Reality app. See the first one to find a comprehensive description of the necessary development environment. Additionally, you can find there an explanation of how Vuforia API works.

This article describes how to add more Image Targets to a database, what kinds of targets are Image Targets, how a user can have an influence on recognizing targets and more.

More Image Targets

You can add other Image Targets to a database. Go to the first article, there is a description of how to add a target to a database. Vuforia API contains the following types of Image Target: Image Target, Multi Target and Cylinder Target.

Multi Target is a combination of several images, which are arranged in one geometric figure. Vuforia API treats it as one target.

Cylinder Target is an image put in some cylinder shape like a tin, a bottle etc.

User interaction with Vuforia

User can decide whether Vuforia API recognizes a target thanks to interaction with an app. A code which shows sample interaction is on my Github. For example, a user can activate two targets by clicking on buttons. In case of my app, Vuforia API tracks two targets simultaneously. You can change it in VuforiaConfiguration -> Max Simultaneous Tracked Images.

The interaction code handles on click event and sets the target’s game object as active. See TargetActivateController.OnTargetButtonClick. The code creates buttons dependent on a count of targets. See TargetActivateController.CreateTargetButtons.

Read virtual objects from json

You can display a virtual image in the same way as text. Just create RawImage prefab in Unity Editor, load it on the code and deal with images in the event handler of displaying augmentations. The difference between text and image is only in particular data. The image needs a texture. See ExtendedTrackableBehaviour.AddVirtualImage.

Previously I hardcoded data of virtual text. However, it is not a good approach to implementing a real-life app. Data should be stored somewhere.

The app loads virtual objects from the json file. One json file stores data for one target. Unity Engine has a utility to serialize and deserialize json. It is called JsonUtility. See how simple using of it is in a code below.


To sum up, let’s have a look at Vuforia features described in this article:

  • types of Image Targets: Image Target, Cylinder Target, Multi-Target. Each of them has its own usage,
  • simultaneous tracking of Image Targets. A number of them can be changed in Vuforia Configuration,
  • getting the configuration in code from VuforiaConfiguration.Instance object,
  • integration with Unity Engine: dealing with virtual objects if the target’s Game Object is active, virtual objects are part of the Unity UI system.
0 0 vote
Article Rating
Share on
Notify of
Inline Feedbacks
View all comments