Log in or register to post comments

Failed to load dataset

October 22, 2018 - 1:34am #1

Hello! I can't download image target from the Application.persistentDataPath through VuforiaUnity.StorageType.STORAGE_ABSOLUTE. The path to the file is correct, checked through the DataSet.Exists, does not give an error. Help me please!

Here is my script:

public class SDCardDataSetLoader : MonoBehaviour

{

    // specify these in Unity Inspector

    public GameObject augmentationObject = null;  // you can use teapot or other object

    public string dataSetName = "MM_Spaceport.dat"; 

   

    void Start()

    {

         VuforiaARController.Instance.RegisterVuforiaStartedCallback(LoadDataSet);

    }

    void LoadDataSet()

    {

        string pathDataSet = Application.persistentDataPath + "/" + dataSetName;

        print(pathDataSet);

        if (!DataSet.Exists(pathDataSet, VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) {

            Debug.LogError("Data set " + pathDataSet + " does not exist.");

            return;

        } else

            print("good path");

        ObjectTracker objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>();

        DataSet dataSet = objectTracker.CreateDataSet();

        if (dataSet.Load(pathDataSet, VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) {



            objectTracker.Stop();  // stop tracker so that we can add new dataset

            if (!objectTracker.ActivateDataSet(dataSet)) {

                Debug.Log("<color=yellow>Failed to Activate DataSet: " + dataSetName + "</color>");

            }

            if (!objectTracker.Start()) {

                Debug.Log("<color=yellow>Tracker Failed to Start.</color>");

            }

            int counter = 0;

            IEnumerable<TrackableBehaviour> tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours();

            foreach (TrackableBehaviour tb in tbs) {

                if (tb.name == "New Game Object") {

                    tb.gameObject.name = ++counter + ":DynamicImageTarget-" + tb.TrackableName;

                    tb.gameObject.AddComponent<DefaultTrackableEventHandler>();

                    tb.gameObject.AddComponent<TurnOffBehaviour>();

                    if (augmentationObject != null) {

                        GameObject augmentation = (GameObject)GameObject.Instantiate(augmentationObject);

                        augmentation.transform.parent = tb.gameObject.transform;

                        augmentation.transform.localPosition = new Vector3(0f, 0f, 0f);

                        augmentation.transform.localRotation = Quaternion.identity;

                        augmentation.transform.localScale = new Vector3(0.005f, 0.005f, 0.005f);

                        augmentation.gameObject.SetActive(true);

                    } else {

                        Debug.Log("<color=yellow>Warning: No augmentation object specified for: " + tb.TrackableName + "</color>");

                    }

                }

            }

        } else

            Debug.LogError("<color=yellow>Failed to load dataset: '" + dataSetName + "'</color>");

    }

}

Log in or register to post comments