Cloud Recognition Sample

This example shows how to recognize images on a cloud server and then overlay it with augmentations utilizing the ImageTracker and CloudRecognitionService classes.

For a better understanding, here are some terms that will be used in the following and other sections of this documentation related to vision-based augmented reality.

  • Target: An image and its associated extracted data that is used to recognize an image.

  • Target Collection: A group of targets that are searched together. Think of it as a directory, which contains all your images you want to search. The Wikitude SDK can work with two different sorts of Target Collections

    • On-device Target Collection: a static wtc file containing the extracted data of your images. Can consist of up to 1,000 images.
    • Cloud Target Collection: A target collection stored on the Wikitude server. See Cloud Archive below. Can consist of up to 50,000 images.
  • Cloud Archive: An archive stored on the server that is optimized for cloud-based recognition. It is generated from a Target Collection and is used in combination with CloudRecognitionService .

  • CloudRecognitionService: Instead of analysing and computing the live camera feed directly on the device, the CloudRecognitionService will send the image(s) taken by the camera to the Wikitude Cloud Recognition server. The server will then do the hard work of trying to match the image with your targets in the specified cloud archive. Beside the benefit of searching in large image database, using the CloudRecognitionService has also a positive impact on the general performance in most cases. Especially when using a large target collection and on older devices.

Cloud recognition in Unity

CloudTracker Prefab

To add a tracker prefab to the scene, simply drag the CloudTracker prefab into the scene hierarchy. The CloudTracker prefab also has the ImageTracker script, but is preconfigured to use the CloudRecognitionService instead of a TargetCollectionResource.

A CloudRecognitionService needs to know which cloud archive should be loaded. This is done by entering a TargetCollectionId into the appropriate text field of the ImageTracker script component, in the CloudRecognitionService section. To identify the SDK user, the field called ClientToken needs to be entered as well. With those values in place, the CloudRecognitionService knows which image targets have to be searched for on the cloud recognition server.

To react on events like successfully loading a cloud archive, you can use the Unity Events listed in in the inspector of the ImageTracker. Please refer to the Image Recognition examples for more information on how to use UnityEvents. When the ImageTracker is using the CloudRecognitionService additional events that are specific to it are shown in the inspector.

To start a server recognition, call the Recognize or StartContinuousRecognition methods of the Wikitude.CloudRecognitionService script assigned to the ImageTracker. To evaluate the server response and evaluate which target was recognized and which meta information are associated with this particular image target, you can use the OnRecognitionResponse event on the ImageTracker component, in the Cloud Recognition Service Events section.

In case a continuous recognition was started, it needs to be stopped after either a image target was recognized or the application is about to quit. You can restart the continuous recognition after the target was lost to start tracking it again. Please see the Cloud Recognition - Continuous Mode sample for an example on how to do this.

Regional server endpoints

The cloud recognition server region can be selected by changing the Server Region option in the ImageTracker inspector, in the Cloud Recognition Service section.

Define custom augmentations

Augmentations are placed exactly like when using a normal ImageTracker, so please refer to the Image Recognition examples for more information.