Log in or register to post comments

Load DataSet from File

November 16, 2018 - 2:01am #1

Hello!



I'm currently trying to load a dataset from Application.persistentDataPath however I can't figure out why it doesn't work.

 

What I tried right now:

1. Created a new project

2. Enabled vuforia in player settings

3. Added an ar camera

4. Created a new script with the following content and attached it to a empty gameobject:

public class VuforiaLoader : MonoBehaviour {
    void Start () {
        VuforiaARController.Instance.RegisterVuforiaStartedCallback(LoadDataSet);
    }

    private void LoadDataSet()
    {
        ObjectTracker objectTracer = TrackerManager.Instance.GetTracker<ObjectTracker>();

        DataSet dataSet = objectTracer.CreateDataSet();

        var path = Application.persistentDataPath + "/Vuforia/" + "Spheres.xml";
        var type = VuforiaUnity.StorageType.STORAGE_ABSOLUTE;
        Debug.Log("Loading dataset " + path);

        if (!DataSet.Exists(path, type)) {
            Debug.LogError("<color=blue>Data set doesn't exist</color>");
            return;
        } else {
            Debug.LogError("<color=orange>Data set exists</color>");
        }

        if (!dataSet.Load(path, type)) {
            Debug.LogError("Couldn't load dataset");
            return;
        }
       
        objectTracer.Stop();

        if (!objectTracer.ActivateDataSet(dataSet)) {
            Debug.LogError("Failed to activate dataset");
            return;
        }

        if (!objectTracer.Start()) {
            Debug.LogError("Failed to start tracker");
            return;
        }

    }
}

5. Created a Image Target Database with 2 Targets in it called "Spheres"

6. Put the two files to C:\Users\user\AppData\LocalLow\DefaultCompany\VuforiaTests\Vuforia    Spheres.xml     and      Spheres.dat

7. Ran the project

 

Result:

According to DataSet.Exists() the dataset exists, but dataSet.Load() isn't able to load the DataSet.



Could somebody help?

 

AttachmentSize
Image icon OUTLOOK_2018-11-16_11-00-15.png23.47 KB

Load DataSet from File

November 19, 2018 - 2:00am #5

Alright I fixed it.

 

Problem was that I didn't use a key and thought (in dev player) that it'd work without one as well since it didn't give me an error message that it's missing one.

Load DataSet from File

November 19, 2018 - 1:47am #4

I've also looked around on the forum and googled quite a bit and tried out lots of different solutions to this problem.

For example I found this link: https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/loading-datasets-external-scources

But it looks kinda the same to mine and it doesn't work as well.

 

 

I can't use cloud repo since it requires a internet connection which is not optimal since the app should work offline as well.

 

Load DataSet from File

November 18, 2018 - 11:04pm #3

Hello!



Yes I did!



The targets load wonderfully when I put them into Assets/StreamingAssets/Vuforia.

 

However for my current task I need to load them from an external resource and therefore I'd need to load them during runtime. Which doesn't work for me.

Load DataSet from File

November 16, 2018 - 2:20pm #2

Hello,

Have you reviewed the following article?

https://library.vuforia.com/articles/Solution/Working-with-Vuforia-and-Unity.html

Thanks,

Vuforia Engine Support

Log in or register to post comments