7

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?

Rumata
  • 1,027
  • 3
  • 16
  • 47

1 Answers1

4

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

}
David
  • 15,894
  • 22
  • 55
  • 66
  • Where does the above UI come from? I don't see anything like it in the Target Manager or in Xcode. – John Scalo Oct 16 '17 at 23:39
  • Drag an image target prefab to the scene, you will see it then. – David Oct 17 '17 at 01:13
  • Thank you very much!!! It seems to be a perfect solution, but for some reason, it doesn't work for me. Here is a short example code I created, so if I detect a marker I want to show a simple UI canvas with a button. http://csharppad.com/gist/82e2573f674f1d42b413d3fb8b0b9b60 I disabled the DefaultTrackableEventHandler, and added Debug.Log() for testing, but I don't see any messages in my console (so OnTrackingFound() never reached), but I still see objects, parented to the image prefab appear when the marker is recognized! It's strange did I made a mistake anywhere? I use Unity 2017.2.0f3 – Rumata Oct 18 '17 at 09:42
  • Are you able to see Debug.log in other places, e.g. start() ? Did you hide the log/error panel? From the code, if you see the toggled UI, it is a signal that OnTrackingfound() is fired. – David Oct 19 '17 at 02:39
  • 1
    @Rumata I am also looking for similar solution. Were you able to crack this? – Venkatesh Jan 08 '18 at 13:00