Log in or register to post comments

TargetFinder error

March 24, 2019 - 9:15pm #1

I`m building an app using cloud recognition to play an URL video.

Console gives me these two errors, I think it`s an error with the new update. can someone please help.

**************************************************************************************************************************************

Unsupported TargetFinder type provided

UnityEngine.Debug:LogError(Object)

Vuforia.ObjectTracker:GetTargetFinder()

SimpleCloudHandler:OnNewSearchResult(TargetSearchResult) (at Assets/SimpleCloudHandler.cs:49)

Vuforia.ObjectRecoBehaviour:Update()

*******************************************************************************************************************************************************

NullReferenceException: Object reference not set to an instance of an object

SimpleCloudHandler.OnNewSearchResult (Vuforia.TargetFinder+TargetSearchResult targetSearchResult) (at Assets/SimpleCloudHandler.cs:49)

Vuforia.ObjectRecoBehaviour.Update () (at <d17b882acd8f40e982e2cd7d407d5aeb>:0

*********************************************************************************************************************************************************************

*****this is my OnNewSearchResult,

public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)

    {

        TargetFinder.CloudRecoSearchResult cloudRecoSearchResult = (TargetFinder.CloudRecoSearchResult)targetSearchResult;

        Debug.Log("CloudReco: new search result available: " + targetSearchResult.TargetName);

        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;

    }

TargetFinder error

September 19, 2019 - 7:20am #4

That is the exact problem i am having, i m trying to implement your suggestions but i still cant find to resolve it.. and i  think i m doing it wrong somewhere.  because the if part is very down my initial imagetarget list (the first part of the solution). Can you help me by having a look on my script? 

TargetFinder error

August 24, 2019 - 10:10am #3

I had the same problem, it almost drove me mad but finally i figure it out.

The problem is with this line 

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

You can try switch it into these lines:

IEnumerable<TargetFinder> targetfinders = tracker.GetTargetFinders();

            List<TargetFinder> convertedTargetFinders = targetfinders.ToList();

            if (convertedTargetFinders.Count() > 0)

            {

                ImageTargetBehaviour ImageTargetBehaviour = (ImageTargetBehaviour)convertedTargetFinders[0].EnableTracking(targetSearchResult, newImageTarget);

            }

 

dont forget to add this to use .ToList() method:

Using System.Linq;

TargetFinder error

March 27, 2019 - 2:02am #2

Really hard to debug this for you with the lack of context. From the code you posted, what strikes me as weird is why you check for null of the behaviour (if(behaviour)) but above you access behaviour.gameObject without a null check.

Also, not relevant to this post, but you can remove all of this: augmentation = null, followed by if(augmentation != null) {...}

Log in or register to post comments