Log in or register to post comments

Deactivate database

June 14, 2018 - 3:23am #1

Hello Guys!

I need to deactivate and after activate some database, but I don't know how can I do this.

How can I use DataSet for deal with the problem?

Please, help me.

I would like to stop recognizing for second target when I'm working with firs target, because the targets are similar and I know when I will recognize first target.

Deactivate database

June 15, 2018 - 5:06am #3

It works!

Thank you so much

You are the best!

Deactivate database

June 14, 2018 - 9:26am #2

Hello RuslanLevitskiy,

The follow code will de-activate all datasets and then activate the specified dataset.

public void SwitchTargetByName(string activateThisDataset)
{
    TrackerManager trackerManager = (TrackerManager)TrackerManager.Instance;
    ObjectTracker objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>();

    IEnumerable<DataSet> datasets = objectTracker.GetDataSets();
    IEnumerable<DataSet> activeDataSets = objectTracker.GetActiveDataSets();
    List<DataSet> activeDataSetsToBeRemoved = activeDataSets.ToList();
        
    //Loop through all the active datasets and deactivate them.
    foreach (DataSet ads in activeDataSetsToBeRemoved)
    {
        objectTracker.DeactivateDataSet(ads);
    }
        
    //Swapping of the datasets should not be done while the ObjectTracker is working at the same time.
    //So, Stop the tracker first.
    objectTracker.Stop();
        
    //Then, look up the new dataset and if one exists, activate it.
    foreach (DataSet ds in datasets)
    {
        if (ds.Path.Contains(activateThisDataset))
        {
            objectTracker.ActivateDataSet(ds);
        }
        
    }
    //Finally, start the object tracker.
    objectTracker.Start();
}

Thanks,

Vuforia Support

Log in or register to post comments