ARReferenceImage

An image to be recognized in the real-world environment during a world-tracking AR session.

在世界追踪AR Session期间在真实世界环境中识别的图像。


Overview

To accurately detect the position and orientation of a 2D image in the real world, ARKit requires preprocessed image data and knowledge of the image's real-world dimensions. The ARReferenceImage class encapsulates this information. To enable image detection in an AR session, pass a collection of reference images to your session configuration's detectionImages property.

Typically, you create reference images in your Xcode project's asset catalog:

In your asset catalog, use the Add (+) button to create an AR Resource Group.

Drag image files into the resource group to create AR Reference Image entries in the asset catalog.

For each reference image, use the Xcode inspector panel to provide the real-world size at which you want ARKit to recognize the image. (You can also provide a descriptive name, which appears as the name property at runtime and can be useful for debugging.)

概述

要准确检测真实世界中2D图像的位置和方向,ARKit需要预处理的图像数据和图像真实世界尺寸的知识。 ARReferenceImage类封装了这些信息。 要在AR Session中启用图像检测,请将参考图像集合传递给Session配置的detectionImages属性。

通常,您可以在Xcode项目的Asset目录中创建参考图像:

在您的Asset目录中,使用添加(+)按钮创建一个AR资源组。

将图像文件拖放到资源组中以在资产目录中创建AR参考图像条目。

对于每个参考图像,使用Xcode检查器面板来提供您想让ARKit识别图像的实际大小。 (您也可以提供一个描述性名称,它在运行时显示为名称属性,可用于调试。)


                             Loading Reference Images


+ referenceImagesInGroupNamed:bundle:
Loads all reference images in the specified AR Resource Group in your Xcode project's asset catalog.
加载Xcode项目Asset目录中指定AR资源组中的所有参考图像。

Parameters

name

The name of an AR Resource Group from your Xcode project's main asset catalog. 

来自Xcode项目主asset目录的AR资源组的名称。

bundle

The bundle from which to load asset catalog resources, or nil to use your app's main bundle.

要从中加载Asset目录资源的包,或者不能使用您的应用的主包。

Return Value

A set of all unique reference images in the specified group.

返回值

指定组中所有唯一参考图像的集合。

Discussion

To use the images for image detection in a world-tracking AR session, provide this set for your session configuration's detectionImages property.

讨论

要在跟踪世界的AR Session中使用图像进行图像检测,请为会话配置的detectionImages属性提供此设置。


                                   Examining a Reference Image


name
A descriptive name for the image
图像的描述性名称

Discussion

For reference images loaded from an Xcode asset catalog, this property is the name assigned in the asset catalog. For programmatically created reference images, this value is nil. 

ARKit does not make this string visible to the user, but it can be valuable for debugging.

讨论

对于从Xcode资产目录加载的参考图像,此属性是在Asset目录中分配的名称。 对于以编程方式创建的参考图像,此值为零。

ARKit不会让这个字符串对用户可见,但它对调试很有价值。

physicalSize
The real-world dimensions, in meters, of the image.
图像的实际尺寸(以米为单位)。

Discussion

To accurately recognize the position and orientation of an image in the AR environment, ARKit must know the image's physical size. You provide this information when creating an AR reference image in your Xcode project's asset catalog, or when programmatically creating a reference image with an ARReferenceImage initializer.

讨论

为了准确识别AR环境中图像的位置和方向,ARKit必须知道图像的物理尺寸。 您在Xcode项目的Asset目录中创建AR参考图像时,或以编程方式创建具有ARReferenceImage初始值设定项的参考图像时提供此信息。


                                        Creating Reference Images


- initWithCGImage:orientation:physicalWidth:
Creates a new reference image from a Core Graphics image object.
从Core Graphics图像对象创建新的参考图像。

Parameters

image

A Core Graphics image object.

核心图形图像对象。

orientation

The intended display orientation for the image. 

图像的预期显示方向。

physicalWidth

The real-world width, in meters, of the image.

图像的实际宽度(以米为单位)。

Discussion

To accurately recognize the position and orientation of an image in the AR environment, ARKit must know the image's physical size. When you call this initializer, ARKit uses the physicalWidth measurement and orientation you provide together with the aspect ratio of the image itself to calculate the physical height. Use the  physicalSize property of the created ARReferenceImage object to retrieve these values.

Important

ARKit preprocesses reference images before using them for image detection. To provide reference images bundled with your app, create AR Reference Image assets in your Xcode asset catalog, and use the referenceImageSetNamed:inBundle: method to load them.

讨论

为了准确识别AR环境中图像的位置和方向,ARKit必须知道图像的物理尺寸。 当您调用此初始值设定项时,ARKit使用您提供的physicalWidth测量值和方向以及图像本身的高宽比来计算物理高度。 使用创建的ARReferenceImage对象的physicalSize属性来检索这些值。

重要

ARKit在使用它们进行图像检测之前预处理参考图像。 要提供与您的应用捆绑在一起的参考图像,请在您的Xcode资产目录中创建AR参考图像Asset,并使用referenceImageSetNamed:inBundle:方法加载它们。

- initWithPixelBuffer:orientation:physicalWidth:
Creates a new reference image from a Core Video pixel buffer.
从核心视频像素缓冲区创建新的参考图像。

Parameters

image

A Core Graphics image object.

核心图形图像对象。

orientation

The intended display orientation for the image. 

图像的预期显示方向。

physicalWidth

The real-world width, in meters, of the image.

图像的实际宽度(以米为单位)。

Discussion

To accurately recognize the position and orientation of an image in the AR environment, ARKit must know the image's physical size. When you call this initializer, ARKit uses the physicalWidth measurement and orientation you provide together with the aspect ratio of the image itself to calculate the physical height. Use the physicalSize property of the created ARReferenceImage object to retrieve these values.

Important

ARKit preprocesses reference images before using them for image detection. To provide reference images bundled with your app, create AR reference image assets in your Xcode asset catalog, and use the referenceImagesInGroupNamed:bundle: method to load them.

讨论

为了准确识别AR环境中图像的位置和方向,ARKit必须知道图像的物理尺寸。 当您调用此初始值设定项时,ARKit使用您提供的physicalWidth测量值和方向以及图像本身的高宽比来计算物理高度。 使用创建的ARReferenceImage对象的physicalSize属性来检索这些值。

重要

ARKit在使用它们进行图像检测之前预处理参考图像。 要提供与您的应用捆绑在一起的参考图像,请在您的Xcode资产目录中创建AR参考图像资产,然后使用referenceImagesInGroupNamed:bundle:方法加载它们。


Inherits From NSObject

Conforms To NSCopying

你可能感兴趣的:(ARReferenceImage)