- Home /
Question by
matrix1395 · 10 hours ago ·
objectvuforiarecognition
Recognize position of the object
I am looking for an option to detect position object as soon as it stands in the right place - on a table, for example. I am using Vuforia engine here to recognize particular object but apart of doing object recognition, I would also like to do some position recognition on this object. This is what I have so far:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
using UnityEngine.UI;
public class TargetVector : MonoBehaviour
{
// public TrackableBehaviour.Status newStatus;
public TrackableBehaviour mTrackableBehaviour;
public Text positionTextX;
void Update()
{
OnTrackableStateChanged();
}
public void OnTrackableStateChanged()
{
Vector3 targetPosition = mTrackableBehaviour.transform.position /*- Camera.main.transform.position*/;
if (mTrackableBehaviour.CurrentStatus == TrackableBehaviour.Status.DETECTED ||
mTrackableBehaviour.CurrentStatus == TrackableBehaviour.Status.TRACKED)
{
positionTextX.gameObject.SetActive(true);
positionTextX.text = "X: " + targetPosition.x.ToString() + " Y: " + targetPosition.y.ToString() + " Z: " + targetPosition.z.ToString();
}
else
{
positionTextX.gameObject.SetActive(false);
}
}
Comment
Your answer
Follow this Question
Related Questions
Play sound on click GUIbutton 0 Answers
Cloud recognition in Vuforia 0 Answers
Problem importing 3D model 0 Answers
how to change to another object after button is pressed 1 Answer