Log in or register to post comments

Image target problem

November 7, 2016 - 5:40am #1

I learn augmented reality and have a problem. I want to use one image target but I have lots of picture(in my vuforia database). I can read only one image but

this is a problem for me. I have to scan lots of marker(I will read different markers but one image target enough)

I have to perceive this images name and use a loop. I used codes on the internet but they don't work.

How can solve this problem?

Can you help me please?

using UnityEngine;

using System.Collections;

using System.Collections.Generic;

using Vuforia;

public class DynamicTargets : MonoBehaviour

{

    private bool mChipsObjectCreated = false;



    // Update is called once per frame

    void Update()

    {

       // mChipsObjectCreated = false;

        IEnumerable<TrackableBehaviour> trackableBehaviours = TrackerManager.Instance.GetStateManager().GetActiveTrackableBehaviours();

        // Loop over all TrackableBehaviours.

        foreach (TrackableBehaviour trackableBehaviour in trackableBehaviours)

        {

            string name = trackableBehaviour.TrackableName;

            Debug.Log("Trackable name: " + name);

          

           while (name.Equals("photo") && !mChipsObjectCreated)

            {

                // chips target detected for the first time

                // augmentation object has not yet been created for this target

                // let's create it

                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

                // attach cube under target

                cube.transform.parent = trackableBehaviour.transform;

                // Add a Trackable event handler to the Trackable.

                // This Behaviour handles Trackable lost/found callbacks.

                trackableBehaviour.gameObject.AddComponent<DefaultTrackableEventHandler>();

                // set local transformation (i.e. relative to the parent target)

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

                cube.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);

                cube.transform.localRotation = Quaternion.identity;

                cube.gameObject.SetActive(true);

                mChipsObjectCreated = true;

            }

}

    }

}

Log in or register to post comments