0

I am in the process of development of an augmented reality app. I would like to put in the app multiple image targets e multiple 3d models, connecting specific images targets with specific 3D models. For that I would like to use the assetbundle to store the 3D models in a server and the cloudrecognition to store the images targets. I am having some difficulties on that. What is the better way to do that? I can't even connect the 3D model (in the assetBundle) in a normal image target, how can I connect it to an image target that is in the cloud?

Kalle Richter
  • 8,008
  • 26
  • 77
  • 177

2 Answers2

1

I use this script attached to the cloudreco:

using Vuforia;
using UnityEngine;

public class SimpleCloudHandler : MonoBehaviour, ICloudRecoEventHandler
{
    private CloudRecoBehaviour mCloudRecoBehaviour;
    private bool mIsScanning = false;
    private string mTargetMetadata = "";
    // Use this for initialization
    void Start()
    {
        // register this event handler at the cloud reco behaviour
        mCloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();

        if (mCloudRecoBehaviour)
        {
            mCloudRecoBehaviour.RegisterEventHandler(this);
        }
    }

    public void OnInitialized()
    {
        Debug.Log("Cloud Reco initialized");
    }
    public void OnInitError(TargetFinder.InitState initError)
    {
        Debug.Log("Cloud Reco init error " + initError.ToString());
    }
    public void OnUpdateError(TargetFinder.UpdateState updateError)
    {
        Debug.Log("Cloud Reco update error " + updateError.ToString());
    }

    public void OnStateChanged(bool scanning)
    {
        mIsScanning = scanning;
        if (scanning)
        {
            // clear all known trackables
            var tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
            tracker.TargetFinder.ClearTrackables(false);
        }
    }
    // Here we handle a cloud target recognition event
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
        // do something with the target metadata
        NewMethod(targetSearchResult);
        // stop the target finder (i.e. stop scanning the cloud)
        mCloudRecoBehaviour.CloudRecoEnabled = false;
    }

    private void NewMethod(TargetFinder.TargetSearchResult targetSearchResult)
    {
        mTargetMetadata = targetSearchResult.MetaData;
    }

    void OnGUI()
    {
        // Display current 'scanning' status
        GUI.Box(new Rect(100, 100, 200, 50), mIsScanning ? "Scanning" : "Not scanning");
        // Display metadata of latest detected cloud-target
        GUI.Box(new Rect(100, 200, 200, 50), "Metadata: " + mTargetMetadata);
        // If not scanning, show button
        // so that user can restart cloud scanning
        if (!mIsScanning)
        {
            if (GUI.Button(new Rect(100, 300, 200, 50), "Restart Scanning"))
            {
                // Restart TargetFinder
                mCloudRecoBehaviour.CloudRecoEnabled = true;
            }
        }
    }
}

And appears this message: We got a target metadata: https://drive.google.com/uc?authuser=0&id=1twVZENr-J9gsw4PwLeelA1quAIgxsLUN&export=download UnityEngine.Debug:Log(Object) SimpleCloudHandler:OnNewSearchResult(TargetSearchResult) (at Assets/SimpleCloudHandler.cs:49) Vuforia.CloudRecoBehaviour:Update()

0

1) https://library.vuforia.com/articles/Training/Cloud-Recognition-Guide.html#metadata

2)https://library.vuforia.com/articles/Solution/Working-with-Vuforia-and-Unity.html#using-asset-bundles

Go through this links and still it not works post your script or error.

darsh
  • 51
  • 1
  • Thank you! I am trying to put an URL (with the link of the dowload of the 3d model) in the metadata, but i think the camera isn't reading the metadata corretly because when the imagetarget is recognize, just the text of link (ex: drive.google.com/…) appears, and not the model. Is that a script, right? I don't know which is. – Michelle Fernandes May 21 '18 at 16:38
  • I'm new in Unity, and i have facing some dificulties on that. I'm searching this for days, but sometimes, i don't know how to apply some methods in scripts and also where to attach these scripts. So, do i have to attached this script (that will handle with the recognition of the 3D model) on the image target? or on the cloudreco? – Michelle Fernandes May 21 '18 at 16:39