Extended Tracking 扩展跟踪

来源:互联网 发布:电子杂志app制作软件 编辑:程序博客网 时间:2024/06/14 16:43

Extended Tracking utilizes features of the environment to improve tracking performance and sustain tracking even when the target is no longer in view.

Extended Tracking allows the tracking a degree of persistence once a target has been detected. As the target goes out of view, Vuforia uses other information from the environment to infer the target position by visually tracking the environment. Vuforia builds a map around the target specifically for this purpose and assumes that both the environment and target are largely static.

Extended Tracking can significantly enhance two kinds of user experience:

Game or game-like experiences with a large amount of dynamic content that requires the user to point the device away from the target as the user follows the content
Visualizations of large objects like furniture, appliances, large home furnishings and even architectural models at the right scale and perspective
Use this feature to facilitate creating more robust applications, because any augmentations attached to these Targets will persist. In practice this means that after you point your device away from the initial Target, any augmentations maintain their positions with respect to the real world and are consistent with the initial reference frame defined by the target. The more detailed and feature-­rich the environment, the better Extended Tracking works.

Let’s see how this works with regard to pictures and scenarios that use the new Vuforia Samples, which contain an Extended Tracking toggle in the options. The following example depicts the effects when running the Image Targets application with this toggle selected.

Figure A shows a device capturing a Stones Target in its field of view (FOV). The result is Figure B, which shows the Stones Target in view, along with augmentations.
扩展跟踪使用环境的功能来提高跟踪性能并维持跟踪,即使目标不再存在。

一旦检测到目标,扩展跟踪就可以跟踪一定程度的持久性。当目标出局时,Vuforia使用环境中的其他信息通过视觉跟踪环境来推断目标位置。 Vuforia为此目的专门为目标构建了一个地图,并假定环境和目标都是静态的。

扩展跟踪可以显着提升两种用户体验:

具有大量动态内容的游戏或类似游戏的体验,需要用户在用户遵循内容时将设备指向目标
诸如家具,电器,大型家居装饰品,甚至建筑模型的大型物品的视觉化,以正确的尺度和视角
使用此功能便于创建更强大的应用程序,因为附加到这些目标的任何扩充将会持续存在。在实践中,这意味着在您将设备指向初始目标之后,任何扩充将保持其与现实世界的位置,并与目标定义的初始参考帧一致。更详细和功能丰富的环境,更好的扩展跟踪工作。

让我们看看如何使用新的Vuforia样本的图片和场景,其中包含选项中的扩展跟踪切换。以下示例描述了在选择此切换的情况下运行“图像目标”应用程序时的效果。

图A显示了在其视场(FOV)中捕获Stones Target的设备。结果是图B,其中显示了Stones Target在视图中,以及增加。这里写图片描述
As Figure B shows, the augmentations of buildings on top of a wooden table are displayed on the screen of the device. This encourages the user to pan to these items by moving the angle of the camera to point upwards, thereby making the Stones Target disappear from view.

In previous versions of Vuforia, this led to all augmentations disappearing, because the Target reference frame is lost. With the Extended Tracking feature, the buildings remain visible even when the Stones Target is not in the camera view. Figures C and D illustrate this:
如图B所示,在木制桌子顶部的建筑物的增加显示在设备的屏幕上。 这鼓励用户通过将相机的角度移动向上指向这些物品,从而使石头目标从视野消失。

在以前版本的Vuforia中,这导致所有增加消失,因为目标参考帧丢失。 使用扩展跟踪功能,即使“石头目标”不在相机视图中,建筑仍然可见。 图C和D说明:
这里写图片描述

Note that after the Stones Target goes out of view it is not required for further display of the augmentations if this feature is enabled. That means that the augmentations persist without the target, and this capability supports more robust and continuous AR experiences.

Note that after the Stones Target goes out of view it is not required for further display of the augmentations if this feature is enabled, i.e., the augmentations persist without the target, and this capability supports more robust and continuous AR experiences.
请注意,如果启用了此功能,Stones Target将不再需要进一步显示扩充功能。 这意味着扩充持续没有目标,这种能力支持更强大和持续的AR体验。

请注意,如果启用了此功能,即在不使用目标的情况下,扩充持续存在,Stones Target将不再需要进一步显示扩充功能,并且此功能支持更强大和连续的AR体验。
Extended Tracking

