"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Cloud Reco - Using Target Metadata

 

This article highlights the meaning and usage best practices for Cloud Targets Metadata.

In Vuforia, every Cloud Image Target has an associated Metadata; a target metadata is nothing else than a custom (user-defined) string, i.e. a blob of text that you can fill with any text you like.

Therefore, you can use the metadata just as a way to contain some information about the target, that your application will be able to process using some custom logic.

Just as an example, your application might use the metadata string to represent some of the following:

  • some simple text message (like “Hello, I am your image target XYZ”) that you want to display on the screen of your device when the target is detected
  • a URL pointing to a 3D model stored on a server (for instance something like “http://my_server/my_models/my_model_01.obj”), so that for each different image target, your application may use that URL to connect to a specific server and retrieve (and render) a specific 3D model as the augmentation for that image target;
  • the filename of a 3D model stored on your device local storage or SD card (essentially the same scenario as the previous point, but using local storage instead of a remote server);
  • the URL of a specific video that you want your application to play when the image target is recognized;
  • the URL of some other type of data/content stored in a server database
  • more in general, some special string that your application is able to process and use to perform specific actions

 

How do I create a metadata and how do I associate it to a Cloud target ?

Metadata can be uploaded together with an image target at the time you create the target itself in your Cloud Database; or you can also update the metadata of an existing target, at a later time; in both case, you can use the online TargetManager, as explained here:

https://developer.vuforia.com/resources/dev-guide/managing-targets-cloud-database-using-target-manager

Or you can proceed programmatically though the VWS API, as explained here:

https://developer.vuforia.com/resources/dev-guide/managing-targets-cloud-database-using-developer-api

 

The relevant API to retrieve the metadata of a target in your mobile application (when the target is detected) is:

  • Native SDK:          TargetSearchResult::getMetadata()
  • Unity Extension:   TargetSearchResult.Metadata()

Sample code:

For a reference sample code in native, see the CloudRecognition.cpp file in the CloudRecognition sample project.

For a reference sample code in Unity, see the CloudRecoEventHandler.cs script (attached to the CloudRecognition prefab) in the CloudRecognition sample; in particular, the OnNewSearchResult method shows how to get a targetSearchResult object (from which you can then get the metadata, as shown in the example code).