Log in or register to post comments

Need help cloud recognitipn

March 1, 2021 - 6:31pm #1

Hello, I have a problem there is a script that used to use cloud recognition,it scanned photos and turned them into videos using meta data.Now, after a long time, the script has stopped working,or rather, the script is working ,and the application is immediately turned off at startup.Please help me.Here is the code itself.

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Vuforia;

using UnityEngine.Video;

using UnityEngine.UI;

public class SimpleCloudHandler : MonoBehaviour, IObjectRecoEventHandler

{

    public ImageTargetBehaviour behaviour;

    CloudRecoBehaviour cloud;

    public GameObject mainPlayer;

    public Text ErrorTxt;

    string errorTitle, errorMsg;

    public void OnInitError(TargetFinder.InitState initError) { }

    public void OnInitialized(TargetFinder targetFinder) { }

    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)

    {

        TargetFinder.CloudRecoSearchResult cloudRecoSearchResult =

            (TargetFinder.CloudRecoSearchResult)targetSearchResult;

        GameObject newImageTarget = Instantiate(behaviour.gameObject) as GameObject;

        mainPlayer = newImageTarget.transform.GetChild(0).gameObject;

        GameObject augmentation = null;

        if (augmentation != null)

        {

            augmentation.transform.SetParent(newImageTarget.transform);

        }

        if (behaviour)

        {

            ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();

            ImageTargetBehaviour imageTargetBehaviour = (ImageTargetBehaviour)tracker.GetTargetFinder<TargetFinder>().EnableTracking(targetSearchResult, newImageTarget);

        }

        string URL = cloudRecoSearchResult.MetaData;

        mainPlayer.GetComponent<VideoPlayer>().url = URL.Trim();

        cloud.CloudRecoEnabled = true;

    }

    public void OnStateChanged(bool scanning)

    {

        if (scanning)

        {

            ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();

            tracker.GetTargetFinder<TargetFinder>().ClearTrackables(false);

        }

    }

    public void OnUpdateError(TargetFinder.UpdateState updateError) { }

    // Start is called before the first frame update

    void Start()

    {

        CloudRecoBehaviour cloudReco = GetComponent<CloudRecoBehaviour>();

        if (cloudReco)

        {

            cloudReco.RegisterEventHandler(this);

        }

        cloud = cloudReco;

        mainPlayer = GameObject.Find("Player");

        Hide(mainPlayer);

    }

    void Hide(GameObject ob)

    {

        Renderer[] rends = ob.GetComponentsInChildren<Renderer>();

        Collider[] cols = ob.GetComponentsInChildren<Collider>();

        foreach (var item in rends)

        {

            item.enabled = false;

        }

        foreach (var item in cols)

            item.enabled = false;

    }

}

Log in or register to post comments