Multiple targets in Unity VisualSearch

November 11, 2012 - 2:36am #1

Hello, 

I've uploaded 2 different image targets to the server and I'm trying to make the unity app recognize them and assign a different model to each one.

How do I do that?

 

-Nathan

Multiple targets in Unity VisualSearch

November 14, 2012 - 1:03pm #10

Let me check on the status of the update so that you're not wasting your effort. 

For 2.0.18 you'd implement this in the EnableNewResult method of the CloudRecoBehaviour - see line 203 for instructions.

Multiple targets in Unity VisualSearch

November 14, 2012 - 8:54am #9

Hey Nalin & David

As far as I understand (from Carla and Roy) 2.0.21 isn't available to developers yet.

Could you rephrase your answers with 2.0.18 in mind?

Thanks
Nathan

 

Multiple targets in Unity VisualSearch

November 14, 2012 - 2:40am #8

Hi Nathan,

It could be that you are using an outdated version.

2.0.21 onwards have a CloudReco sample, and here if you click on scene 4 (Vuforia-4-CloudRecognition) then it should show the key objects in the hierarchy, one of which is a prefab called CloudRecognition.  If you click on this then the inspector will show various attributes including Access/Secret keys, and also teh Cloud Reco Event Handler script is attached to this.

HTH

N

Multiple targets in Unity VisualSearch

November 14, 2012 - 1:21am #7

Hey David,

I do not see any file called CloudRecoEventHandler.cs, nor do I see ICloudRecoEventHandler used anywhere in the code, could it be that I'm using an outdated version?

Thanks,
Nathan

Multiple targets in Unity VisualSearch

November 13, 2012 - 10:25am #6

The Cloud Reco Event Handler is already a component of the CloudRecogntion prefab, so you don't need to add anything new, simply modify CloudRecoEventHandler.cs. You can also develop your own custom event handler by implementing the ICloudRecoEventHandler interface, and inheriting from MonoBehaviour.

 

How can I accomplish that in the designer without any code?

 Create a GameObject, give it a name, and add your augmentation as a child of that object. You can then pass this to the EnableTracking method by name or reference - to obtain a reference, you can use GameObject.Find( "name" );

Multiple targets in Unity VisualSearch

November 13, 2012 - 12:39am #5

Thanks Alessandro,
I see what you're talking about.

David: Can you tell me which script file I need to add the handler to?

Multiple targets in Unity VisualSearch

November 12, 2012 - 4:43am #4

Hi Nathan, just a side note:

if you use the Cloud Reco, your typical use case would be to have a large number of image targets uploaded on the cloud;

but if you plan to have pre-defined 3D models for your augmentation, you're probably not going to have that large number of models, as anyway you won't be able to package all of them with your app.

So, just be aware of that, as for a limited number of targets (and their corresponding augmenting 3D models) you would not need then Cloud Reco (you could use a standard DataSet).

This is just a side note, I'll let David answer you on the how-to art.

 

 

Multiple targets in Unity VisualSearch

November 12, 2012 - 1:53am #3

Thanks for the snippets :)

I was wondering about pre-authoring the augemntations within Unity.

How can I accomplish that in the designer without any code?

 

Thanks
Nathan

Multiple targets in Unity VisualSearch

November 11, 2012 - 4:47pm #2

You can accomplish that by customizing your search result event handling within the CloudRecoEventHandler's OnNewSearchResult method.

 

public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)

    {

        // This code demonstrates how to use an already set up ImageTargetBehaviour for the search result.

        // Depending on your application, it can make more sense to load some content here dynamically (e.g. from the meta data)

        // and attach it to a newly created game object.

        // Vuforia will return a new object with the right script automatically if you use

        // TargetFinder.EnableTracking(TargetSearchResult result, string gameObjectName)

 

//Check if the metadata isn't null

if(targetSearchResult.MetaData == null)

{

return;

}

 

        // enable the new result with the duplicated ImageTargetBehaviour: - OR provide a custom defined object by name or reference.

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

 

        if (imageTargetBehaviour != null)

        {

            // stop the target finder

            mCloudRecoBehaviour.CloudRecoEnabled = false;

 

// Calls the TargetCreated Method of the SceneManager object to start loading

// the BookData from the JSON

            mContentManager.TargetCreated(targetSearchResult.MetaData);

        }

    }

 

------

You can pre-author the augmentations for these objects, or add them at runtime by making the object the parent of the augmentation, using transform.parent.

Log in or register to post comments