Log in or register to post comments

Unity load dataset setup trackables runtime

February 5, 2016 - 3:28pm #13

I can't seem to get this code to work. Has anybody had any luck with it?

 

https://developer.vuforia.com/forum/faq/unity-load-dataset-setup-trackables-runtime

Unity load dataset setup trackables runtime

August 29, 2016 - 5:48pm #12

I also found this code does not work. I'm able to download xml and dat files from the web but I can't find a way to load and activate them at runtime. 

Unity load dataset setup trackables runtime

August 30, 2016 - 11:01am #11

So I found the solution to make this code work. You need to change:

void Start()

    {

        QCARBehaviour qcb = GameObject.FindObjectOfType<QCARBehaviour>();

        qcb.RegisterQCARStartedCallback(LoadDataSet);

    }

To:

VuforiaBehaviour qcb = GameObject.FindObjectOfType<VuforiaBehaviour> ();

  qcb.RegisterVuforiaStartedCallback(LoadDataSet);

and if you are loading from the Steaming/QCAR folder you need to set the path as just putting the string name of the .xml file does not access the dataset.

Like this - public string dataSetName = Application.streamingAssetsPath + "/QCAR/" + DATASETNAME + ".xml";

Unity load dataset setup trackables runtime

September 22, 2016 - 1:20pm #10

Im sorry to bother you about this but any chance you could share your full working code? I tried those changes and it still failed to load. 

Unity load dataset setup trackables runtime

September 22, 2016 - 1:45pm #9

this is the exact code I am using if anyone wants to point out for me what I am doing wrong. Thank You

 

Quote:

using UnityEngine;

using System.Collections;

using Vuforia;

using System.Collections.Generic;

using UnityEngine.UI;



public class DynamicDataSetLoader : MonoBehaviour

{

    // specify these in Unity Inspector

    public GameObject augmentationObject = null;  // you can use teapot or other object

    public string DATASETNAME = "";  //  Assets/StreamingAssets/QCAR/DataSetName

    public string text = "";

    public Text test = null;

    // Use this for initialization

    void Start()

    {

        VuforiaBehaviour vb = GameObject.FindObjectOfType<VuforiaBehaviour>();

        vb.RegisterVuforiaStartedCallback(LoadDataSet);

    }

    void LoadDataSet()

    {

        string dataSetName = Application.streamingAssetsPath + "/QCAR/" + DATASETNAME + ".xml";

        ObjectTracker objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>();

        DataSet dataSet = objectTracker.CreateDataSet();

        if (dataSet.Load(dataSetName))

        {

            objectTracker.Stop();  // stop tracker so that we can add new dataset

            if (!objectTracker.ActivateDataSet(dataSet))

            {

                // Note: ImageTracker cannot have more than 100 total targets activated

                Debug.Log("<color=yellow>Failed to Activate DataSet: " + dataSetName + "</color>");

                text = "<color=yellow>Failed to Activate DataSet: " + dataSetName + "</color>";

            }

            if (!objectTracker.Start())

            {

                Debug.Log("<color=yellow>Tracker Failed to Start.</color>");

                text = "<color=yellow>Tracker Failed to Start.</color>";

            }

            int counter = 0;

            IEnumerable<TrackableBehaviour> tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours();

            foreach (TrackableBehaviour tb in tbs)

            {

                if (tb.name == "New Game Object")

                {

                    // change generic name to include trackable name

                    tb.gameObject.name = ++counter + ":DynamicImageTarget-" + tb.TrackableName;

                    // add additional script components for trackable

                    tb.gameObject.AddComponent<DefaultTrackableEventHandler>();

                    tb.gameObject.AddComponent<TurnOffBehaviour>();

                    if (augmentationObject != null)

                    {

                        // instantiate augmentation object and parent to trackable

                        GameObject augmentation = (GameObject)GameObject.Instantiate(augmentationObject);

                        augmentation.transform.parent = tb.gameObject.transform;

                        augmentation.transform.localPosition = new Vector3(0f, 0f, 0f);

                        augmentation.transform.localRotation = Quaternion.identity;

                        augmentation.transform.localScale = new Vector3(0.005f, 0.005f, 0.005f);

                        augmentation.gameObject.SetActive(true);

                    }

                    else

                    {

                        Debug.Log("<color=yellow>Warning: No augmentation object specified for: " + tb.TrackableName + "</color>");

                        text ="< color = yellow > Warning: No augmentation object specified for: " + tb.TrackableName + " </ color > ";

                    }

                }

            }

        }

        else

        {

            Debug.LogError("<color=yellow>Failed to load dataset: '" + dataSetName + "'</color>");

            text = "<color=yellow>Failed to load dataset: '" + dataSetName + "'</color>";

        }

    }

