Log in or register to post comments

Enable/Disable dynamically extended Tracking (PositionalDeviceTracker)

March 18, 2019 - 10:02am #7

Hello, 

I have a Unity application with mutiple augmented reality scenes, using ImageTargets.



For some on these scenes, I need to use Extended Tracking, and not for some others.

So I want to be able to activate/disable the extended tracking dynamically. After reading the documentation, I understood the correct method was to use the InitTracker method from the TrackerManager class.



So, In the VuforiaConfiguration, I have disabled the device tracker mode because by default, I dont want to use the extended tracking. and i created this class : 

 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Vuforia;

public class ExtendedTrackingManager : MonoBehaviour

{

    public bool mustInitExtendedTracking = false;



    // Start is called before the first frame update

    void Awake()

    {

        VuforiaARController.Instance.RegisterVuforiaInitializedCallback(OnVuforiaInitialized);

    }

    void OnVuforiaInitialized()

    {

        Debug.Log("OnVuforiaInitialized ! - " + mustInitExtendedTracking);

        if (mustInitExtendedTracking)

        {

            DeviceTracker deviceTracker = TrackerManager.Instance.InitTracker<PositionalDeviceTracker>();

            if (deviceTracker != null)

            {

                Debug.Log("deviceTracker.Start()");

                deviceTracker.Start();

            }

        }

        else

        {

            PositionalDeviceTracker deviceTracker = TrackerManager.Instance.InitTracker<PositionalDeviceTracker>();

            if (deviceTracker != null)

            {

                Debug.Log("deviceTracker.Stop()");

                deviceTracker.Reset();

                deviceTracker.ResetAnchors();

                deviceTracker.Stop();

            }

        }

    }

    // Update is called once per frame

    void Update()

    {

       

    }

}

 

 

But the matter is that when the extended tracking should be enable, it doesn't work. The android logcat says : 



03-18 17:49:35.117 17829 17878 I Unity   : OnVuforiaInitialized ! - True

03-18 17:49:35.117 17829 17878 I Unity   :

03-18 17:49:35.117 17829 17878 I Unity   : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

03-18 17:49:35.117 17829 17878 I Unity   :

03-18 17:49:35.117 17829 17878 E Unity   : PositionalDeviceTracker failed to initialize

 

If I try to disable the error is the same : 



03-18 17:49:35.117 17829 17878 I Unity   : OnVuforiaInitialized ! - Fale

03-18 17:49:35.117 17829 17878 I Unity   :

03-18 17:49:35.117 17829 17878 I Unity   : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

03-18 17:49:35.117 17829 17878 I Unity   :

03-18 17:49:35.117 17829 17878 E Unity   : PositionalDeviceTracker failed to initialize

 

What is the correct method to enable/disable extended tracking ?

 

Unity 2018 3.x

Vuforia 8x

Enable/Disable dynamically extended Tracking (PositionalDeviceTracker)

March 19, 2019 - 4:13am #6

Hello,

Extended Tracking is only enabled with the Positional Device Tracker (PDT). Thus, if you don't want the Extended Tracking feature, you won't initialize the PDT - tracking using the device camera alone should work as expected. Note the PDT will be initialized by default when using: Ground Plane game objects, Model Targets game objects, and *any feature* that runs on HoloLens.

Would it be simpler for you to monitor the tracking state of a target using TrackableBehaviour.Status() to help drive your logic? This way you don't have to go through enabling/disabling the PDT on a per-scene basis.

https://library.vuforia.com/content/vuforia-library/en/reference/unity/classVuforia_1_1TrackableBehaviour.html#a67a0db04d321a74b7e7fcfd3f1a3f70b

Thanks,

Vuforia Engine Support

 

Enable/Disable dynamically extended Tracking (PositionalDeviceTracker)

March 19, 2019 - 9:25am #5

Hello medabit,

Thanks for your answer.

Maybe my question wasn't clear enough.

For now, in the application, we just have 2 possibilities : to activate or desactivate the extended tracking for all of the scenes.

I didn't find a way to activate the extended tracking on just a couple of these scenes.

I thought that in my last message, the sourcecode that I used would fix the problem. I don't see what didn't work and I would like to know if theret is a solution.

Could I manually change the sourcecode on some of the scenes to activate or desactivate the extended tracking, and not have a global extended tracking on the whole application (that is to say : change the parameter DeviceTracker (PDT) in VuforiaConfiguration).

Enable/Disable dynamically extended Tracking (PositionalDeviceTracker)

March 20, 2019 - 6:02am #4

