This page concerns the Vuforia Engine API version 9.8 and earlier. It has been deprecated and will no longer be actively updated.
This article provides examples on the general app structure for the Area Target API with code examples on commonly performed tasks. The examples include setting up the project environment and app initialization so that the AreaTargets feature can be used.
Area Targets are tracked using the AreaTracker which works in a similar fashion as the ObjectTracker. The difference for AreaTracker being that it uses the Device Tracker as an obligatory requirement and fusion provider must be FUSION_PROVIDER_PLATFORM_SENSOR_FUSION.
In an AR session, you are allowed to load up to 255 AreaTargets which can be achieved by loading them just once, and thereafter activate/deactivate the AreaTargets as needed. By having multiple AreaTarget in extension of each other facilitates tracking and augmentations of very large areas.
For more information on the AreaTracker and AreaTarget, please see Area Targets API Overview.
Adding a License Key
If you want to use Vuforia Area Targets in your application you will need to first create one using the Area Target Generator, as well as an applicable license key for development or deployment. See How to Add a License Key to Your Vuforia App for more information.
General App initialization
Set up the native environment with the Vuforia Engine SDK. If in doubt, follow the guide for setting up the environment for Android or iOS that can be found in the Vuforia Library.
Download the Vuforia Engine Native SDK for your platform here: https://developer.vuforia.com/downloads/SDK.
Start by initiating and starting the PositionalDeviceTracker as AreaTracker won’t start if PositionalDeviceTracker is not initialized and no AreaTargetResults will be published unless it is started.
Initialize the PositionalDeviceTracker
TrackerManager& trackerManager = TrackerManager::getInstance();
PositionalDeviceTracker* deviceTracker = static_cast<Vuforia::PositionalDeviceTracker*>(trackerManager.initTracker(
Vuforia::PositionalDeviceTracker::getClassType()));
Initialize the AreaTracker
TrackerManager& trackerManager = TrackerManager::getInstance();
AreaTracker* areaTracker = static_cast<Vuforia::AreaTracker*>(trackerManager.initTracker(
Vuforia::AreaTracker::getClassType()));
Load AreaTarget DataSet
const char* areaTargetDatasetPath = "yourAreaTargetDatasetName.xml";
DataSet* areaTargetDataset = areaTracker->createDataSet();
if (DataSet::exists(areaTargetDatasetPath, Vuforia::STORAGE_APPRESOURCE))
{
areaTargetDataset->load(areaTargetDatasetPath, Vuforia::STORAGE_APPRESOURCE);
}
Start the trackers
deviceTracker->start();
areaTracker->start();
Activate AreaTarget DataSet
Activation of the AreaTargets is quick and so, it is not required to stop the AreaTracker when activating/deactivating AreaTargets. This performance also allows you to activate an AreaTarget alongside another AreaTarget that is being tracked at runtime.
areaTracker->activateDataSet(areaTargetDataset);
Retrieving AreaTargetResult from the state
const auto& trackableResultList = state.getTrackableResults();
for (const auto& trackableResult : trackableResultList)
{
if (trackableResult->isOfType(Vuforia::AreaTargetResult::getClassType()))
{
Vuforia::Matrix34F pose = trackableResult->getPose();
}
}
Deactivate AreaTarget DataSet
areaTracker->deactivateDataSet(areaTargetDataset);
Stop the AreaTracker
areaTracker->stop();
Destroy AreaTarget DataSet after deactivating it
areaTracker->destroyDataSet(areaTargetDataset);
Destroy the AreaTracker
TrackerManager& trackerManager = TrackerManager::getInstance();
trackerManager.deinitTracker(Vuforia::AreaTracker::getClassType());
Adding Content to your Scanned Space
We highly recommend that authoring of the virtual content in the scanned space should be done in the Unity Editor. You may thereafter build directly to the supported platforms in Unity. If you so choose not to use Unity, we advise that you locate a third-party point-cloud editor or other 3D-editor tool that can be used for authoring and capable of exporting the necessary spatial coordinates to your native development environment. See Using Area Targets in Unity for more information on authoring and building AR experiences.