Log in or register to post comments

ObjectTracker.TargetFinder.EnableTracking do not track target

May 23, 2016 - 12:31am #1

Hi!

I have some troubles with code below. I have printed some trackers. They are relatively small and close to each other (size is approximately 4*7 cm). When I scan one of this trackers OnNewSearchResult method executes OK. New tracker is registered for tracking with this:

_imageTargetBehaviour = (ImageTargetBehaviour)ObjectTracker.TargetFinder.EnableTracking(targetSearchResult, ImageTargetTemplate.gameObject);

But for 90% of times the OnTrackableStateChanged method is not called by Vuforia after that. For the last 10% percents after 10-20 seconds OnNewSearchResult is called and execution go to the if statement where content is going to show.

Because, can be scanned more than one tracker I use lock (lastTarget boolean variable) - it's guarantee that only one tracker will be tracked at the same time (if ObjectTracker.TargetFinder.EnableTracking() is called more than for one tracker Vuforia.UnityExtensions.dll starts to threw Exceptions in Update method of DigitalEyewearAbstractBehaviour class ).

So the problem step by step:

application recognize tracker, starts to track it, and after that Vufuria do not send updates of track state to OnNewSearchResult, and even user move away camera from this target and scan something else OnNewSearchResult will be called but this call will be ignored because previous target is still tracked and information about that is saved in lastTarget variable.

 

 

/************************************************* SOURCE ******************************************************/

public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
{
    if (lastTarget != null) return;
    //...
    _imageTargetBehaviour = (ImageTargetBehaviour)ObjectTracker.TargetFinder.EnableTracking(targetSearchResult, ImageTargetTemplate.gameObject);
    lastTarget = targetSearchResult.UniqueTargetId;
    //...
}

/// <summary>
/// Is called from OnTrackableStateChanged method alongside with OnTrackingLost() method
/// </summary>
internal void _HideDLC()
{
    lastTarget = null;
    //...
}

/***************** DefaultTrackableEventHandler ****************/

public void OnTrackableStateChanged(TrackableBehaviour.Status previousStatus,
                                TrackableBehaviour.Status newStatus)
{
    if (previousStatus == TrackableBehaviour.Status.UNKNOWN && newStatus == TrackableBehaviour.Status.UNKNOWN)
    {
        return;
    }
    if (previousStatus == TrackableBehaviour.Status.UNKNOWN && newStatus == TrackableBehaviour.Status.NOT_FOUND)
    {
        return;
    }

    if (newStatus == TrackableBehaviour.Status.DETECTED ||
        newStatus == TrackableBehaviour.Status.TRACKED ||
        newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
    {
        OnTrackingFound();
        CloudHandler.Instance._ShowDLC();
    }
    else
    {
        OnTrackingLost();
        CloudHandler.Instance._HideDLC();
    }
}

Log in or register to post comments