What if the environment or target is not static?

By default, Extended Tracking assumes that the environment the camera sees is mostly static. The Extended Tracking map will continually expand, so new objects added to the scene will become part of the map. This does imply some extra background processing to managing and optimizing the map which could be perceived as slow-down in the app if there’s a lot of other processing going on. If a large part of the scene moves, it risks pulling the map with it and negatively impacting the offset accuracy between the target and the map. This offset may be recomputed when the target is tracked again. If only a small part of the scene moves, then it’s possible that a negative impact to the offset may be minor and go unnoticed thus introducing small error in accuracy of extended tracked pose estimates. In this way, larger scene changes can sometimes be less problematic than more subtle ones.

If scene changes or changes of the target location are expected, then the application should NOT use Persistent Extended Tracking (PET). Not using PET is the safer approach here, as the map will be reset whenever tracking stops for a few seconds. PET should only be used if:

the application does NOT need to afford scene or target location changes (and the 5 s auto reset is therefore only harmful to the experience)
the application lets the advanced user reset the map manually when a scene change has happened.
Persistent Extended Tracking

With persistent mode turned on, Vuforia never resets or rebuilds the map during extended tracking. Instead, there is a dedicated resetExtendedTracking API (see below) that puts this in the hands of the developer. The application can keep the map for much longer, providing a seamless experience if the device is put down or the camera is stopped temporarily. Furthermore, if an additional target is detected and tracked, this target is appended to all existing targets that are being tracked.

Trackables that support Extended Tracking

These targets support Extended Tracking:

Object Targets
Image Targets
Multi-Targets
Cylinders
User-Defined Targets
Cloud Recognition
VuMarks
Text and Frame Markers do not support Extended Tracking
扩展跟踪

如果环境或目标不是静态的,该怎么办?

默认情况下,扩展跟踪假定摄像机看到的环境大部分是静态的。扩展跟踪地图将不断扩展,因此添加到场景中的新对象将成为地图的一部分。这意味着管理和优化地图的一些额外的后台处理,如果还有很多其他处理,可能会被认为是应用程序中的减速。如果场景的大部分移动,则有可能会拉动地图并对目标和地图之间的偏移精度产生负面影响。当再次追踪目标时,可以重新计算该偏移量。如果只有一小部分场景移动,则可能对偏移量产生负面影响可能较小,并且不会被忽视,从而引入延迟跟踪姿态估计的精度的小错误。这样,更大的场景变化有时比较微妙的变化更小问题。

如果预期场景更改或目标位置的更改,则应用程序不应使用持久扩展跟踪(PET)。不使用PET是更安全的方法,因为当跟踪停止几秒钟时,地图将被重置。 PET只能在以下情况下使用:

应用程序不需要提供现场或目标位置的更改(因此5秒的自动复位仅对体验有害)
应用程序使高级用户在发生场景更改时手动重置地图。
持续扩展跟踪

在持续模式打开时,Vuforia在扩展跟踪期间不会重置或重建地图。相反,有一个专用的resetExtendedTracking API(见下文)将其置于开发者手中。应用程序可以使地图保持更长时间,如果设备放下或相机暂时停止,则可以提供无缝体验。此外,如果检测和跟踪附加目标,则将该目标附加到正在被跟踪的所有现有目标。

支持扩展跟踪的跟踪

这些目标支持扩展跟踪:

对象目标
图像目标
多靶点
气瓶
用户定义的目标
云识别
VuMarks
文本和帧标记不支持扩展跟踪
Behaviour of Extended Tracking with multiple simultaneous targets

Under certain conditions, Extended Tracking can work with multiple targets, but be aware that all targets need to be in the right scale with respect to each other.

When Vuforia is configured to track one target at a time:

A target may still be extended tracked when it is out of view. Only when that target has lost tracking can a new target be tracked.

When Vuforia is configured to track more than one target simultaneously:

Extended Tracking should work fine with multiple simultaneous targets. If the targets are in physically disjoint locations, only one of the targets will be extended tracked. When tracking multiple simultaneous targets, it is recommended to NOT use Persistent Extended Tracking so that the Extended Tracking map will be able to reset 5 seconds after tracking is lost and be ready to use extended tracking on the next tracked target.

