Log in or register to post comments

Cloud Recognition Tutorial Scripts

June 24, 2013 - 8:00am #1

Hi Moderators, 

Thank you for posting a new tutorial on creating Cloud Recognition Apps in Unity. My question is regarding the Simple Cloud Reco Event Handler script which replaces the existing, more complicated Event Handler in the tutorial. It seems similar, but a bit different from the Simple Event Handler script described in this post: https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/please-explain-step-step-how-use-vuforia-cloud , which may explain some of the problems that I'm having following the tutorial. Would it be possible to include the script in a new package for the existing Cloud Reco sample, or to provide a package for the tutorial project to run through? 

When I tried to follow the tutorial, I managed to make an app which recognized cloud targets and their metadata, but somehow the script for closing out of the augmentation and reintitiating scanning didn't make it to the app. I'm not sure if this is a product of the wrong event handler, or if this has to do with the way I built out of Unity.

Cloud Recognition Tutorial Scripts

March 21, 2016 - 9:15pm #7

would it be possible to also post the meta file that works with the dragon and teapot? I realize now that the way I'm entering the switch case should be corrrect but maybe my formatting in the metafile isn't working.

 

 

Cloud Recognition Tutorial Scripts

March 14, 2016 - 7:40am #6

Hi Rickb ,

I am new in vuforia unity. I want video play in cloud recoganization target. Please guide me for this task. I am using latest vuforia sdk 5-5-9. Give any tutorial url or sample project. In cloud recoganization Sample scene only contains 3d object. Please guide me..

 

Cloud Recognition Tutorial Scripts

July 24, 2013 - 3:41pm #5

Thanks David, I just realize that the prefab called CloudRecoTarget part of example projet is missing. I tried to create from the standard ImageTarget. I desabled the DefaultTrackbleEventHandle as it seems to be part of the prefab. I compiled the app on ipad but my model don' t desappear when the tracker is away. I don't know if i have to desable the models that i put under CloudRecognition structure. Thanks Richard

Cloud Recognition Tutorial Scripts

July 24, 2013 - 1:36pm #4

Here you go - copy this to a file and name that file SimpleCloudRecoEventHandler.cs

 

/*==============================================================================
Copyright (c) 2012 QUALCOMM Austria Research Center GmbH.
All Rights Reserved.
Qualcomm Confidential and Proprietary
==============================================================================*/

using System;
using UnityEngine;

/// <summary>
/// This MonoBehaviour implements the Cloud Reco Event handling for this sample.
/// It registers itself at the CloudRecoBehaviour and is notified of new search results.
/// </summary>
public class SimpleCloudRecoEventHandler : MonoBehaviour, ICloudRecoEventHandler
{
    #region PRIVATE_MEMBER_VARIABLES

    // CloudRecoBehaviour reference to avoid lookups
    private CloudRecoBehaviour mCloudRecoBehaviour;
    // ImageTracker reference to avoid lookups
    private ImageTracker mImageTracker;
	
	private GameObject dragon, teapot;

    #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()
    {
        // get a reference to the Image Tracker, remember it
        mImageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);
    }

    /// <summary>
    /// visualize initialization errors
    /// </summary>
    public void OnInitError(TargetFinder.InitState initError)
    {
    }

    /// <summary>
    /// visualize update errors
    /// </summary>
    public void OnUpdateError(TargetFinder.UpdateState updateError)
    {
    }

    /// <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:
        ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, newImageTarget);
		
		Debug.Log("Metadata value is " + model_name );
		
		
		
		switch( model_name ){
		 	
			case "teapot" :
			    
				Destroy( imageTargetBehaviour.gameObject.transform.Find("Dragon").gameObject );
			   
				break;
			
			case "dragon" :
			    
				Destroy( imageTargetBehaviour.gameObject.transform.Find("teapot").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");
	}



}

 

Cloud Recognition Tutorial Scripts

July 24, 2013 - 12:48pm #3

Hi, i dowloaded the Tutorial package that is linked to the ''Creating Cloud Recognition Apps in Unity....'' but down to two third of the tutorial the speaker mentioned that he replaced the CloudRecoEventHandler.cs by the SimpleCloudRecoEventHandler.cs which should been found under Asset/Script directory. Would it be possible to let me know where can i find this because it is not in the package that was out on line. Thanks Richard

Cloud Recognition Tutorial Scripts

June 29, 2013 - 12:14pm #2

 Would it be possible to include the script in a new package for the existing Cloud Reco sample, or to provide a package for the tutorial project to run through? 

Thank you for the suggestion.

We are considering this possibility for the future, but I cannot give any confirmation at the moment.

 

Log in or register to post comments