ARKit和Vuforia - 标记识别 [英] ARKit and Vuforia - marker recognition
问题描述
我正在开发iOS应用程序,我需要识别一个标记(很可能是QR代码)并使用ARKit在其上放置一些3D内容。
<我正在考虑Vuforia和ARKit的组合。
是否可以仅使用Vuforia来识别标记并获得其位置,然后将此数据传递给ARKit?
- 我需要识别标记才能选择相应的3D内容。
- 为了在那里放置3D内容,我需要获取标记的位置,之后我想使用ARKit进行跟踪。
有可能吗?
还有另一种可以与ARKit一起使用的标记识别解决方案吗?
Q1:
您可以处理标记的识别(在Vuforia中称为图像目标)
创建脚本:
公共类CustomTrackableEventHandler:MonoBehaviour,
ITrackableEventHandler
{
...
public void OnTrackableStateChanged(
TrackableBehaviour.Status previousStatus,
TrackableBehaviour.Status newStatus)
{
if(newStatus == TrackableBehaviour.Status.DETECTED ||
newStatus == TrackableBehaviour。 Status.TRACKED ||
newS tatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
{
OnTrackingFound();
// ****你自己的逻辑****
}
其他
{
OnTrackingLost();
}
}
}
然后你可以替换DefaultTrackableEventHandler用这个脚本。
Q2:我需要获得标记的位置,以便在那里放置3D内容,之后我想使用ARKit进行跟踪。
你可以添加一个空的游戏object为标记的子级(ImageTarget),层次结构为:
YourMarker(ImageTarget)
| __EmptyPlaceHolder
识别出标记后,您可以编程方式获取其位置:
var placeHolder = GameObject.Find(EmptyPlaceHolder);
if(placeHolder!= null){
Debug.Log(placeHolder.transform.position); //所有的位置,localPosition,四元数等都可以使用
}
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?
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
}
这篇关于ARKit和Vuforia - 标记识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!