You want to start/stop the PositionalDeviceTracker on a per scene basis.

This article describes how to Initialize the PDT if you don't want to start with it initialized/started for example: https://library.vuforia.com/articles/Solution/Configuring-Rotational-Tracking-in-Unity.html

 

To access and stop the PDT, the following code should work from a script (PDT must have been previously initialized):

 

var pdt = TrackerManager.Instance.GetTracker<PositionalDeviceTracker>();

pdt.Stop();

 

To start it again, use the Start() method.

 

Peter

Enable/Disable dynamically extended Tracking (PositionalDeviceTracker)

March 25, 2019 - 4:11am #3

pmessenger wrote:

You want to start/stop the PositionalDeviceTracker on a per scene basis.

This article describes how to Initialize the PDT if you don't want to start with it initialized/started for example: https://library.vuforia.com/articles/Solution/Configuring-Rotational-Tracking-in-Unity.html

 

To access and stop the PDT, the following code should work from a script (PDT must have been previously initialized):

 

var pdt = TrackerManager.Instance.GetTracker<PositionalDeviceTracker>();

pdt.Stop();

 

To start it again, use the Start() method.

 

Peter

 

@pmessenger Hello Peter,

Thanks for your answer. I try your solution to enable/disable Extended Tracking dynamically, but the matter is still the same for me. I suppose that I did not do it right, but I don't know what is incorrect.

In my project, I have disable the Device tracker in the VuforiaConfiguration pannel.

I have create a small testcase with 3 scenes :

-one scene with the Vuforia Extended Tracking (ExtendedTrackingVuforiaScene) active

-one classic vuforia scene without the extended Tracking (ClassicVuforiaScene)

-one mainscene to switch between the 2 others

When the ExtendedTrackingVuforiaScene is loaded, I do the next code :

public class ActiveExtendedTracking : MonoBehaviour

{

    void Awake()

    {

        VuforiaARController.Instance.RegisterVuforiaInitializedCallback(OnVuforiaInitialized);

    }

    void OnVuforiaInitialized()

    {

       

        var deviceTracker = TrackerManager.Instance.InitTracker<PositionalDeviceTracker>();

        deviceTracker.Start();

        StartCoroutine("CoroutineStartPDT");

       

    }

    IEnumerator CoroutineStartPDT()

    {

        yield return null;

        var pdt = TrackerManager.Instance.GetTracker<PositionalDeviceTracker>();

        pdt.Start();

    }



}

 

 

 

When the ClassicVuforiaScene is Loaded I do that :

public class DesactiveExtendedTracking : MonoBehaviour

{

    void Awake()

    {

        VuforiaARController.Instance.RegisterVuforiaInitializedCallback(OnVuforiaInitialized);

    }

    void OnVuforiaInitialized()

    {

        /*var deviceTracker = TrackerManager.Instance.InitTracker<PositionalDeviceTracker>();

        deviceTracker.Stop();

       */

        var pdt = TrackerManager.Instance.GetTracker<PositionalDeviceTracker>();

        pdt.Stop();

    }

}

 

Can you help me to fix my problem ?

 

Enable/Disable dynamically extended Tracking (PositionalDeviceTracker)

March 25, 2019 - 8:14am #2

I had a quick look at your project and it seems to be working for me. An easy way to verify if extended tracking is working is to cover a target and see if the augmentation is still displayed.

Note: You're currently enabling the PDT twice. You only need to call Start() on the device tracker once, and there's no need for doing it in a co-routine (currently that part is failing and throwing a MissingReferenceException). 

Also, use GetTracker<>() instead of InitTracker, if you've already initialized it. You only need to initialize once and there's no need to de-init it afterwards in your case (start/stop is enough).

 

Hope that helps!

 

Enable/Disable dynamically extended Tracking (PositionalDeviceTracker)

March 28, 2019 - 7:31am #1

@pmessenger Hello Peter, thanks for your answer but it doesn't work. We didn't use the InitTracker method, it was in commented lines. We have deleted the Coroutine, but the result in the same : On all our Android devices, (ex: Moto X4, Samsung S8plus), if we're trying first to launch the Extended Tracking scene, it seems to be activate (but extended tracking is very more instable than with previous releases...), and if we launch the no-extended tracking scene first, and try to activate the extended tracking scene after, the Extended Tracking is never working,

We don't understand. We have lot of problem with extended tracking since the Vuforia 8.x / Unity 2018.3.x with our projects that's why we really need to have a simple test case like.

I put the simple test case project in attached file

Log in or register to post comments