Log in or register to post comments

Loading dataset from sdcard

November 18, 2014 - 11:20am #6

Hi, I'm trying to download a dataset to my external storage in android and then assign this dataset to my image target

I searched a lot in the forums and couldn't find (and understand) how this works.

I have an ARCamera , ImageTarget and a simple cube in my scene. the cube is the child of ImageTarget and I don't have any datasets in my assets at build time. here's my code which is attached to my ImageTarget : 

using UnityEngine;
using System.Collections;

public class datasetLoader : MonoBehaviour {

	public GUIText debugger;

	// Use this for initialization
	void Start () {
		Debug.Log("persistence path: " + Application.persistentDataPath);
		string testPath = Application.persistentDataPath + "/marker.xml";
		LoadDataSet(testPath , DataSet.StorageType.STORAGE_ABSOLUTE);
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	private bool LoadDataSet(string dataSetPath, DataSet.StorageType storageType)
	{
		if(!DataSet.Exists(dataSetPath, storageType))
		{
			Debug.LogError("Data set: " + dataSetPath + " does not exist.");
			return false;
		}

		ImageTracker imageTracker = (ImageTracker)TrackerManager.Instance.GetTracker<ImageTracker>();

		DataSet dataSet = imageTracker.CreateDataSet();
		if(!dataSet.Load(dataSetPath, storageType))
		{
			Debug.LogError("Failed to load data set " + dataSetPath + ".");
			return false;
		}

		imageTracker.ActivateDataSet(dataSet);

		return true;

	}
}

 

from what I understood this code creates the dataset but how can I assign it to the imagetarget I want?

I'll appreciate if you can help me with this.

Thanks very much

 

 

Loading dataset from sdcard

November 20, 2014 - 9:47am #5

Hi,  Anyone has any idea on how to get this right ? 

I've attached the inspector of the new  gameobject created by this script. As you can see the inspector shows " No targets defined"!. My question is how to tell it that I have loaded a dataset and also how can I assign this loaded dataset to the existing ImageTarget prefab I have in the scene.

Thanks very much

AttachmentSize
Image icon tracker.jpg12.57 KB

Loading dataset from sdcard

November 24, 2014 - 6:47am #4

Any chance anyone can help me with this ? I've been stuck with this problem for about a month and couldn't find any way to make it work.

I'll appreciate if someone can help me with this.

Thanks very much

Loading dataset from sdcard

November 24, 2014 - 7:56am #3

If you search the FAQ, you might stumble on this:

https://developer.vuforia.com/forum/faq/unity-how-do-i-get-list-active-trackables

This explains how the Targets (which belong to a Dataset that you loaded programmatically) can be retrieved at runtime using the StateManager class; it also provides some examples of how you can programmatically associate the targets to a custom augmentation object.

Hope this helps.

 

Loading dataset from sdcard

November 24, 2014 - 11:23pm #2

Hi Alessandro, Thanks for your help.

But my main problem here is that none of my objects have targets any loaded datasets.

I have followed the guide here : https://developer.vuforia.com/resources/dev-guide/swappable-databases-unity

and attached the script to my ImageTarget object. When I play the scene it creates a New Game Object which has ImageTargetBehaviour and DefaultTrackableEventHandler attached but this object and also my ImageTarget both don't have any datasets loaded.

I have attached a screenshot of inspector. 

I'll appreciate if you see and help me what is wrong with it.

Thanks very much

AttachmentSize
Image icon inspector.jpg16.3 KB

Loading dataset from sdcard

November 28, 2014 - 12:22am #1

I see. Make sure to:

- have added an ARCamera prefab into your scene

- select ARCamera, check the Inspector, check that the Data Set Load behaviour component contains a Dataset (if not, you need to put a valid Dataset XML and DAT in your Assets/Streaming Assets/QCAR directory, or import a Dataset unitypackage that you ahve downloaded from the Target Manager)

- Make sure the Load Dataset and Activate Dataset checkboxes are both checked (enabled)

- Once you have done this, you will be able to select the Target in your Image Target inspector.

See also this detailed guide:

https://developer.vuforia.com/resources/dev-guide/trackable-details-unity

 

Log in or register to post comments