Log in or register to post comments

Dynamic dataset load to ImageTarget problem

July 19, 2016 - 3:11am #1

Hi Everyone,

I have used code from this link: 

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

I have done load dataset from SD card, attach 3D model to ImageTarget in runtime and it work fine, ImageTarget can track the Target but it has a problem (Very big problem). When target is found, ARCamera will be crazy in position and rotation (https://drive.google.com/file/d/0B7ZatGj5WB5iTHpJa2NScWh5N00/view?usp=sharing) when i choosed FIRST_TARGET option in ARCamera, or ImageTarget will be crazy in position and rotation instead when i choosed SPECIFIC_TARGET option in ARCamera.

Is there anyone know why it happen and the way to solve it?

Thanks!

Dynamic dataset load to ImageTarget problem

March 4, 2017 - 2:00am #5

where i can found Dynamicdatasetload script?? in unity??

 

Dynamic dataset load to ImageTarget problem

July 20, 2016 - 11:47pm #4

Hi all, 

i found the answer that is default ARCamera has to change position and rotation to follow up with 3D model to make user can see 3D model smoothly.

THAT IS FEATURE NOT BUG :)))

Dynamic dataset load to ImageTarget problem

July 20, 2016 - 8:34pm #3

Yeah, it happen in Game window when i'm running the app.
I use code from the link in post #1 to dynamic adding database to an empty object at runtime. It work fine means: I can download Vuforia Database from my own server and add them to an object, it can create the Image Target object with database is loaded, and can track the image. 
But when image is tracked, ARCamera will be crazy in position and rotation (they have been set is 0,2,-10 in position and 0,0,0 in rotation). I don't know how it can happen cause i'm not changing anything in position or rotation of ARCamera in my code.
Here is my code:

using UnityEngine;
using System.Collections;

using Vuforia;
using System.Collections.Generic;


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
int counter = 0;

public static bool isDownloadObjectDone = false;
bool isLoaded = false;

// Use this for initialization
void Start()
{
  LoadDataSet (augmentationObject);
}

// Update is called once per frame
void Update()
{
  
}

public void LoadDataSet (GameObject augmentationObject)
{

  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>");
   }
  
   if (!objectTracker.Start ()) {
    Debug.Log ("<color=yellow>Tracker Failed to Start.</color>");
   }

   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;
     tb.transform.localScale = new Vector3 (10, 10, 10);

     // add additional script components for trackable
     tb.gameObject.AddComponent<TrackableBehavior> ();
     tb.gameObject.AddComponent<TurnOffBehaviour> ();
     tb.gameObject.AddComponent<MeshFilter> ();
     tb.gameObject.AddComponent<MeshRenderer> ();

     augmentationObject.transform.parent = tb.gameObject.transform;

    }
   }
  }
}
}

Dynamic dataset load to ImageTarget problem

July 19, 2016 - 7:42pm #2

Hi,

What do you mean like crazy movement? Is this happen in the Game window or the Scene window of Unity?

The way Vuforia try to create the AR experience is, at least for FIRST_TARGET mode, to move the camera and the video texture plane while keep the virtual object fit in the 3D world space, rather than move the virtual object.

So if the rapid movement is happening in the game view window then it should be an issue.

Todd

 

Log in or register to post comments