The abstract base class for AR session configurations.
AR Session配置的抽象基类。
Overview
ARConfiguration is an abstract class; you do not create or work with instances of this class.
To run an AR session, create an instance of the concrete ARConfiguration subclass that provides the kind of augmented reality experience you want to use in your app or game. Then, set up the configuration object's properties and pass the configuration to your session's runWithConfiguration:options: method. ARKit includes the following concrete configuration classes:
ARWorldTrackingConfiguration
Provides high-quality AR experiences that use the rear-facing camera precisely track a device's position and orientation and allow plane detection and hit testing.
AROrientationTrackingConfiguration
Provides basic AR experiences that use the rear-facing camera and track only a device's orientation.
ARFaceTrackingConfiguration
Provides AR experiences that use the front-facing camera and track the movement and expressions of the user's face.
概述
AR配置是一个抽象类; 您不创建或使用此类的实例。
要运行AR会话,请创建具体ARConfiguration子类的实例,以提供您想要在您的应用或游戏中使用的增强现实体验。 然后,设置配置对象的属性并将配置传递给会话的runWithConfiguration:options:方法。 ARKit包含以下具体配置类:
ARWorldTrackingConfiguration
提供高品质的AR体验,使用后置摄像头精确跟踪设备的位置和方向,并允许进行飞机检测和命中测试。
AROrientationTrackingConfiguration
提供使用后置摄像头的基本AR体验,并仅跟踪设备的方向。
ARFaceTrackingConfiguration
提供使用前置摄像头并追踪用户脸部动作和表情的AR体验。
Topics
主题
Verifying Device Support
isSupported
A Boolean value indicating whether the current device supports this session configuration class.
一个布尔值,指示当前设备是否支持此session配置类。
Discussion
Different types of AR experiences (which you configure using concrete ARConfigurationsubclasses) can have different hardware requirements.
Before attempting to create an AR configuration, verify that the user’s device supports the configuration you plan to use by checking the isSupported property of the corresponding configuration class. If this property’s value is NO, the current device does not support the requested configuration.
讨论
不同类型的AR体验(使用具体ARConfigurationsubslasses进行配置)可以具有不同的硬件要求。
在尝试创建AR配置之前,通过检查相应配置类的isSupported属性来验证用户设备是否支持您计划使用的配置。 如果此属性的值为NO,则当前设备不支持请求的配置。
Important
All ARKit configurations require an iOS device with an A9 or later processor. If your app otherwise supports other devices and offers augmented reality as a secondary feature, use this property to determine whether to offer AR-based features to the user.
If your app requires ARKit for its core functionality, use the arkit key in the UIRequiredDeviceCapabilities section of your app's Info.plist to make your app available only on devices that support ARKit.
重要
所有ARKit配置都需要带有A9或更高版本处理器的iOS设备。 如果您的应用程序支持其他设备,并将增强现实作为辅助功能提供,请使用此属性来确定是否向用户提供基于增强现实的功能。
如果您的应用需要ARKit的核心功能,请使用应用Info.plist的UIRequiredDeviceCapabilities部分中的arkit密钥,以使您的应用仅在支持ARKit的设备上可用。
Configuring the AR Session
lightEstimationEnabled
A Boolean value specifying whether ARKit analyzes scene lighting in captured camera images.
一个布尔值,指定ARKit是否分析拍摄的照相机图像中的场景照明
Discussion
When this value is YES (the default), a running AR session provides scene lighting information in the lightEstimate property of each ARFrame object it captures.
If you render your own overlay graphics for the AR scene, you can use this information in shading algorithms to help make those graphics match the real-world lighting conditions of the scene captured by the camera. (The ARSCNView class automatically uses this information to configure SceneKit lighting.)
讨论
当此值为YES(默认值)时,正在运行的AR会话将在其捕获的每个ARFrame对象的lightEstimate属性中提供场景照明信息。
如果您为AR场景渲染自己的叠加图形,则可以在着色算法中使用此信息,以帮助使这些图形与相机捕捉的场景的真实照明条件相匹配。 (ARSCNView类自动使用此信息配置SceneKit照明。)
worldAlignment
A value specifying how the session maps real-world device motion into a 3D scene coordinate system.
指定Session如何将真实世界设备运动映射到3D场景坐标系中的值。
Discussion
Creating an AR experience depends on being able to construct a coordinate system for placing objects in a virtual 3D world that maps to the real-world position and motion of the device. When you run a session configuration, ARKit creates a scene coordinate system based on the position and orientation of the device; any ARAnchor objects you create or that the AR session detects are positioned relative to that coordinate system.
See ARWorldAlignment for possible values.
讨论
创建AR体验取决于能够构建一个坐标系,以便将物体放置在映射到设备实际位置和运动的虚拟3D世界中。 当您运行会话配置时,ARKit会根据设备的位置和方向创建场景坐标系; 您创建的任何ARAnchor对象或AR会话检测到的ARAnchor对象都相对于该坐标系定位。
有关可能的值,请参阅ARWorldAlignment。
ARWorldAlignment
Options for how ARKit constructs a scene coordinate system based on real-world device motion.
ARKit如何基于真实设备运动构建场景坐标系统
Alignments
ARWorldAlignmentGravity
The coordinate system's y-axis is parallel to gravity, and its origin is the initial position of the device.
坐标系的y轴平行于重力,它的原点是设备的初始位置。
Discussion
The y-axis matches the direction of gravity as detected by the device's motion sensing hardware; that is, the vector (0,-1,0) points downward.
The position and orientation of the device as of when the session configuration is first run determine the rest of the coordinate system: For the z-axis, ARKit chooses a basis vector (0,0,-1) pointing in the direction the device camera faces and perpendicular to the gravity axis. ARKit chooses a x-axis based on the z- and y-axes using the right hand rule—that is, the basis vector (1,0,0) is orthogonal to the other two axes, and (for a viewer looking in the negative-z direction) points toward the right.
讨论
y轴与设备的运动传感硬件检测到的重力方向相匹配; 也就是说,矢量(0,-1,0)指向下。
在会话配置第一次运行时,设备的位置和方向决定了坐标系的其余部分:对于z轴,ARKit选择指向设备摄像机方向的基向量(0,0,-1) 面向并垂直于重力轴。 ARKit使用右手规则选择基于z轴和y轴的x轴 - 也就是说,基本矢量(1,0,0)与其他两个轴正交,并且(对于查看 负z方向)指向右侧。
ARWorldAlignmentGravityAndHeading
The coordinate system's y-axis is parallel to gravity, its x- and z-axes are oriented to compass heading, and its origin is the initial position of the device.
坐标系的y轴与重力平行,其x轴和z轴的方向为罗盘航向,其起点为设备的初始位置。
Discussion
The y-axis matches the direction of gravity as detected by the device's motion sensing hardware; that is, the vector (0,-1,0) points downward.
The x- and z-axes match the longitude and latitude directions as measured by Location Services. The vector (0,0,-1) points to true north and the vector (-1,0,0) points west. (That is, the positive x-, y-, and z-axes point east, up, and south, respectively.)
Although this option fixes the directions of the three coordinate axes to real-world directions, the location of the coordinate system's origin is still relative to the device, matching the device's position as of when the session configuration is first run.
讨论
y轴与设备的运动传感硬件检测到的重力方向相匹配; 也就是说,矢量(0,-1,0)指向下。
x轴和z轴与位置服务测量的经度和纬度方向相匹配。 矢量(0,0,-1)指向正北,矢量(-1,0,0)指向西。 (也就是说,正x,y和z轴分别指向东,上和南)。
尽管此选项将三个坐标轴的方向固定为实际方向,但坐标系原点的位置仍然相对于设备,与首次运行会话配置时的设备位置相匹配。
Note
Using gravity and heading alignment requires tracking the device's geographic location. Your app's Info.plist must include user-facing text for the NSLocationUsageDescription or NSLocationWhenInUseUsageDescription key so that the user can grant your app permission for location tracking.
注意
使用重力和航向对齐需要跟踪设备的地理位置。 您应用的Info.plist必须包含NSLocationUsageDescription或NSLocationWhenInUseUsageDescription键的面向用户的文本,以便用户可以授予您的应用对位置跟踪的权限。
ARWorldAlignmentCamera
The scene coordinate system is locked to match the orientation of the camera.
场景坐标系被锁定以匹配相机的方向。
Discussion
When this alignment is active, ARKit performs no device motion tracking. That is, world-space positions are effectively always relative to the current position and orientation of the device. (For example, a SceneKit object placed in an ARSCNView will thus maintain the same position on screen, even as the camera image changes while the device moves.)
讨论
当此对齐处于活动状态时,ARKit不执行任何设备运动跟踪。 也就是说,世界空间位置实际上总是相对于设备的当前位置和方向。 (例如,放置在ARSCNView中的SceneKit对象将在屏幕上保持相同的位置,即使设备移动时相机图像发生变化也是如此。)
Managing Video Capture Options
videoFormat
The video capture size and frame rate to be used for sessions running this configuration.
用于运行此配置的Session的视频捕获大小和帧速率。
Discussion
The ARVideoFormat class is immutable; to set the frame rate and video resolution for an AR session, choose one of the video formats in the supportedVideoFormats array.
讨论
ARVideoFormat类是不可变的; 要为AR会话设置帧速率和视频分辨率,请选择supportedVideoFormats阵列中的一种视频格式。
supportedVideoFormats
The set of video capture formats available on the current device.
当前设备上可用的一组视频捕获格式。
Discussion
By default, the videoFormat property for a new session configuration matches the first video capture format in this array. To change the video format for a session, change that property's value to one of the other ARVideoFormat objects in this array.
Important
ARConfiguration is an abstract base class, so its implementation of this property always returns an empty array. Read this property from the configuration subclass you plan to use for your AR session, such as ARWorldTrackingConfiguration or ARFaceTrackingConfiguration.
Different devices and iOS versions offer different sets of supported video formats, but the order of this array always puts higher-quality formats before lower-quality formats. For best results across all devices and versions, choose formats based on their order in the array rather than on hard-coded minimum resolution or frame rate values.
讨论
默认情况下,新Session配置的videoFormat属性与此数组中的第一个视频捕获格式匹配。 要更改Session的视频格式,请将该属性的值更改为此阵列中的其他ARVideoFormat对象之一。
重要
ARConfiguration是一个抽象基类,所以它的这个属性的实现总是返回一个空数组。 从计划用于AR会话的配置子类中读取此属性,例如ARWorldTrackingConfiguration或ARFaceTrackingConfiguration。
不同的设备和iOS版本提供不同的支持的视频格式集,但是这个阵列的顺序总是会在低质量格式之前放置更高质量的格式。 为了在所有设备和版本中获得最佳效果,请根据阵列中的顺序选择格式,而不是硬编码的最小分辨率或帧速率值。
ARVideoFormat
A video size and frame rate specification for use with an AR session.
用于AR Session的视频大小和帧速率规范。
Overview
This class is immutable; to set the frame rate and video resolution for an AR session, set your configuration's videoFormat property to one of the formats in the supportedVideoFormats array.
概述
这个类是不可改变的; 要为AR会话设置帧速率和视频分辨率,请将配置的videoFormat属性设置为supportedVideoFormats阵列中的一种格式。
Topics
Video Format Settings
framesPerSecond
The rate at which the session captures video and provides AR frame information.
Session捕获视频并提供AR帧信息的速率。
imageResolution
The size, in pixels, of video images captured in the session.
Session中捕获的视频图像的大小(以像素为单位)。
Recording Audio
providesAudioData
A Boolean value that specifies whether to capture audio during the AR session.
一个布尔值,指定是否在ARSession期间捕获音频。
Discussion
To receive and handle captured audio data, your session delegate must implement the session:didOutputAudioSampleBuffer: method.
讨论
要接收和处理捕获的音频数据,您的会话委托必须实现会话:didOutputAudioSampleBuffer:方法。
网友评论