Log in or register to post comments

Switching camera from Rotational / Positional device tracking mode.

July 9, 2018 - 8:13am #1

So I'm making an app currently that I want to be compatible for both older and newer versions of android. I know that Ground Plane detection is only available on newer versions so I've developed both a Ground Plane and non-Ground Plane mode of my app and I'd like to make a switch that automatically activates one based on the phone you're using. I currently use the method of searching the phone name in a list of strings to find if the device is ground plane compatible (as I don't think there's a better way to do it?) and this works fine. My issue is, in my non-ground plane version, I need to use rotational device tracking, however in my ground plane version I need positional device tracking. How do I programatically switch my camera from one mode to the other?

Thanks in advance for your help!

Switching camera from Rotational / Positional device tracking mode.

July 9, 2018 - 2:42pm #2

Hello DanielRubins,

You can create a function that attempts to initialize the PDT, but if it fails it falls back on initializing the RDT instead. Here's a quick example.

public void InitializeTracker()
{
    PositionalDeviceTracker positionalDeviceTracker = TrackerManager.Instance.InitTracker<PositionalDeviceTracker>();
    if( positionalDeviceTracker != null )
    {
        // Positional device tracker is not null and is therefore supported on device. No need to proceed.
        return;
    }

    // No positional device tracker supported on this device so initialize the rotaitonal tracker.
    RotationalDeviceTracker rotationalDeviceTracker = TrackerManager.Instance.InitTracker<RotationalDeviceTracker>();
}

If you intend on calling this more than once in your code, you should call "GetTracker" before initializing to check if it already exists: rotationalDeviceTracker = TrackerManager.Instance.GetTracker<RotationalDeviceTracker>();

Thanks,

Vuforia Engine Support

Log in or register to post comments