Vuforia Extended Tracking 在 Unity + Hololens中的应用总结
程序员文章站
2022-04-28 21:26:16
...
官方文档: https://library.vuforia.com/articles/Training/Extended-Tracking
划重点:
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 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.
主要应用场景:追踪后显示的内容比较大,视野需要离开Target去跟随内容。
Target离开视野后根据环境特性保证持续的追踪,所以环境越复杂,extended的效果越好。
使用extended tracking的环境最好是基本静止的,大的环境变化增加额外的后台处理,还会影响显Target和map之间的的offset偏置精度,tracked again之后可能会重新计算offset。
微小的环境变化带来的offset可能会被忽略,影响了extended tracked的精度,off却不再重新计算,这样带来的问题反而比大的环境变化带来的问题严重。
tracking lost 5秒后自动重置extended tracking map。
unity中实现 extended tracking:
unity中 extended tracing 的 API:
自定义OnTrackingFound() 和 OnTrackingLost()
DefaultTrackableEventHandler.cs:
一次追踪一个target
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.
当前追踪的target lost tracking 后才能 track 新的 target。
同时追踪多个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.
主要应用场景:追踪后显示的内容比较大,视野需要离开Target去跟随内容。
Target离开视野后根据环境特性保证持续的追踪,所以环境越复杂,extended的效果越好。
使用extended tracking的环境最好是基本静止的,大的环境变化增加额外的后台处理,还会影响显Target和map之间的的offset偏置精度,tracked again之后可能会重新计算offset。
微小的环境变化带来的offset可能会被忽略,影响了extended tracked的精度,off却不再重新计算,这样带来的问题反而比大的环境变化带来的问题严重。
tracking lost 5秒后自动重置extended tracking map。
unity中实现 extended tracking:
unity中 extended tracing 的 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();
}
/ Starts/stops extended tracking for a given trackable
public 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;
}
}
}
自定义OnTrackingFound() 和 OnTrackingLost()
DefaultTrackableEventHandler.cs:
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();
}
Persistent Extended Tracking(PET)
extended tracking 的一种状态,tracking过程中不再重置或重建map,if the device is put down or the camera is stopped temporarily 也保持map不变。
应用场景:APP不管环境或者target的变化(“tracking lost 5秒后自动重置extended tracking map”这个功能对APP不利);可用 resetExtendedTracking API 手动重置map。
unity中的 resetExtendedTracking API:
ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
bool success = tracker.PersistExtendedTracking(!mPersistExtendedTracking);
if (success)
{
Debug.Log("PersistentExtendedTrackingEnabled");
}
// To reset Extended Tracking
tracker.ResetExtendedTracking();
一次追踪一个target
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.
当前追踪的target lost tracking 后才能 track 新的 target。
同时追踪多个targets
同时追踪多个 targets 建议不使用PET。
unity中的相关设置:
Hololens + unity 项目中遇到的问题:
1. 设置了 simultaneous tracked objects 为1, 仍然能发现两个同时处于 newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED 状态的 ImageTargets。EXTENDED_TRACKED不属于这里的 tracked?
2. 想设置 ImageTarget 的PET 为 false,ObjectTracker 中只有 TrackerManager.Instance.GetTracker<ObjectTracker>(),没有TrackerManager.Instance.GetTracker<ImageTracker>()。
上一篇: 唐初两大名将李靖和李绩哪个更厉害?