How To Use The Extended Tracking API
The following is a description of the API with examples of how to implement Extended Tracking in native code and Unity.
具有多个同时目标的扩展跟踪的行为

在某些条件下,扩展跟踪可以与多个目标一起使用,但要注意所有目标都需要相对于彼此的正确比例。

当Vuforia配置为一次跟踪一个目标时:

目标在视野不足时仍可能被追踪。只有当目标失去跟踪时,才能跟踪新的目标。

当Vuforia配置为同时跟踪多个目标时:

扩展跟踪应该与多个同时的目标工作正常。如果目标在物理上不相交的位置,则只有一个目标将被扩展跟踪。当跟踪多个同步目标时,建议不要使用持久扩展跟踪,以便扩展跟踪映射将能够在跟踪丢失后5秒钟重置,并准备在下一个跟踪目标上使用扩展跟踪。

如何使用扩展跟踪API
以下是API的描述,其中介绍了如何在本地代码和Unity中实现扩展跟踪。
Native API

The following code shows the updated Trackable base class definition, along with the updated API for startExtendedTracking() and stopExtendedTracking(), which control this feature.
本机API

以下代码显示了更新的Trackable基类定义,以及用于startExtendedTracking()和stopExtendedTracking()的更新的API,该API控制了此功能。

class Vuforia_API Trackable : private NonCopyable{    //...    /// Starts extended tracking for this Trackable    /**     *  This function will return true if extended tracking was      *  successfully started for this Trackable (or already started)      *  and false otherwise.     */    virtual bool startExtendedTracking() = 0;    /// Stops extended tracking for the Trackable    /**     *  This function will return true if extended tracking was     *  successfully stopped for this Trackable (or already stopped)      *  and false otherwise.     */    virtual bool stopExtendedTracking() = 0;    virtual ~Trackable()  {}};

Remember that this applies only to the following Trackable types, all of which are subclasses of ObjectTarget:

CylinderTarget
ImageTarget
MultiTarget
VuMarkTarget
VuMarkTemplate
Text and Framemarkers do not support Extended Tracking.

The TrackableResult class was updated in Vuforia SDK 2.8 so that getStatus() returns an EXTENDED_TRACKED status if the Natural Feature Tracker is no longer generating poses for the Trackable. When the Natural Feature Tracker is generating poses for the Trackable, getStatus() will return a TRACKED status.

In addition, the Tracker class was updated to enable and disable Persistent Extended Tracking and to reset the Extended Tracking, as described earlier.
请记住,这仅适用于以下Trackable类型,它们都是ObjectTarget的子类:

CylinderTarget
ImageTarget
多目标
VuMarkTarget
VuMarkTemplate
文本和Framemarkers不支持扩展跟踪。
Remember that this applies only to the following Trackable types, all of which are subclasses of ObjectTarget:

CylinderTarget
ImageTarget
MultiTarget
VuMarkTarget
VuMarkTemplate
Text and Framemarkers do not support Extended Tracking.

The TrackableResult class was updated in Vuforia SDK 2.8 so that getStatus() returns an EXTENDED_TRACKED status if the Natural Feature Tracker is no longer generating poses for the Trackable. When the Natural Feature Tracker is generating poses for the Trackable, getStatus() will return a TRACKED status.

In addition, the Tracker class was updated to enable and disable Persistent Extended Tracking and to reset the Extended Tracking, as described earlier.
请记住,这仅适用于以下Trackable类型,它们都是ObjectTarget的子类:

CylinderTarget
ImageTarget
多目标
VuMarkTarget
VuMarkTemplate
文本和Framemarkers不支持扩展跟踪。

TrackableResult类在Vuforia SDK 2.8中进行了更新,因此如果自然特征跟踪器不再为“跟踪”生成姿势,getStatus()将返回EXTENDED_TRACKED状态。 当自然特征跟踪器为Trackable生成姿势时,getStatus()将返回TRACKED状态。

此外,如前所述,Tracker类更新为启用和禁用持久扩展跟踪并重新设置扩展跟踪。

class Vuforia_API Tracker : private NonCopyable{    //...    /// Enables/disables persistent extended tracking    /**     *  In persistent extended tracking mode, the environment map will only     *  ever be reset when the developer calls resetExtendedTracking().     *  This function will return true if persistent extended tracking     *  was set successfully (or was already set to the specified value)     *  and false otherwise.     */    virtual bool persistExtendedTracking(bool on) = 0;    /// Resets environment map for extended tracking    /**     *  Environment map can only be reset by the developer if persistent     *  extended tracking is enabled.     *  This function will return true if environment map was reset     *  successfully and false otherwise.     */    virtual bool resetExtendedTracking() = 0;};

The resetExtendedTracking() API works only if persistExtendedTracking() has already been called to turn it on.
resetExtendedTracking()API只有在已经调用persistExtendedTracking()才能打开它的情况下才有效。

Unity API

In Unity, implement this feature by ticking the Extended Tracking option in the Inspector, so that using an API is not mandatory. It can, however, be useful to understand how to control it using scripting for use in advanced scenarios.

First, all supported targets implement a new interface, ExtendedTrackable, which contains two methods that mirror the native counterparts.

unity API

在Unity中,通过勾选“检查器”中的“扩展跟踪”选项来实现此功能,以便使用API不是强制性的。 但是,了解如何使用高级场景中使用的脚本来控制它可能是有用的。

首先,所有支持的目标都实现了一个新的接口,扩展跟踪,其中包含两个镜像本地对象的方法。

public interface ExtendedTrackable : Trackable{    // Start extended tracking. The Target can be tracked although it is not visible.    bool StartExtendedTracking();    // Stop extended tracking. Target will only be tracked when it is visible.    bool StopExtendedTracking();}

The TrackableBehaviour.status () contains the values TRACKED and EXTENDED_TRACKED. When the Natural Feature Tracker is tracking the object, this value will be TRACKED, even if the Extended Tracking option is enabled for the Trackable. When the Natural Feature Tracker loses the Trackable and Extended Tracking takes over (if Extended Tracking is enabled for the Trackable), the status will change to EXTENDED_TRACKED. The OnTrackableStateChanged() method in the DefaultTrackableEventHandler.cs file illustrates this.

TrackableBehaviour.status()包含值TRACKED和EXTENDED_TRACKED。 当自然特征跟踪器跟踪对象时,即使对于跟踪对象启用了扩展跟踪选项,该值也将被跟踪。 当自然功能跟踪器丢失跟踪和扩展跟踪接管(如果为Trackable启用扩展跟踪),状态将更改为EXTENDED_TRACKED。 DefaultTrackableEventHandler.cs文件中的OnTrackableStateChanged()方法说明了这一点。

public void OnTrackableStateChanged(                                TrackableBehaviour.Status previousStatus,                                TrackableBehaviour.Status newStatus)    {    if (newStatus == TrackableBehaviour.Status.DETECTED ||        newStatus == TrackableBehaviour.Status.TRACKED ||        newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)    {        OnTrackingFound();    }    else    {        OnTrackingLost();    }

Finally, the ObjectTracker class was updated to enable and disable Persistent Extended Tracking, and also to reset the Extended Tracking to mirror the native counterpart.
最后,ObjectTracker类被更新以启用和禁用持久扩展跟踪,并且还重新设置扩展跟踪以镜像本机对等体。

ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();bool success = tracker.PersistExtendedTracking(!mPersistExtendedTracking);if (success){    Debug.Log("PersistentExtendedTrackingEnabled");}// To reset Extended Trackingtracker.ResetExtendedTracking();

How To Implement Extended Tracking
The following code groups show how to add extended tracking to the Chips Image Target within a standard Image Target application.

The code for Android and iOS shows a modified loadTracker() function (with the updated lines in bold) that goes through the dataset on startup and calls startExtendedTracking() when it finds the chips target. In this instance the function is implemented in the startup functionality for the sake of convenience, but this function can be called at any time.
Android implementation

The following C++ and JAVA code is used to initialize this feature on Android.

C++ Implementation:
如何实现扩展跟踪
以下代码组显示了如何在标准图像目标应用程序中向Chips Image Target添加扩展跟踪。

Android和iOS的代码显示了一个修改的loadTracker()函数(更新的粗体),在启动时通过数据集,并在找到芯片目标时调用startExtendedTracking()。 在这种情况下,为了方便起见,该功能在启动功能中实现,但可以随时调用此功能。
Android实现

以下C ++和JAVA代码用于在Android上初始化此功能。

C ++实现:

// Find “chips” target in datasetfor (int i = 0; i < myDateSet ->getNumTrackables(); i++){    Vuforia::Trackable* trackable = aDataSet.dataSet->getTrackable(i);    if (strcmp(trackable->getName(), "chips") == 0)    {        // Start extended tracking on “chips” target        if (!trackable->startExtendedTracking())        {            LOGD ("Failed to start extended tracking on chips target");        }    }

Java Implementation: Java实现:

// Find “chips” target in datasetfor (int i = 0; i < myDateSet.getNumTrackables(); i++){    Trackable trackable = myDataSet.getTrackable(i);    if (trackable.getName().equals( "chips" ))    {        // Start extended tracking on “chips” target        if (!trackable.startExtendedTracking())        {            DebugLog.LOGD ("Failed to start extended tracking on chips target");        }    }

iOS implementation;

You can find this original code in the sampleutils.mm file in the Image Targets sample. This code snippet shows the context in which Extended Tracking is enabled.
iOS实现;

您可以在ImageTargets示例中的sampleutils.mm文件中找到原始代码。 此代码段显示启用扩展跟踪的上下文。

// Load the tracker data [performed on a background thread]- (void)loadTracker{    // Background thread must have its own autorelease pool    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];    BOOL haveLoadedOneDataSet = NO;    if (targetType != TYPE_FRAMEMARKERS)    {        // Load all the requested datasets        for (DataSetItem *aDataSet in targetsList)        {            if (aDataSet.path != nil)            {                aDataSet.dataSet = [self loadDataSet:aDataSet.path];                if (haveLoadedOneDataSet == NO)                {                    if (aDataSet.dataSet != nil)                    {                        // activate the first one in the list                        [self activateDataSet:aDataSet.dataSet];                        haveLoadedOneDataSet = YES;                    // Set extended tracking mode                    //  start extended tracking mode code                        // Find “chips” target in dataset                        for (int i = 0; i < aDataSet.dataSet->getNumTrackables(); i++)                        {                            Vuforia::Trackable* trackable = aDataSet.dataSet->getTrackable(i);                            if (strcmp(trackable->getName(), "chips") == 0)                            {                                // Start extended tracking on “chips” target                                if (!trackable->startExtendedTracking())                                {                                    NSLog(@"Failed to start extended tracking on chips target");                                }                            }                        }                    //  end of extended tracking mode code                    }                }            }        }        // Check that we've loaded at least one target        if (!haveLoadedOneDataSet)        {            NSLog(@"sampleutils: Failed to load any target");            appStatus = APPSTATUS_ERROR;            errorCode = QCAR_ERRCODE_LOAD_TARGET;        }    }    // Continue execution on the main thread    if (appStatus != APPSTATUS_ERROR)        [self performSelectorOnMainThread:@selector(bumpAppStatus) withObject:nil waitUntilDone:NO];    [pool release];

Unity implementation

To enable Extended Tracking for an Image Target, you must check the corresponding checkbox in the Inspector when it is highlighted. As the following figure shows, you can find Extended Tracking under the target behaviour component in the target’s inspector:

团结执行

要启用图像目标的扩展跟踪,当突出显示时,必须检查检查器中的相应复选框。 如下图所示,您可以在目标检查器中的目标行为组件下找到扩展跟踪:
这里写图片描述
If the application must dynamically enable or disable the extended tracking at run time, you can use the Extended Tracking API’s startExtendedTracking and stopExtendedTracking methods as illustrated in the following code example:
如果应用程序必须在运行时动态启用或禁用扩展跟踪,则可以使用扩展跟踪API的startExtendedTracking和stopExtendedTracking方法,如以下代码示例所示

// Starts/stops extended tracking for a given trackablepublic void UseExtendedTracking(string trackableName, bool enabled) {    IEnumerable<TrackableBehaviour> tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours();    foreach (TrackableBehaviour tb in tbs) {        // check trackable name        if (tb.TrackableName.Equals( trackableName )) {            if (enabled)                 tb.StartExtendedTracking();            else                tb.StopExtendedTracking();            return;        }    }}