Log in or register to post comments

create cloud recognition sample project

July 9, 2013 - 10:52am #1

I'm has been follow the instruction in tutorial video, but i cannot find simplecloudrecoeventhandler.cs file. Where can i get simplecloudrecoeventhandler.cs file like in tutorial video? I'm using unity.

create cloud recognition sample project

August 16, 2016 - 12:24am #6

The previously posted code as well as the whole sample project is 3 years old and by now depricated.

As far as I know 'ImageTracker' is now 'ObjectTracker' but I think just renaming won't do the trick.

 

You will have to look for a more recent sample project.

create cloud recognition sample project

July 14, 2016 - 6:50am #5

Hi i get this following error in SimpleCloudRecoEventHandler.cs:

The type or namespace name `ImageTracker' could not be found

I added 'using Vuforia'

But still i am getting this error. How to solve this?

 

create cloud recognition sample project

July 10, 2013 - 10:26am #4

Where do you call the function Hide( GameObject model) ??

create cloud recognition sample project

July 9, 2013 - 11:24am #3

thank you, i can continue my sample code

create cloud recognition sample project

July 9, 2013 - 11:04am #2

Copy the following 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;
		
    }

    #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");
	}



}

 

Log in or register to post comments