Log in or register to post comments

Loading Dataset at Runtime From External Directory

March 12, 2018 - 1:45pm #4

This problem is happening while I am still running from Editor. 

Using Vuforia 7 with Unity 2017.3.0p4

The dataset is loaded. A ObjectTargetBehavior is created but the fields Database and ObjectTarget are EMPTY. And obviously it won't detect anything.

The objective is to download the dataset from an external server and dinamically load it. It will be a mobile application made with unity.

I followed the tutorial to load a dataset at runtime but so far this is the result. 

I am using the following code to load the dataset at runtime:

 

</p>
<p>void Update() {</p>
<p>        if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && !mLoaded) {</p>
<p>            string externalPath = Application.streamingAssetsPath + "/OficinaPackage/Datasets/MSI_H87M-G43_OT.xml";</p>
<p>            if (mDataset == null) {<br>
	                // First, create the dataset<br>
	                ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();<br>
	                mDataset = tracker.CreateDataSet();<br>
	            }</p>
<p>            if (mDataset.Load(externalPath, VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) {<br>
	                mLoaded = true;<br>
	            } else {<br>
	                Debug.LogError("Failed to load dataset!");<br>
	            }</p>
<p>        }<br>
	    }</p>
<p>

 

 

Loading Dataset at Runtime From External Directory

March 13, 2018 - 11:29am #3

Hello CeciLisCosta,

Are you activating the dataset at any point?

Thanks,

Vuforia Support

Loading Dataset at Runtime From External Directory

March 14, 2018 - 3:47am #2

Yes. 

Sorry, the code I past before was another test. This is what I am actually using.

the lines "dataset activated" and "tracker started" are printed. So I supose it is being loaded, activated and started properly.

 

</p>
<p>public class SDCardDataSetLoader : MonoBehaviour {<br>
	    private bool mLoaded = false;<br>
	    private DataSet mDataset = null;<br>
	    // Update is called once per frame<br>
	    void Update() {</p>
<p>        if (VuforiaRuntimeUtilities.IsVuforiaEnabled() && !mLoaded) {</p>
<p>            string externalPath = Application.streamingAssetsPath + "/OficinaPackage/Datasets/MSI_H87M-G43_OT.xml";</p>
<p>            ObjectTracker tracker = null;<br>
	            if (mDataset == null) {<br>
	                // First, create the dataset<br>
	                tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();<br>
	                mDataset = tracker.CreateDataSet();<br>
	            }</p>
<p>            if (mDataset.Load(externalPath, VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) {<br>
	                mLoaded = true;</p>
<p>                if (!tracker.ActivateDataSet(mDataset)) {<br>
	                    // Note: ImageTracker cannot have more than 100 total targets activated<br>
	                    Debug.Log("<color=yellow>Failed to Activate DataSet: " + "</color>");<br>
	                } else {<br>
	                    Debug.Log("data set activated");<br>
	                }<br>
	                if (!tracker.Start()) {<br>
	                    Debug.Log("<color=yellow>Tracker Failed to Start.</color>");<br>
	                } else {<br>
	                    Debug.Log("tracker started");<br>
	                }</p>
<p>            } else {<br>
	                Debug.LogError("Failed to load dataset!");<br>
	            }</p>
<p>        }<br>
	    }<br>
	}</p>
<p>

obs: Didn't find out how to past a code here inside a proper code box or formated...

Loading Dataset at Runtime From External Directory

March 16, 2018 - 8:45am #1

Just to make it clear. I do not have the dataset imported to my aplication. I only put the .dat and .xml in a external directory. In the final application I will need to download the dataset and load it dinamically.

Log in or register to post comments