A configuration that uses the back-facing camera, tracks a device's orientation and position, and detects real-world flat surfaces.
使用背面照相机的配置,跟踪设备的方向和位置,并检测真实世界的平面。
Overview
All AR configurations establish a correspondence between the real world the device inhabits and a virtual 3D coordinate space where you can model content. When your app displays that content together with a live camera image, the user experiences the illusion that your virtual content is part of the real world.
Creating and maintaining this correspondence between spaces requires tracking the device's motion. The ARWorldTrackingConfiguration class tracks the device's movement with six degrees of freedom (6DOF): specifically, the three rotation axes (roll, pitch, and yaw), and three translation axes (movement in x, y, and z).
This kind of tracking can create immersive AR experiences: A virtual object can appear to stay in the same place relative to the real world, even as the user tilts the device to look above or below the object, or moves the device around to see the object's sides and back.
概述
所有AR配置都可以在设备居住的真实世界与虚拟3D坐标空间之间建立对应关系,您可以在其中对内容进行建模。 当您的应用程序将该内容与实时相机图像一起显示时,用户会体验到虚拟内容是真实世界的一部分的错觉。
在空间之间创建和维护这种对应关系需要跟踪设备的运动。 ARWorldTrackingConfiguration类以六个自由度(6DOF)跟踪设备的运动:特别是三个旋转轴(滚动,俯仰和偏航)以及三个平移轴(在x,y和z中的移动)。
这种追踪可以创造逼真的AR体验:虚拟物体可以看起来与真实世界保持相同的位置,即使用户将设备倾斜到物体的上方或下方,或者移动设备以查看 物体的侧面和背面。
If you enable the planeDetection setting, ARKit analyzes the scene to find real-world horizontal or vertical surfaces. For each plane detected, ARKit automatically adds an ARPlaneAnchor object to the session.
If you provide images for the detectionImages property, ARKit analyzes the scene to recognize those images. For each detected image, ARKit automatically adds an ARImageAnchor object to the session.
如果启用planeDetection设置,ARKit将分析场景以查找真实世界的水平或垂直表面。 对于检测到的每个平面,ARKit会自动将ARPlaneAnchor对象添加到会话中。
如果您为detectionImages属性提供图像,ARKit会分析场景以识别这些图像。 对于每个检测到的图像,ARKit会自动将ARImageAnchor对象添加到会话中。
Creating a Configuration
- init
Creates a new world tracking configuration.
创建新的世界跟踪配置。
+ new
Enabling Plane Detection
planeDetection
A value specifying whether and how the session attempts to automatically detect flat surfaces in the camera-captured image.
一个值用来表明是否开启平面检测以及判别是哪种平面的值。
Discussion
By default, plane detection is off. If you enable ARPlaneDetectionHorizontal or ARPlaneDetectionVertical plane detection, the session adds ARPlaneAnchor objects and notifies your ARSessionDelegate, ARSCNViewDelegate, or ARSKViewDelegate object whenever its analysis of captured video images detects an area that appears to be a flat surface.
讨论
默认情况下,平面检测已关闭。 如果启用ARPlaneDetectionHorizontal或ARPlaneDetectionVertical平面检测,会话将添加ARPlaneAnchor对象,并在其捕获的视频图像的分析检测到看似平坦的区域时,通知您的ARSessionDelegate,ARSCNViewDelegate或ARSKViewDelegate对象。
ARPlaneDetection
Options for whether and how ARKit detects flat surfaces in captured images.
ARKit是否以及如何检测拍摄图像中的平坦表面的选项。
Plane Detection Options
ARPlaneDetectionHorizontal
The session detects planar surfaces that are perpendicular to gravity.
会话检测垂直于重力的平面。
ARPlaneDetectionVertical
The session detects surfaces that are parallel to gravity (regardless of other orientation).
会话检测平行于重力的平面。
ARPlaneDetectionNone
Plane detection is disabled.
平面检测不可用
Enabling Image Detection
detectionImages
A set of images for ARKit to attempt to detect in the user's environment.
ARKit尝试在用户环境中检测的一组图像。
Discussion
Use this property to choose known 2D images for ARKit to find in the user's environment and present as ARImageAnchor for use in your AR experience. Use Xcode to define reference images for ARKit to detect, or define them programmatically with the ARReferenceImageclass.
For example, you might use this feature to create a AR experience where, when the user encounters a certain movie poster, space ships or cartoon characters appear to emerge from the poster and inhabit the user's environment.
讨论
使用此属性可以为ARKit选择已知的2D图像,以便在用户环境中查找并以ARImageAnchor的形式显示,以便用于您的AR体验。 使用Xcode为ARKit定义参考图像来检测,或使用ARReferenceImageclass以编程方式定义它们。
例如,您可以使用此功能创建AR体验,其中当用户遇到某个电影海报时,太空飞船或卡通人物会从海报中浮现出来,并置身于用户的环境中。
Managing Device Camera Behavior
autoFocusEnabled
A Boolean value that determines whether the device camera uses fixed focus or autofocus behavior.
一个布尔值,用于确定设备相机是使用固定焦点还是自动聚焦行为。
Discussion
In apps linked against the iOS 11.3 SDK or later, ARKit enables autofocus by default.
在与iOS 11.3 SDK或更高版本链接的应用程序中,ARKit默认启用自动对焦。
Inherits From ARConfiguration