Rumata
Rumata

Reputation: 1047

ARKit and Vuforia - marker recognition

I'm working on an iOS app, I need to recognize a marker (most likely it will be QR code) and place some 3D content over it using ARKit.

I was thinking about a combination of Vuforia and ARKit.

Is it possible to use Vuforia only to recognize the marker and get its position, and then "pass" this data to ARKit?

Is it possible?
Is there another solution for marker recognition which can be used with ARKit?

Upvotes: 7

Views: 1456

Answers (1)

David
David

Reputation: 16287

Q1: You can handle the recognition of the marker (called Image Target in Vuforia) Create a script:

public class CustomTrackableEventHandler : MonoBehaviour,
                                           ITrackableEventHandler
{
    ...

    public void OnTrackableStateChanged(
                                    TrackableBehaviour.Status previousStatus,
                                    TrackableBehaviour.Status newStatus)
    {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED ||
            newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
        {
            OnTrackingFound(); 
            // **** Your own logic here ****
        }
        else
        {
            OnTrackingLost();
        }
    }
}

Then you can replace the DefaultTrackableEventHandler with this this script.

enter image description here

Q2: I need to get the position of the marker only ones, in order to place 3D content there, after that I want to use ARKit for tracking.

You can add an empty game object to be the child of the marker (ImageTarget), and the hierarchy would be:

YourMarker(ImageTarget)
     |__EmptyPlaceHolder

When the marker is recognised, you can then programatically get its location:

var placeHolder = GameObject.Find("EmptyPlaceHolder");
if(placeHolder != null){
    Debug.Log(placeHolder.transform.position); // all the location, localPosition, quaternion etc will be available to you

}

Upvotes: 4

Related Questions