Log in or register to post comments

VWS from unity

November 3, 2013 - 7:37am #6

Hi,

 

I am currently working with Vuforia and Unity for my thesis. I am planning to add new marker to vuforia cloud reco during runtime of my application. However, I am not very sure how this works. from what I learn is I need to use Vuforia Web Service to do this. Please do tell me if I am right or not:

Concept 1:

1. I need to generate the PNG from my unity Application

2. Then I have to send it to my PHP web application

3. Then my PHP web application will submit the PNG to Vuforia Cloud Reco using VWS

 

Concept 2:

1. I need to generate the PNG from my unity Application

2. Then my unity application will submit it directly to Vuforia Cloud Reco using VWS

 

Which one is correct? and If possible please give me a link to a tutorial about this on unity (If there are any). I have looked for this but I only found discussion about other people's project, not a tutorial. I am very new to this (Vuforia + unity) and I got only until January to finish my thesis. Any help is appreciated.

 

Thank you.

VWS from unity

November 3, 2013 - 9:45am #5

The 1st concept is the recommended implementation, so that you can manage target submissions. 

Here is a tutorial on working w/ Cloud Recognition in Unity - https://developer.vuforia.com/resources/tutorials , and there is sample code and API examples on this page - https://developer.vuforia.com/resources/dev-guide/managing-targets-cloud-database-using-developer-api

This article demonstrates how to capture a screen shot in Unity - https://developer.vuforia.com/resources/dev-guide/unity-screenshots , and this one deals with how to access the camera image directly - https://developer.vuforia.com/resources/dev-guide/unity-camera-image-access

VWS from unity

November 4, 2013 - 5:46am #4

Thank you for the quick reply. I will try this out and post again if something is not clear enough

VWS from unity

November 4, 2013 - 7:54am #3
using UnityEngine;
using System.Collections;

public class SimpleCREventHandler : MonoBehaviour, ICloudRecoEventHandler {
	
	#region PRIVATE_MEMBER_VARIABLES
	
	//CloudRecoBehaviour reference to avoid lookups
	private CloudRecoBehaviour mCloudRecoBehaviour;
	//ImageTracker reference to avoid lookups
	private ImageTracker mImageTracker;
	
	private GameObject jelly, ghost;
	
	#endregion // PRIVATE_MEMBER_VARIABLES
	
	
	#region EXPOSED_PUBLIC_VARIABLES
	
	public ImageTargetBehaviour ImageTargetTemplate;
	
	#endregion
	
	#region UNITY_MONOBEHAVIOUR_METHODS
	
	// Use this for initialization
	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;
		
		
        //jelly = GameObject.Find("Jelly");
        //ghost = GameObject.Find("BooBoo");
         
        //Hide( jelly );
        //Hide( ghost );
        
         
        //jelly.SetActive( false );
        //ghost.SetActive( false );
		
	}
	
	#endregion // UNITY_MONOBEHAVIOUR_METHODS
	
	#region ICloudRecoEventHandler_IMPLEMENTATION
	
	public void OnInitialized()
	{
		//get a reference to the Image Tracker and remember it
		mImageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);
	}
	
	 public void OnInitError(TargetFinder.InitState initError)
    {
    }
 
    public void OnUpdateError(TargetFinder.UpdateState updateError)
    {
    }
 
    public void OnStateChanged(bool scanning)
    {
    }
 	
	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 "ghost" :
			Destroy(imageTargetBehaviour.gameObject.transform.Find("Jelly").gameObject);
			break;
			
		case "jelly" :
			Destroy(imageTargetBehaviour.gameObject.transform.Find("BooBoo").gameObject);
			break;
		}
		
		if (imageTargetBehaviour != null)
		{
			//stop the target finder
			mCloudRecoBehaviour.CloudRecoEnabled = false;
		}
	}
	
	// Update is called once per frame
	void Update () {
		
		if (Input.GetKeyDown ("escape")) {
			Application.Quit ();
		}
	
	}
	#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");
    }
}

So I had this problem, I followed the tutorial, then it can recognize the marker and draw the object. after that, I added the script to enable quiting from application using back arrow(Android) now it cannot recognize the marker. I followed the tutorial all the same, just changed the name a bit here and there. is there anything wrong with my code? or is it the internet connection? I assume this application uses internet connection to right?

VWS from unity

October 14, 2015 - 8:53am #2

Hi, @DavidBeard.

 

All the useful links that you provided are now broken. It would be great if you could update them.

 

Thank you very much.

 

Regards!

Log in or register to post comments