Search Unity

Vuforia Cloud Reco Assistance

Discussion in 'AR' started by GeneralDollar, Jul 8, 2018.

  1. GeneralDollar

    GeneralDollar

    Joined:
    Mar 24, 2018
    Posts:
    27
    I realize asking for assistance with Vuforia should probably be done through Vuforia's website, however they never answer a single question related to Cloud Reco from pretty much anyone who has ever asked for assistance.

    My issue is the inability to have a successful project utilizing Vuforia cloud recognition. I have followed their "How To" step by step, but nothing ever happens. It seems that the entire SimpleCloudHandler script stops at the OnStateChanged method for me.

    The Vuforia Youtube tutorial on cloud reco is useless when they don't offer any resources to the source files used, and the "teacher" decides to use his own custom script and does not show how he created it.

    Could someone please help walk me, and the rest of the users struggling to implement Vuforia Cloud Recognition, through a step by step process of successfully recognizing at least just one single cloud image.

    I am a beginner, but I have been figuring out Unity and C# pretty quickly.

    I appreciate the time and help of anyone who replies!


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Vuforia;
    5.  
    6. public class SimpleCloudHandler : MonoBehaviour, ICloudRecoEventHandler
    7. {
    8.     public ImageTargetBehaviour ImageTargetTemplate;
    9.  
    10.     private CloudRecoBehaviour mCloudRecoBehaviour;
    11.     private bool mIsScanning = false;
    12.     private string mTargetMetadata = "";
    13.     // Use this for initialization
    14.     void Start()
    15.     {
    16.         // register this event handler at the cloud reco behaviour
    17.         mCloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();
    18.  
    19.         if (mCloudRecoBehaviour)
    20.         {
    21.             mCloudRecoBehaviour.RegisterEventHandler(this);
    22.         }
    23.     }
    24.  
    25.     public void OnInitialized()
    26.     {
    27.         Debug.Log("Cloud Reco initialized");
    28.     }
    29.     public void OnInitError(TargetFinder.InitState initError)
    30.     {
    31.         Debug.Log("Cloud Reco init error " + initError.ToString());
    32.     }
    33.     public void OnUpdateError(TargetFinder.UpdateState updateError)
    34.     {
    35.         Debug.Log("Cloud Reco update error " + updateError.ToString());
    36.     }
    37.  
    38.     public void OnStateChanged(bool scanning)
    39.     {
    40.         mIsScanning = scanning;
    41.         if (scanning)
    42.         {
    43.             // clear all known trackables
    44.             var tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
    45.             tracker.TargetFinder.ClearTrackables(false);
    46.         }
    47.     }
    48.  
    49.     // Here we handle a cloud target recognition event
    50.     public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    51.     {
    52.         // do something with the target metadata
    53.         mTargetMetadata = targetSearchResult.MetaData;
    54.         print(mTargetMetadata);
    55.         // stop the target finder (i.e. stop scanning the cloud)
    56.         mCloudRecoBehaviour.CloudRecoEnabled = false;
    57.  
    58.         // Build augmentation based on target
    59.         if (ImageTargetTemplate)
    60.         {
    61.             // enable the new result with the same ImageTargetBehaviour:
    62.             ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
    63.             ImageTargetBehaviour imageTargetBehaviour =
    64.              (ImageTargetBehaviour)tracker.TargetFinder.EnableTracking(
    65.              targetSearchResult, ImageTargetTemplate.gameObject);
    66.         }
    67.     }
    68.  
    69.     void OnGUI()
    70.     {
    71.         // Display current 'scanning' status
    72.         GUI.Box(new Rect(100, 100, 200, 50), mIsScanning ? "Scanning" : "Not scanning");
    73.         // Display metadata of latest detected cloud-target
    74.         GUI.Box(new Rect(100, 200, 200, 50), "Metadata: " + mTargetMetadata);
    75.         // If not scanning, show button
    76.         // so that user can restart cloud scanning
    77.         if (!mIsScanning)
    78.         {
    79.             if (GUI.Button(new Rect(100, 300, 200, 50), "Restart Scanning"))
    80.             {
    81.                 // Restart TargetFinder
    82.                 mCloudRecoBehaviour.CloudRecoEnabled = true;
    83.             }
    84.         }
    85.     }
    86. }
     
  2. Ehtisham_Farrukh

    Ehtisham_Farrukh

    Joined:
    Sep 17, 2019
    Posts:
    1
    can i just paste this code in my project? it will run or not? or i also have to add any meta file?