Log in or register to post comments

Cannot destroy dataset loaded from external storage

November 7, 2013 - 7:11pm #1

Hi, I am following the instruction https://developer.vuforia.com/resources/dev-guide/swappable-databases-unity to dynamically load and destroy datasets.  The load and activate is ok.  Even deactivate is ok.  However, when I try to destroy the dataset,  it generates errors as

Could not destroy trackable with id 1

Could not destroy trackable with id 2

...

 

This is the testing code I am using 

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class qcartest : MonoBehaviour, ITrackerEventHandler
{

    private QCARBehaviour qcarbhv;
    private DataSet dataSet = null;

	// Use this for initialization
	void Start () 
        {
            qcarbhv = FindObjectOfType(typeof(QCARBehaviour)) as QCARBehaviour;
            qcarbhv.RegisterTrackerEventHandler(this);
	}
	
	// Update is called once per frame
	void Update () 
        {
            if (Input.GetKeyDown("l"))
            {
                ImageTracker imageTracker = TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) as ImageTracker;
                var datasetPath = Application.persistentDataPath + "/SoundItOut2.xml";
                dataSet = imageTracker.CreateDataSet();
                if (!dataSet.Load(datasetPath, DataSet.StorageType.STORAGE_ABSOLUTE))
                {
                    Debug.Log("Failed loading Dataset @ " + datasetPath);
                    return;
                }

                Debug.Log("Dataset @ " + datasetPath + " loaded!");
                imageTracker.ActivateDataSet(dataSet);
            }


            if (Input.GetKeyDown("u"))
            {
                StartCoroutine("Co_Unload");
            }

	}

    public void OnInitialized()
    {
    }

    public void OnTrackablesUpdated()
    {
    }


    IEnumerator Co_Unload()
    {
        ImageTracker imageTracker = TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER) as ImageTracker;
        imageTracker.Stop();
        yield return new WaitForSeconds(0.5f);

        IEnumerable<DataSet> activeDataSets = imageTracker.GetActiveDataSets();
        List<DataSet> activeDataSetsList = new List<DataSet>();

        foreach (var item in activeDataSets)
        {
            activeDataSetsList.Add(item);
        }

        foreach (var item in activeDataSetsList)
        {
            imageTracker.DeactivateDataSet(item);
            Debug.Log("deactivated " + item.Path);
        }

        yield return new WaitForSeconds(0.5f);
        foreach (var item in activeDataSetsList)
        {
            imageTracker.DestroyDataSet(item, true);
            Debug.Log("destroyed " + item.Path);
        }

        yield return new WaitForSeconds(0.5f);
        imageTracker.Start();
    }

}

Please help what I am doing wrong.  Thanks.

Cannot destroy dataset loaded from external storage

December 5, 2016 - 6:17pm #8

yoalberto007 wrote:

Well I got to destroy the targets doing this. 

        StateManager stateManager = TrackerManager.Instance.GetStateManager ();

        stateManager.DestroyTrackableBehavioursForTrackable (trackableBehaviour.Trackable);

But you only can destroy the targets created by hand.

when you have a dataSet with more targets than the targets you have created in the scene Vuforia create target automatically for all the missing targets, you can not destroy those targets without Errors. 

The solution is to have in the DataSet  only the targets that you actually are going to use, Voforia is trying to recognize all of them even if you did not create the target in the scene.

hi,

what is the difference betwen "stateManager.DestroyTrackableBehavioursForTrackable" with "DestroyDataSet"?

and now I use "stateManager.DestroyTrackableBehavioursForTrackable" to destroy the dataset,

the problem :

After loaded another database,  it can`t identify TargetObject new.

Cannot destroy dataset loaded from external storage

December 5, 2016 - 6:16pm #7

AlessandroB wrote:

This is a known behaviour of Vuforia; you cannot destroy Datasets that have been loaded from file; you can only destroy Dataset that contains User Defined Targets.

However, you can simply deactivate them, without problems.

 

hi,

Can you give me a sample? I want to destroy the old dataset and  load a new at runtime.But it cannot identify the new target after loading.

Cannot destroy dataset loaded from external storage

December 5, 2016 - 12:48am #6

hi,

Your meaning that we can`t destroy the dataset, and load another database?

Cannot destroy dataset loaded from external storage

December 5, 2016 - 12:45am #5

hi,

what is the difference betwen "stateManager.DestroyTrackableBehavioursForTrackable" with "DestroyDataSet"?

and now I use "stateManager.DestroyTrackableBehavioursForTrackable" to destroy the dataset,

the problem :

I load another database, but it can`t recognize TargetObject

Cannot destroy dataset loaded from external storage

November 24, 2016 - 6:25pm #4

hi,

Did you get it? I have the same question!

Cannot destroy dataset loaded from external storage

August 20, 2014 - 7:14am #3

Well I got to destroy the targets doing this. 

        StateManager stateManager = TrackerManager.Instance.GetStateManager ();
        stateManager.DestroyTrackableBehavioursForTrackable (trackableBehaviour.Trackable);

But you only can destroy the targets created by hand.

when you have a dataSet with more targets than the targets you have created in the scene Vuforia create target automatically for all the missing targets, you can not destroy those targets without Errors. 

The solution is to have in the DataSet  only the targets that you actually are going to use, Voforia is trying to recognize all of them even if you did not create the target in the scene.

Cannot destroy dataset loaded from external storage

November 8, 2013 - 12:11am #2

This is a known behaviour of Vuforia; you cannot destroy Datasets that have been loaded from file; you can only destroy Dataset that contains User Defined Targets.

However, you can simply deactivate them, without problems.

 

Log in or register to post comments