Log in or register to post comments

Detectig the currently tracked image targets anf their position

March 28, 2020 - 9:04am #1

Hi, I am new to Vuforia and unity and really want to know what is wrong. I want to track the number of targets detected currently and their position, and found this code on the other forum:


void Update()

    {

        StateManager sm = TrackManager.Instance.GetStateManager ();

        IEnumerable<TrackableBehaviour> activeTrackables = sm.GetActiveTrackableBehaviours ();

        Debug.Log ("List of trackables currently active:");

        foreach (TrackableBehaviour tb in activeTrackables) {

            Debug.Log("Trackable: " + tb.TrackableName + " " );

        }

    }

 

but unity gives me the following error:

error CS0103: The name 'TrackManager' does not exist in the current context.

And also I don't know how to get the position of the detected trackables. How can that be done?

Detectig the currently tracked image targets anf their position

March 29, 2020 - 10:37pm #2

Hi,

I don't know this code above, but I can tell you a different way to do this:

You can write a script like this and put it on a GameObject in the scene:

int activeTargets =3;
    public GameObject IT1;
    public GameObject IT2;
    public GameObject IT3;

    public void increase()
    {
        activeTargets++;
        Debug.Log(activeTargets);
    }
    public void decrease()
    {
        activeTargets--;
        Debug.Log(activeTargets);
    }
    void Update()
    {
        Debug.Log(IT1.transform.position);
        Debug.Log(IT2.transform.position);
        Debug.Log(IT3.transform.position);
    }

Then you link your ImageTargets to the script and call from each ImageTarget the increase.function in OnTargetFound() and the decrease function in OnTargetLost(). See Image attached.

 

 

AttachmentSize
Image icon snip.PNG29.86 KB
Log in or register to post comments