    public void Update()

    {

       

        if (text != "")

        {

            test.text = text;

        }

    }

}

Unity load dataset setup trackables runtime

September 22, 2016 - 4:37pm #8

i did finally get it to import and create the game object but I am having a few issues.

 

its not checking the load and activate on the ar camera

 

and the mesh renderer of the Game object is turned off when imported.

 

from what I can tell,  those are the only issues. 

Unity load dataset setup trackables runtime

September 23, 2016 - 9:45am #7

Ok so the renderer problem. isn't a problem. my laptop hasn't been able to use the scene in play mode in forever and i wasn't aware thats what it does until tracked.

now when the image target is tracked the mesh renderer is activated, but the model doesn't show up on the image target (so I guess it isn't taking the trackers position and applying it to the model) and under the arcamera it is still never checked.

I will continue to update this once it is working properly to help out everyone else but if anyone has any idea, I am all ears

Unity load dataset setup trackables runtime

September 23, 2016 - 11:49am #6

ok so issue was the local size set in code was to small. increasing it to 2f, 2f, 2f brought it to the appropriate size

Now i just need to make extended tracking work with it and then it will finally be working correctly after over a year

Unity load dataset setup trackables runtime

September 30, 2016 - 6:46am #5

Anyone have managed to get this to use with videos? Somehow I managed to get a cube from the scene to show up... not sure how haha. At one point I got the video X to show up, but that was just for a short second. I had hoped that I could get videos up and loaded when needed to prevent the app from overloading memory on phones.

 

*Edit*

Actually... I have 3 trackables with 3 videos. I have Imagetarget 1,2 and 3 in my scene all set up with video prefab. Then I have the Imagetargets set up to 3 empty game objects with the script on and the database name in line. For some strange reason Imagetarget 2 shows up with the X (video there). Meanwhile on Imagetarget 1 and 3 I get a white X-axis and Y-Axis line into the centre of the trackables but noting more. It is almost as if it find them but can't display videos. Any ideas? also how would I expand the script to be able to find 3+ databases?

Unity load dataset setup trackables runtime

April 25, 2017 - 11:25am #4

I have tried implementing loading 3D Models & trackers dynamically..it's working perfectly.  When I click 3D model scene, very first time it is work perfectly. I close the scene and again clicked on 3D scene from multiple scene menu options...then focused on Chips image. I am not seeing augmenting tracking object anymore. Event is not triggering(Tracker Found/Tracker Lost) 

Can anyone please let me know what will be the issues? 

Unity load dataset setup trackables runtime

June 30, 2017 - 10:30am #3

ganusajjan wrote:

I have tried implementing loading 3D Models & trackers dynamically..it's working perfectly.  When I click 3D model scene, very first time it is work perfectly. I close the scene and again clicked on 3D scene from multiple scene menu options...then focused on Chips image. I am not seeing augmenting tracking object anymore. Event is not triggering(Tracker Found/Tracker Lost) 

Can anyone please let me know what will be the issues? 

 

I'm stuck on this too. the target tracks on the camera but it's not triggering anything in defaulttrackablebehaviour

Unity load dataset setup trackables runtime

July 7, 2017 - 5:27pm #2

We are having this same issue.

Did anyone get it solved?

 

Vuforia, I think this is a serious bug on 6.2.

 

 

Unity load dataset setup trackables runtime

August 14, 2017 - 9:28am #1

We have the same issue.

Tracking works fine, but the targets are not triggering anything in defaulttrackablebehaviour.

Is anyone able to help?

Log in or register to post comments