Log in or register to post comments

Multiple Image Target (Cloud Recognition)

March 29, 2016 - 11:44pm #1

hi everyone, I have problem with this code, and Im not clearly understand it. I want to make cloud reco can scanning more than one image target. I have added chips and tarmac cloud target and at this point I want to show 2 different 3D models, "ana" and "ironman" but thats not success. when I scan it, both of image target only show "ana" . please help me

Im using this code:

using UnityEngine;
using System.Collections;
using Vuforia;

public class SimpleCloudRecoEventHandler : MonoBehaviour, ICloudRecoEventHandler {
	#region PRIVATE_MEMBER_VARIABLES
  	
	// CloudRecoBehaviour reference to avoid lookups
	private CloudRecoBehaviour mCloudRecoBehaviour;
	// ImageTracker reference to avoid lookups
	private ObjectTracker mImageTracker;
    
	
	private GameObject ana, ironman;

	#endregion // PRIVATE_MEMBER_VARIABLES
	
	
	
	#region EXPOSED_PUBLIC_VARIABLES
	
	/// <summary>
	/// can be set in the Unity inspector to reference a ImageTargetBehaviour that is used for augmentations of new cloud reco results.
	/// </summary>
	public ImageTargetBehaviour ImageTargetTemplate;
	
	#endregion
	
	#region UNTIY_MONOBEHAVIOUR_METHODS
	
	/// <summary>
	/// register for events at the CloudRecoBehaviour
	/// </summary>
	void Start()
	{
		// register this event handler at the cloud reco behaviour
		CloudRecoBehaviour CloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();
		if (CloudRecoBehaviour)
		{
			CloudRecoBehaviour.RegisterEventHandler(this);
		}
		
		// remember cloudRecoBehaviour for later
		mCloudRecoBehaviour = CloudRecoBehaviour;
		
		/*
        teapot = GameObject.Find("teapot");
        dragon = GameObject.Find("Dragon");
         
        Hide( teapot );
        Hide( dragon );
        */
		
		//teapot.SetActive( false );
		//dragon.SetActive( false );
		
	}
	
	#endregion // UNTIY_MONOBEHAVIOUR_METHODS
	
	
	#region ICloudRecoEventHandler_IMPLEMENTATION
	
	/// <summary>
	/// called when TargetFinder has been initialized successfully
	/// </summary>
	public void OnInitialized()
	{
        Debug.Log("Cloud Reco initialized");
		// get a reference to the Image Tracker, remember it
		ObjectTracker imageTracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
		//mImageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);
	}
	
	/// <summary>
	/// visualize initialization errors
	/// </summary>
	public void OnInitError(TargetFinder.InitState initError)
	{
        Debug.Log("Cloud Reco init error " + initError.ToString());
	}
	
	/// <summary>
	/// visualize update errors
	/// </summary>
	public void OnUpdateError(TargetFinder.UpdateState updateError)
	{
        Debug.Log("Cloud Reco update error " + updateError.ToString());
	}
	
	/// <summary>
	/// when we start scanning, unregister Trackable from the ImageTargetTemplate, then delete all trackables
	/// </summary>
	public void OnStateChanged(bool scanning)
	{
	}
	
	/// <summary>
	/// Handles new search results
	/// </summary>
	/// <param name="targetSearchResult"></param>
	public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
	{
		// duplicate the referenced image target
		GameObject newImageTarget = Instantiate(ImageTargetTemplate.gameObject) as GameObject;
		
		GameObject augmentation = null;
		
		string model_name = targetSearchResult.MetaData;
		
		
		if( augmentation != null )
			augmentation.transform.parent = newImageTarget.transform;


		// enable the new result with the same ImageTargetBehaviour:

        //ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();

        //ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, newImageTarget);

        ImageTargetBehaviour imageTargetBehaviour =
                (ImageTargetBehaviour)mImageTracker.TargetFinder.EnableTracking(
                    targetSearchResult, newImageTarget);

		Debug.Log("Metadata value is " + model_name );
		
		
		
		switch( model_name ){
			
		case "ana" :
			
			Destroy( imageTargetBehaviour.gameObject.transform.Find("ana").gameObject );
			
			break;
			
		case "ironman" :
			
			Destroy( imageTargetBehaviour.gameObject.transform.Find("ironman").gameObject );
			
			break;
			
		}
		
		if (imageTargetBehaviour != null)
		{
			// stop the target finder
			mCloudRecoBehaviour.CloudRecoEnabled = false;
		}
	}
	
	
	
	#endregion // ICloudRecoEventHandler_IMPLEMENTATION
	
	private void Hide( GameObject model ){
		
		Debug.Log( "Hiding "+ model.name );
		
		Renderer[] rendererComponents = model.GetComponentsInChildren<Renderer>();
		Collider[] colliderComponents = model.GetComponentsInChildren<Collider>();
		
		// Disable rendering:
		foreach (Renderer component in rendererComponents)
		{
			component.enabled = false;
		}
		
		// Disable colliders:
		foreach (Collider component in colliderComponents)
		{
			component.enabled = false;
		}
		
		//Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
	}

}

 

AttachmentSize
Image icon chips.png773.94 KB
Image icon tarmac.png771.89 KB

Multiple Image Target (Cloud Recognition)

September 2, 2018 - 8:18pm #7

Hello Vuforia Support

I want to recognize multiple targets at the same time by using  Vuforia Cloud.

Is this possible now?

Thanks

 

Multiple Image Target (Cloud Recognition)

January 19, 2018 - 8:09am #6

Hello Equentvuforia,

This is still the case with Cloud Reco.

Apologies for the inconvenience,

Vuforia Support

Multiple Image Target (Cloud Recognition)

January 18, 2018 - 2:39am #5

Hello, is changed something about this feature?

Is still not possibile to use multiple targets at the same time with cloud recognition?

Multiple Image Target (Cloud Recognition)

July 20, 2016 - 3:53am #4

I have the same problem too. Dose vuforia team members have any solutions?

Multiple Image Target (Cloud Recognition)

June 6, 2016 - 11:18am #3

Hi,

Does Vuforia planned anything about this ? The first post about multiple image targets reco is now 4 years old, is any improvement coming ? (or maybe it is a paid feature ?)

Thanks for any informations about this !

Multiple Image Target (Cloud Recognition)

March 30, 2016 - 2:39pm #2
Log in or register to post comments