Wikitude SDK API Reference

API Docs for: 8.5.0
Show:

ObjectTracker Class

Extends ARchitectObject
Module: AR

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

The Tracker object is used to reference specific AR.ObjectTrackables (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.

ObjectTracker example:
var World = {
    [...]

    init: function initFn() {
        World.createTracker();
    },

    createTracker: function createTrackerFn() {
        this.targetCollectionResource = new AR.TargetCollectionResource("assets/firetruck_map.wto", {
        });

        this.tracker = new AR.ObjectTracker(this.targetCollectionResource, {
            onError: function(errorMessage) {
                alert(errorMessage);
            }
        });

        this.objectTrackable = new AR.ObjectTrackable(this.tracker, "*", {
            drawables: {
                cam: [...]
            },
            onObjectRecognized: this.objectRecognized,
            onObjectLost: this.objectLost,
            onError: function(errorMessage) {
                alert(errorMessage);
            }
        });
    },

    objectRecognized: function objectRecognizedFn() {
        [...]
    },

    objectLost: function objectLostFn() {
        [...]
    }
}

World.init();

Constructor

ObjectTracker

(
  • Tracker
  • options
)

Parameters:

  • Tracker TargetCollectionResource

    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
    • trackerEfficiencyMode (defaults to AR.CONST.TRACKER_EFFICIENCY_MODE.HIGH_ACCURACY) 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 (defaults to undefined) Function optional
    • onError (defaults to undefined) Function optional
    • onDisabled (defaults to undefined) Function optional

Item Index

Methods

Properties

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.

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