OBB Splitting and dynamically loading datasets

March 15, 2015 - 3:33am #1

I am trying to combine OBB splitting with dynamically loading and activating data sets and have failed.

Following these 2 articles for help:

https://developer.vuforia.com/forum/faq/unity-how-can-i-handle-large-android-apps

https://developer.vuforia.com/library/articles/Solution/Unity-Load-DataSet-from-SD-Card

Came up with the following code:

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

public class DataSetLoader : MonoBehaviour
{
        private bool mLoaded = false;
        private DataSet mDataset = null;

   
        void Update ()
        {
                // Debug.Log (QCARRuntimeUtilities.IsQCAREnabled());

                if (QCARRuntimeUtilities.IsQCAREnabled () && !mLoaded) {
                        
                    LoadDataSet();

                }
        }

    void LoadDataSet()
    {

            // First, create the dataset
            ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker> ();
            mDataset = tracker.CreateDataSet ();

            if (mDataset.Load (Application.persistentDataPath+"/DIDI", QCARUnity.StorageType.STORAGE_ABSOLUTE))     
               {
                 mLoaded = true;

                 Debug.Log ("DataSet Loaded Successfully");

                 // Activating the dataset
                 Debug.Log (tracker.IsActive);
                 tracker.ActivateDataSet(mDataset);

               } else {
                      Debug.LogError ("Failed to load dataset!");
                      }

              }
}

After the OBB extraction, the dataset never seems to load. I checked and the data set on the mobile android device is copied to the persistentDataPath.

I can also use the data set if I set the 'Load Data Set Your_Dataset_Name' and 'Activate Data Set Your_Dataset_Name' check-boxes to enabled (ticked) in the ARCamera inspector (under the Data Set Load Behaviour component). But I want to load the data sets dynamically.

Any directions to how this would be acheived would be appreciated.

 

 

 

OBB Splitting and dynamically loading datasets

March 25, 2015 - 7:53am #4

I see.

If you don't want to use the "automatic" dataset loading feature, you should still be able to load and activate the Datasets in script, but you need to:

  • Make sure that the "Load Data Set" and "Activate Data Set" checkboxes are OFF (unchecked), in the ARCamera inspector
  • In your loading script, use the StorageType STORAGE_ABSOLUTE and use the full path to the actual location of the Dataset files that you have stored after extracting them

See also the Dataset Load API here:

https://developer.vuforia.com/resources/api/unity/class_vuforia_1_1_data_set

 

 

OBB Splitting and dynamically loading datasets

March 25, 2015 - 5:16am #3

Thank you for the link.

As for the explanation. This is exactly what I have done. I have managed to load and activate data sets after the OBB file extraction.

But as soon as I want to switch from automatic loading and activation of the dataset (Done by marking these options in the AR prefab) to a manual loading and activation of data set via code as described below, the process fails.

OBB Splitting and dynamically loading datasets

March 20, 2015 - 9:01am #2

Hi, 

 

you should divide the "OBB extraction and dataset loading" in 2 steps;

to this aim, the easiest and cleanest approach is to create 2 scenes in Unity:

  • the first scene is only used for "extracting" the Dataset files from the OBB package and storing them to another location on your device storage
  • the second scene is the AR (Vuforia) scene: in this scene you actually Load (and activate) the Dataset files from the device storage location from the previous step (scene 1)

 

This thread also provides a very detailed explanation of the setup and the code snippets needed:

https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/cant-load-dataset-obb-vuforia-3

 

HTH

 

Log in or register to post comments