Start a new topic
Solved

SLAM not working with Instant Tracking

 I'm having trouble with the Unity Plugin of the Wikitude SDK. I'm using the latest version of all the software. My application is focused around instant tracking, allowing the user to initialize the AR experience by lining up a virtual model on the screen with the physical object in front of them, however, the problem I'm facing at the moment is that it seems as if the SLAM algorithm is not functioning, because the moment that the phone can no longer see the majority of the original scene, it loses tracking. To see if this was a bug or not, I modified the original instant tracking example provided by Wikitude to suit my needs, and this problem did non arise. I have been as of yet unable to find the bug that is causing this, because from what I can see my script for Instant Tracking contains the same major points as the example, therefore I'm asking if there is an out of the way setting that must be enabled or something of that nature. I have included my script (I am using C#) below, in the event that it can be of use.

I hope to hear from you soon, Felix.

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Wikitude;

public class InstantTracking : MonoBehaviour {

    public GameObject IsNotWorkingWarning;
    public GameObject HeightSlider;
    public GameObject DistanceSlider;
    public GameObject TransparencySlider;
    public GameObject LabelHolder;
    public Text HeightLabel;
    public Text DistanceLabel;
    public Text ARButtonText;
    public string ARStart;
    public string ARStop;

    public InstantTracker Tracker;
    public GameObject TrackedGameObject;

    private float heightOffGround = 0.1f;
    private bool ARing = false;
    private bool showingHelp = false;

    void Start ()
    {
        Application.targetFrameRate = 60;
        IsNotWorkingWarning.SetActive(false);
        TransparencySlider.SetActive(false);
        ARButtonText.text = ARStart;
        HeightLabel.text = LocalizationManager.instance.GetLocalizedValue("Height") + ": 1.25 m";
        DistanceLabel.text = LocalizationManager.instance.GetLocalizedValue("Distance") + ": 3 m";
    }

	public void StartStopAR()
    {
        if(!ARing)
        {
            Tracker.SetState(InstantTrackingState.Tracking);
            ARing = true;
            Master.initialized = true;
            ARButtonText.text = ARStop;
        }
        else
        {
            Tracker.SetState(InstantTrackingState.Initializing);
            ARing = false;
            Master.initialized = false;
            ARButtonText.text = ARStart;
        }
    }

    public void ChangeDistance(float value)
    {
        Vector3 location = TrackedGameObject.transform.position;
        location.z = -value;
        TrackedGameObject.transform.position = location;
        DistanceLabel.text = LocalizationManager.instance.GetLocalizedValue("Distance") + ": " + string.Format("{0:0.##} m", 1 + value/5);
    }

    public void ChangeHeight(float value)
    {
        heightOffGround = value;
        Vector3 location = TrackedGameObject.transform.position;
        location.y = -value;
        TrackedGameObject.transform.position = location;
        HeightLabel.text = LocalizationManager.instance.GetLocalizedValue("Height") + ": " + string.Format("{0:0.##} m", 1 + value/20);
    }

    public void EnterFieldOfVision(string target)
    {
        CanBeSeen(true);
    }

    public void ExitFieldOfVision(string target)
    {
        CanBeSeen(false);
    }

    private void CanBeSeen(bool active)
    {
        if(active)
        {
            IsNotWorkingWarning.SetActive(false);
            TransparencySlider.SetActive(true);
        }
        else
        {
            IsNotWorkingWarning.SetActive(true);
            TransparencySlider.SetActive(false);
        }
    }

    public void OnStateChanged(InstantTrackingState newState)
    {
        if(newState == InstantTrackingState.Initializing)
        {
            HeightSlider.SetActive(true);
            DistanceSlider.SetActive(true);
            LabelHolder.SetActive(true);
            TransparencySlider.SetActive(false);
            IsNotWorkingWarning.SetActive(false);
        }
        else
        {
            HeightSlider.SetActive(false);
            DistanceSlider.SetActive(false);
            LabelHolder.SetActive(false);
            TransparencySlider.SetActive(true);
        }
    }
}

cs

Hi,


Can you try setting the Camera Resolution to SD in the Wikitude Camera inspector. Since this is a performance issue, this is the first thing that comes to mind, since the default is Auto, which might translate to FullHD on your device. If that still doesn't work, maybe you could send us the entire project so that we can debug it.


Best regards,

Alexandru.

 Hi Alexandru,

Thanks, that seems to have solved the problem, it's working a lot better now.

Thank you for the help, Felix.

Login or Signup to post a comment