问题
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?
回答1:
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.
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
}
来源:https://stackoverflow.com/questions/46761440/arkit-and-vuforia-marker-recognition