Wikitude SDK API Reference

API Docs for: 8.2.0
Show:

ImageTracker Class

Extends ARchitectObject
Module: AR

The ImageTracker is responsible for finding the position of the target images defined in the target collection (which is either represented by a AR.TargetCollectionResource or a AR.CloudRecognitionService) in the camera image stream. This information is then used in combination with the AR.ImageTrackables to draw the correct augmentations(AR.Drawables) at the correct position.

The Tracker object is used to reference specific AR.ImageTrackables (the targets inside the target collection).

Trackers can be enabled and disabled. Only one Tracker can be active at a time. The current enabled/disabled state of a Tracker is reflected in the enabled property. Should there be multiple Trackers used in the ARchitect file, the following logic applies to specify the currently active Tracker:

  • When a new Tracker is created, it is automatically set to the active one, unless it was created with enabled set to false.
  • When a specific Tracker is enabled, it is automatically set to the active one. The previously active Tracker is disabled by the system.
In case a Tracker is disabled by the system, the developer will be notified via the onDisabled trigger.

Client recognition example:
// a Tracker referencing a target collection on a server
var targetCollection1 = new AR.TargetCollectionResource("http://myserver.com/targetCollection1.wtc");
var tracker1 = new AR.ImageTracker(resource1 , {
  onDisabled : function(){
    //tracker has been disabled by the system
  }
});
var enabled = tracker1.enabled; //true

// a second tracker, which will cause tracker1 to be disabled
var targetCollection2 = new AR.TargetCollectionResource("http://myserver.com/targetCollection2.wtc");
var tracker2 = new AR.ImageTracker(resource2);

enabled = tracker1.enabled; //false
enabled = tracker2.enabled; //true

Cloud recognition example:

// a ImageTracker referencing a target collection with a specific client token token
var cloudRecognitionService = new AR.CloudRecognitionService("__your_client_token__", "__target_collection_id__", {
        onLoaded: function onLoadedFn() {
            // enable UI elements to start recognition calls
        }
});
var tracker = new AR.ImageTracker(cloudRecognitionService);

// ... additional code...

// to start a single recognition process, call the cloud recognition service's recognize function.
cloudRecognitionService.recognize(function(recognized, responseData) {
        if ( recognized )
        {
            // A target image was found in the processed camera frame.
            // The name of the recognized target can be retrieved from the responseData object.
            alert('recognized target image: ' + responseData.targetInfo.name);
        }
        else
        {
            // No target image could be found in the processed camera frame.
        }
});

Constructor

ImageTracker

(
  • Tracker
  • options
)

Parameters:

  • Tracker TargetCollectionResource | CloudRecognitionService

    source holding the Target Collection which is created with the Wikitude Studio Manager.

  • options Object optional

    Setup-Parameters to customize additional object properties.

    Accepted options-properties are

    • enabled (defaults to true) Boolean optional
    • physicalTargetImageHeights Object optional
    • extendedRangeRecognition Number optional
    • maximumNumberOfConcurrentlyTrackableTargets Number optional

      The maximum number of targets that can be tracked concurrently. This is 1 by default and may only be set to more than 1.

    • trackerEfficiencyMode Number optional

      The efficiency mode in which the image tracker should run. Please refer to the AR.CONST.TRACKER_EFFICIENCY_MODE documentation for more information.

    • onTargetsLoaded Function optional
    • onError Function optional
    • onDisabled Function optional
    • onDistanceChangedThreshold Number optional

      The threshold that has to be exceeded for AR.ImageTarget.onDistanceChanged to be triggered.

    • onTranslationChangedThreshold Number optional

      The threshold that has to be exceeded for AR.ImageTarget.onTranslationChanged to be triggered.

    • onRotationChangedThreshold Number optional

      The threshold that has to be exceeded for AR.ImageTarget.onRotationChanged to be triggered.

Methods

destroy

()

Inherited from ARchitectObject

Destroys the object.

Properties

destroyed

Boolean

Inherited from ARchitectObject

Indicates if the object has already been destroyed.

enabled

Boolean

The current activity state of the Tracker. This property might by changed automatically by the system, in case another Tracker is enabled, causing this Tracker to be disabled. The onDisabled trigger will be called in this case.

onDistanceChangedThreshold

Number

The threshold that has to be exceeded for ImageTarget.onDistanceChanged to be triggered.

The default threshold is 0 which means that every change will trigger ImageTarget.onDistanceChanged.

onRotationChangedThreshold

Number

The threshold that has to be exceeded for ImageTarget.onRotationChanged to be triggered.

The default threshold is 0 which means that every change will trigger ImageTarget.onRotationChanged.

onTranslationChangedThreshold

Number

The threshold that has to be exceeded for ImageTarget.onTranslationChanged to be triggered.

The default threshold is 0 which means that every change will trigger ImageTarget.onTranslationChanged.

physicalTargetImageHeights

Object

Use this option to specify the physical height of a image target that is included in the .wtc file. These options are only necessary if the distanceToUser functionality is used and the .wtc file version is below 4.1. The physical height is expressed in millimeter, and this object contains a map using target names as keys.

Events

onDisabled

The trigger fires when the Tracker has been disabled by the system. It does not fire when enabled is set to false manually.

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 onDisabled.

onError

The trigger fires when the Tracker could not be loaded by the engine.

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.

onTargetsLoaded

The trigger fires when the Tracker's target collection was successfully loaded and the Tracker was loaded by the engine. ImageTrackables related to this Tracker can only be tracked after the Tracker was successfully loaded.

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 onTargetsLoaded.