Log in or register to post comments

Recognice different image targets

November 9, 2015 - 8:37am #1

Hello

 

I'm really newbie in Vuforia Development and I need help with the cloud recognition of different image targets... The problem is that my application developed in Unity crashes when I decide to detect a different image target.

Specific Situation

I have 2 image targets (A PES 2015 xbox DVD cover and a Leap Motion box), When the camera sees one of those image targets it shows the prefab without any problem, the problem is when I try to detect the other image target after the first one, there my app crashes with the following error log:

 

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.
Vuforia.StateManagerImpl.UpdateCameraPose (UnityEngine.Transform cameraTransform, UnityEngine.Transform parentTransformToUpdate, .TrackableResultData[] trackableResultDataArray, Int32 originTrackableID)
Vuforia.VuforiaManagerImpl.UpdateTrackers (FrameState frameState)
Vuforia.VuforiaManagerImpl.Update (ScreenOrientation counterRotation, Boolean reapplyOldState)
Vuforia.VuforiaAbstractBehaviour.UpdateStatePrivate (Boolean forceUpdate, Boolean reapplyOldState)
Vuforia.VuforiaAbstractBehaviour.Update ()
 
The problem doesn't happens if I decide to stop the target finding and then restart it, but I don't want that happen, I want to detect multiple targets with different projections in runtime without pushing a button everytime I decide to scan a new ImageTarget.

Recognice different image targets

August 3, 2019 - 8:22am #3

Taurustar wrote:

if anyone has a problem with this same thing I found a solution.

The problem is fixed if you disable the cloud recognition, so I disable and re enable it everytime that the program calls the function OnNewSearchResult, and is just reset if the last result target is different of the new one... here is the code if anyone wants it.

 

public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult) {
		mTargetMetadata = targetSearchResult.MetaData.ToString ();
		Destroy(GameObject.Find(target+"(Clone)"));
		target = mTargetMetadata;
		
		// Build augmentation based on target
		if (lastTarget.UniqueTargetId != targetSearchResult.UniqueTargetId) {
			Debug.Log ("Disabling the  Clour Reco");
			mCloudRecoBehaviour.CloudRecoEnabled = false;
			StartCoroutine (WaitOneFrame ());
			mCloudRecoBehaviour.CloudRecoEnabled = true;
			Debug.Log ("Cloud Reco enabled");
		} else { Debug.Log ("Same Targets");}
		if (ImageTargetTemplate) {
			// enable the new result with the same ImageTargetBehaviour:
			ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker> ();
			ImageTargetBehaviour imageTargetBehaviour = 
			(ImageTargetBehaviour)tracker.TargetFinder.EnableTracking
					(targetSearchResult, ImageTargetTemplate.gameObject);
			StartCoroutine(makeIt());

		}

		lastTarget = targetSearchResult;

	}

 The Coroutine MakeIt() makes the search in the cloud database for the image target and displays the prefab in the asset bundle for the specific image target, and the couroutine of WaitOneFrame() makes a delay of 1 frame before to re enable the Cloud Recognition.

 

I'd really like to see your "Makeit()" Function if you'd be willing to share. I think it may help me solve this issue for myself.

Recognice different image targets

November 10, 2015 - 11:07am #2

if anyone has a problem with this same thing I found a solution.

The problem is fixed if you disable the cloud recognition, so I disable and re enable it everytime that the program calls the function OnNewSearchResult, and is just reset if the last result target is different of the new one... here is the code if anyone wants it.

 

public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult) {
		mTargetMetadata = targetSearchResult.MetaData.ToString ();
		Destroy(GameObject.Find(target+"(Clone)"));
		target = mTargetMetadata;
		
		// Build augmentation based on target
		if (lastTarget.UniqueTargetId != targetSearchResult.UniqueTargetId) {
			Debug.Log ("Disabling the  Clour Reco");
			mCloudRecoBehaviour.CloudRecoEnabled = false;
			StartCoroutine (WaitOneFrame ());
			mCloudRecoBehaviour.CloudRecoEnabled = true;
			Debug.Log ("Cloud Reco enabled");
		} else { Debug.Log ("Same Targets");}
		if (ImageTargetTemplate) {
			// enable the new result with the same ImageTargetBehaviour:
			ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker> ();
			ImageTargetBehaviour imageTargetBehaviour = 
			(ImageTargetBehaviour)tracker.TargetFinder.EnableTracking
					(targetSearchResult, ImageTargetTemplate.gameObject);
			StartCoroutine(makeIt());

		}

		lastTarget = targetSearchResult;

	}

 The Coroutine MakeIt() makes the search in the cloud database for the image target and displays the prefab in the asset bundle for the specific image target, and the couroutine of WaitOneFrame() makes a delay of 1 frame before to re enable the Cloud Recognition.

Log in or register to post comments