Hi everyone,
I've followed the following link for createing a dataset from an external path:
https://developer.vuforia.com/library/articles/Solution/Unity-Load-DataSet-from-SD-Card
I've successfully created and activate my dataset, now what I'm trying to do is to add a reset function which will reload the same dataset with a different setting (the use or not of extend tracking for example).
So far here what I've done:
public void DoAReset(){ //deactive dataset ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>(); tracker.DeactivateDataSet (mDataset); List<string> trackableNames = new List<string> (); IEnumerable<TrackableBehaviour> trackableBehaviours = TrackerManager.Instance.GetStateManager ().GetTrackableBehaviours (); foreach (TrackableBehaviour trackableBehaviour in trackableBehaviours) { if (mDataset.Contains (trackableBehaviour.Trackable)) { trackableNames.Add (trackableBehaviour.Trackable.Name); } } foreach (string trackableName in trackableNames) { GameObject go = GameObject.Find (trackableName); DefaultTrackableEventHandler tra = go.GetComponent<DefaultTrackableEventHandler> (); tra.StopTrackableEventHandler (); } //remove dataset tracker.DestroyDataSet (mDataset, false); //reset mLoaded and mDataset mDataset = null; mLoaded = false;//reload model }
Here is the StopTrackableEventHandler function:
public void StopTrackableEventHandler(){ if (mTrackableBehaviour) { mTrackableBehaviour.UnregisterTrackableEventHandler (this); } TrackerManager.Instance.GetStateManager ().DestroyTrackableBehavioursForTrackable (mTrackableBehaviour.Trackable, true); Destroy (mTrackableBehaviour); }
With the following code, I have to problem:
1- for the line "tracker.DestroyDataSet (mDataset, false);", if I set the second parameter to "true", I'll have an error saying that the Trackable cannot be destroy
2- When I load my dataset, my 2 trackable receive as ID 1 and 2, but after calling the reset function, those ID changed to 4 and 5, then 7 and 8 if call reset again. It probably means that the previous ImageTarget were not completely destroyed but how can destroy any previous ImageTarget?
Could you please tell me the proper way to completely remove a dataset?
I really thank you in advance for your help
Hi,
you can remove (destroy) Trackables from UserDefined Datasets (UDT), but you cannot remove them from a DataSet that was loaded from a .DAT / .XML file.
(The UDT Sample App also shows an example of removing trackables from a UDT Dataset, for example).
For DataSets lodaded from file, you can simply deactivate and destroy the whole DataSet, using tracker.DestroyDataset( dataset, false );
Also, the fact that the Trackable IDs are not restarting from 0 (or from 1) is just because the internal ID counter is not necessarily reset to zero, but it's not necessarily an indication of a trackable not being removed from memory.