ARKit 和 Vuforia - 标记识别 [英] ARKit and Vuforia - marker recognition

查看:34
本文介绍了ARKit 和 Vuforia - 标记识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 iOS 应用,我需要识别一个标记(很可能是二维码)并使用 ARKit 在它上面放置一些 3D 内容.

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.

我在考虑将 Vuforia 和 ARKit 结合起来.

I was thinking about a combination of Vuforia and ARKit.

是否可以使用 Vuforia 仅识别标记并获取其位置,然后将此数据传递"给 ARKit?

  • 我需要识别标记才能选择相应的 3D 内容.
  • 我只需要获取标记的位置,以便在那里放置 3D 内容,之后我想使用 ARKit 进行跟踪.

有可能吗?
是否有另一种可以与 ARKit 一起使用的标记识别解决方案?

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

推荐答案

Q1:您可以处理标记的识别(在 Vuforia 中称为 Image Target)创建脚本:

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();
        }
    }
}

然后你可以用这个脚本替换 DefaultTrackableEventHandler.

Then you can replace the DefaultTrackableEventHandler with this this script.

Q2:我只需要获取标记的位置,以便在那里放置 3D 内容,然后我想使用 ARKit 进行跟踪.

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.

您可以添加一个空游戏对象作为标记(ImageTarget)的子对象,层次结构为:

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

}

这篇关于ARKit 和 Vuforia - 标记识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