Using the Device Tracker in Native

Vuforia Engine supports positional device tracking which allows for six-degrees-of-freedom tracking. By initializing and enabling the Device Tracker in your project, your device will be able to track in relation to the environment supporting extended experiences.

This article describes the Device Tracker APIs and general practice for using Device Tracker in native. For more information on Unity, refer to the Device Tracking in Unity article. 

The Device Tracker establishes the tracking of the device with respect to the environment. While other trackers track images or objects, this tracker uses visual details of the environment in the camera view as well as, in some cases, the built-in inertial measurement unit (IMU) sensor to determine the six-degree-of-freedom pose of the device itself. Depending on the available platform technology (such as ARKit and ARCore) at run-time the Vuforia Fusion mechanism will use different underlaying technology to drive the Positional Device Tracker.

Enabling the Device Tracker is required for the Ground Plane, Model Targets, Area Targets, and Extended Tracking features to work but it will also support Extended Tracking all other Vuforia Target types. The Device Tracker is enabled by the PositionalDeviceTracker class.

Device Tracking API

The DeviceTracker class tracks the pose of a device within a world coordinate system using data from the device's inertial sensors, camera, or platform enablers like ARKit/ARCore and VISLAM. 

The PositionalDeviceTracker, DeviceTrackable, and DeviceTrackableResult types

Init DeviceTracker

Vuforia::Tracker* deviceTracker = 
trackerManager.initTracker(Vuforia::PositionalDeviceTracker::getClassType());

Start DeviceTracker

deviceTracker.start();

Stop DeviceTracker

deviceTracker.stop(;

For more information on DeviceTrackableResult and what statuses it reports, please refer to Interpreting Tracking State API Results. Additionally, read about Vuforia AR Continued Experiences for more information on using the DeviceTracker to recover from interrupted AR sessions.

Positional Device Tracker

The PositionalDeviceTracker provide pose updates as a DeviceTrackableResult for a single DeviceTrackable instance. These Trackable Results are obtainable from the State object either by calling updateState() from the StateUpdater class instance on the TrackerManager, or from the State object returned by Renderer.begin().

Obtaining State from the StateUpdater:

const Vuforia::State state = Vuforia::TrackerManager::getInstance().getStateUpdater().updateState();

 

Usage

The snippet below shows how to enable the Positional Device Tracker for AR applications in native code.  

Vuforia::TrackerManager& trackerManager = Vuforia::TrackerManager::getInstance();
    Vuforia::Tracker* deviceTracker = trackerManager.getTracker(Vuforia::PositionalDeviceTracker::getClassType());
    if(deviceTracker != 0)
    {
        deviceTracker->start();
    }