Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

  • I need to recognize the marker in order to select corresponding 3D content.
  • 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.

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

like image 857
Rumata Avatar asked Oct 16 '17 00:10

Rumata


1 Answers

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

}
like image 183
David Avatar answered Sep 29 '22 15:09

David