Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cloud Reco issue with tutorial

Discussion in 'Vuforia' started by Bird_LYKKE, May 30, 2018.

  1. Bird_LYKKE

    Bird_LYKKE

    Joined:
    Jul 26, 2017
    Posts:
    15
    I use unity 2018.1.0b13 and follow this link https://library.vuforia.com/content...lution/How-To-Implement-Cloud-Reco.html#unity
    cloud reco work fine but when scaned target1 it can not recognize target2 and same issue happen when try to scan target2 before target1

    public class SimpleCloudHandler : MonoBehaviour, ICloudRecoEventHandler
    {
    public CloudRecoBehaviour mCloudRecoBehaviour;
    private bool mIsScanning = false;
    private string mTargetMetadata = "";
    public MarkerDetectionSignal markerDetectionSignal;

    public ImageTargetBehaviour ImageTargetTemplate;

    public void OnInitError(TargetFinder.InitState initError)
    {
    Debug.Log("Cloud Reco init error " + initError.ToString());
    }

    public void OnInitialized()
    {
    Debug.Log("Cloud Reco initialized");
    }


    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {
    // do something with the target metadata
    mTargetMetadata = targetSearchResult.MetaData;
    Debug.Log(mTargetMetadata);

    if (mTargetMetadata.Length > 1)
    {
    string[] spiltSrt = mTargetMetadata.Split(',');
    markerDetectionSignal.fantasyID = new int[spiltSrt.Length];
    for (int i = 0; i < markerDetectionSignal.fantasyID.Length;i++)
    {
    markerDetectionSignal.fantasyID = int.Parse(spiltSrt);
    }

    }
    else
    {
    markerDetectionSignal.fantasyID = new int[1];
    markerDetectionSignal.fantasyID[0] = int.Parse(mTargetMetadata);
    }

    ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
    ImageTargetBehaviour imageTargetBehaviour =
    (ImageTargetBehaviour)tracker.TargetFinder.EnableTracking(
    targetSearchResult, ImageTargetTemplate.gameObject);

    // stop the target finder (i.e. stop scanning the cloud)
    mCloudRecoBehaviour.CloudRecoEnabled = false;
    }

    public void OnStateChanged(bool scanning)
    {
    mIsScanning = scanning;
    if (scanning)
    {
    // clear all known trackables
    var tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
    tracker.TargetFinder.ClearTrackables(false);
    }
    }

    public void OnUpdateError(TargetFinder.UpdateState updateError)
    {
    Debug.Log("Cloud Reco update error " + updateError.ToString());
    }

    // Use this for initialization
    void Start()
    {
    // register this event handler at the cloud reco behaviour
    mCloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();

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

    Bird_LYKKE

    Joined:
    Jul 26, 2017
    Posts:
    15
    And Also get these error

    Exception in callback: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> UnityEngine.MissingReferenceException: The object of type 'ImageTargetBehaviour' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    at (wrapper managed-to-native) UnityEngine.Behaviour:get_enabled ()
    at Vuforia.StateManager.UpdateTrackablePoses (UnityEngine.Transform arCameraTransform, .TrackableResultData[] trackableResultDataArray, .VuMarkTargetResultData[] vuMarkResultDataArray, TrackableIdPair originTrackableID, Int32 frameIndex, Boolean updateTrackableStates) [0x00000] in <filename unknown>:0
    at Vuforia.StateManager.UpdateTrackablePoses (UnityEngine.Transform arCameraTransform, .TrackableResultData[] trackableResultDataArray, .VuMarkTargetResultData[] vuMarkResultDataArray, TrackableIdPair originTrackableID, Int32 frameIndex) [0x00000] in <filename unknown>:0
    at Vuforia.VuforiaManager.UpdateTrackers (FrameState frameState) [0x00000] in <filename unknown>:0
    at Vuforia.VuforiaManager.Update (ScreenOrientation counterRotation, System.Boolean& reapplyOldState) [0x00000] in <filename unknown>:0
    at Vuforia.VuforiaARController.UpdateStatePrivate (Boolean forceUpdate, Boolean reapplyOldState) [0x00000] in <filename unknown>:0
    at Vuforia.VuforiaARController.UpdateState (Boolean forceUpdate, Boolean reapplyOldState) [0x00000] in <filename unknown>:0
    at Vuforia.DigitalEyewearARController.Update () [0x00000] in <filename unknown>:0
    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000d0] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222
    --- End of inner exception stack trace ---
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000eb] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232
    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115
    at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000b9] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:443
    at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00018] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MulticastDelegate.cs:71
    at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:415
    at Vuforia.DelegateHelper.InvokeDelegate (System.Delegate action, System.Object[] args) [0x00000] in <filename unknown>:0
    UnityEngine.Debug:LogError(Object)
    Vuforia.DelegateHelper:InvokeDelegate(Delegate, Object[])
    Vuforia.DelegateHelper:InvokeWithExceptionHandling(Action)
    Vuforia.VuforiaBehaviour:Update()
     
  3. ARConnex

    ARConnex

    Joined:
    Aug 19, 2012
    Posts:
    24
    Hey Bird_LYKKE
    Any luck resolving a workaround for this one ?

    Same deal here, cloud reco 1st ones a charm - between loosing the target and reengaging the tracker, I get the Same "Exception in callback: System.Reflection..... " error spaming the debug screen.
    2018.2 with Vuforia 7.1.35 and now with 2018.1.8 /Vuforia 7.1.35 same
    Your code looks very similar to mine and seems correct , i had no trouble with mine in 2017.2 Vu 6.5 so not sure.

    Tried a 7.2 update and it failed on the install (mac). so will see if that has any effect on this error , once I figure out the magic sauce to install it.

    2017.2 Vu 6.5 work on both android and iOS - (yet webcam seemed to black after the last iOS update.)
     
  4. digitalillusionsra

    digitalillusionsra

    Joined:
    Jul 25, 2017
    Posts:
    1
    Facing the same issue here.
     
  5. ARConnex

    ARConnex

    Joined:
    Aug 19, 2012
    Posts:
    24
    OK so - some progress.

    my original cloudreco handler (working in 6.5) did all the work by inheriting the ITrackableEventHandler
    public class CloudRecoTrackableEventHandler : MonoBehaviour, ITrackableEventHandler

    The setup after 7.2 and installing the Core samples the cloud reco wants to inherit and extend the DefaultTrackableEventHandler (given it may change on updates)

    so changed CloudRecoTrackableEventHandler to extend the DefaultTrackableEventHandler
    public class CloudRecoTrackableEventHandler : DefaultTrackableEventHandler

    in my case It was registering the handler twice. so removed from my CloudRecoTrackableEventHandler
    the code relating to

    mTrackableBehaviour.RegisterTrackableEventHandler(this);
    and the
    OnTrackableStateChanged(.......

    and changed

    public void OnTrackingFound() and public void OnTrackingLost()
    to
    protected override void OnTrackingFound() and protected override void OnTrackinglost()

    which cleared this error for me.
    Exception in callback: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
    at Vuforia.StateManager.UpdateTrackablePoses (Vec....

    You can add any code needed to your protected override void OnTrackingFound() and Lost calls.
    -
    my 7.2 install issue was because the installer needs to be in the unity folder - plus I had renamed the unity folder and app to Unity2018-2 so renamed them back to Unity for the install.
    have not set up the unityhub...
    -
    Xcode 9.3 had issues and Xcode 9.2 worked yet lacked the ability to target 11.3 up so you can pull the 11.3 11.41 device profiles and add them to the same path in 9.2
    /Applications/Xcode93.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
    9.2 now works 7.1 - have yet to run 7.2 (imagine 9.3 may work fine now)
    -
    learned below yet have not tried
    lastly in Xcode you need to manually set the Vuforia version to 1 in their plist else the app will not work with i-tunes testflight.

    at least the dark ages of the black webcam screen seem to have resolved in 7.2 -

    have limited c# experience but hope it helps
     
  6. paweleck

    paweleck

    Joined:
    Jul 24, 2017
    Posts:
    7
    Ive got the same porlbem as Bird_LYKKE. Any idea how to deal with it?
     
  7. Rohan9841

    Rohan9841

    Joined:
    Jun 15, 2018
    Posts:
    2
    Hi, Can you please explain step by step on how you solved the freezing problem? I followed the steps that you mentioned but couldn't solve the problem. Maybe I didn't understand a few things that you've said.