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:方法。