Wikitude SDK API Reference

API Docs for: 9.10.0
Show:

CloudRecognitionService Class

Extends ARchitectObject
Module: AR

A CloudRecognitionService represents a Target Collection which is created with the Wikitude Studio Manager and is hosted by the Wikitude Cloud Service.
It needs to include the binary .wtc targets describing the targets and needs to be referenced via a clientToken and a targetCollectionId.

Example:
// create the cloud recognition service and pass setup parameters
World.cloudRecognitionService = new AR.CloudRecognitionService("b277eeadc6183ab57a83b07682b3ceba", "54e4b9fe6134bb74351b2aa3", {
    onInitialized: function() { alert("initialized"); },
    onError: function() { alert("error"); }
});

Constructor

CloudRecognitionService

(
  • clientToken
  • groupId
  • targetCollectionId
  • options
)

Parameters:

  • clientToken String

    Your unique client token to authorize against the Wikitude cloud recognition service.

  • groupId String

    The groupId that is associated with your Wikitude cloud recognition account.

  • targetCollectionId String

    The identifier for the target collection that should be loaded on the Wikitude cloud recognition server.

  • options Object optional

    Setup-Parameters to customize additional object properties.

    Accepted options-properties are:

Methods

destroy

()

Inherited from ARchitectObject

Destroys the object.

recognize

(
  • onRecognized
  • onError
)

Starts a single recognition process.
When this function is called, the current camera frame will be send to our servers and processed. Once the Server finishes his work, the onRecognizedCallback will be called.

Parameters:

  • onRecognized Function

    A callback function that is called when the SDK received the server response.
    This callback has two parameters.

    • recognized True if a reference image could be found in the current camera image, false otherwise
    • recognitionData A JSON object containing a targetInfo object and an optional metadata object.
      • targetInfo A JSON object containing the targetName, it's star rating and optional it's physical height in mm
      • metadata The custom metadata JSON object that was assigned to a target image during creation.
  • onError Function optional

    A callback function that is called when the SDK was unable to contact the cloud recognition server or the server encountered any error during recognition.
    This callback has two parameters:

    • code A number representing the kind of error that occured.
    • errorObject A JSON object containing more information about what failed.

startContinuousRecognition

(
  • interval
  • onInterruptionCallback
  • onRecognizedCallback
  • onErrorCallback
)

Starts a continuous recognition session.
A active continous recognition session will upload a new camera frame to the server in the specified interval.

Parameters:

  • interval Number

    The interval in which a new recognition should be started. The minimum value is 500 ms.

  • onInterruptionCallback Function optional

    A callback function that is called when the interval is set to a number that can not be fullfilled by the current network conditions.
    This callback has one parameter: suggestedInterval A number representing a interval that could be used with the current network conditions.

  • onRecognizedCallback Function

    A callback function that is called when the SDK received a server response. See CloudTracker/recognize:method for more information.

  • onErrorCallback Function optional

    A callback function that is called when the SDK was unable to contact the cloud recognition server or the server encountered any error during recognition.
    This callback has two parameters:

    • code A number representing the kind of error that occured.
    • errorObject A JSON object containing more information about what failed.

stopContinuousRecognition

()

Stops an active continuous recognition session.

Properties

clientToken

String

The clientToken identifying the user account where the target collection belongs to. The property is read-only and can only be set on creation.

destroyed

Boolean

Inherited from ARchitectObject

Indicates if the object has already been destroyed.

groupId

String

The groupId identifying the user account where the target collection belongs to. The property is read-only and can only be set on creation.

         In case the cloud recognition service was created with an API that did not specify a group id explicitly, groupId is an empty string

targetCollectionId

String

The target collection id identifying a specific image target collection. The property is read-only and can only be set on creation.

Events

onError

The trigger fires when the connection to the Wikitude Cloud Service servers could not be established. Causes for this might include bad network connection.

The trigger is null by default, and will thus result in no action executed when the trigger fires. A developer can add custom functionality by assigning a custom function to onError.

onInitialized

The trigger fires when the connection to the Wikitude Cloud Service servers is established.

The trigger is null by default, and will thus result in no action executed when the trigger fires. A developer can add custom functionality by assigning a custom function to onLoaded.