Information about a real-world surface found by examining a point in the device camera view of an AR session.
通过检查AR Session的设备摄像头视图中的点找到有关真实世界表面的信息。
Overview
If you display an AR experience using SceneKit or SpriteKit, you can use one of the following methods to search the camera image for real-world content at a point specified in view coordinates:
Otherwise, you can search the camera image for real-world content using the ARFrame hitTest:types: method. Because a frame is independent of a view, for this method you pass a point specified in normalized image coordinates (where (0,0) is the top left corner of the image and (1,1) is the lower right).
All these methods return an array of ARHitTestResult objects describing the content found. The number and order of results in the array depends on the search types you specify and the order you specify them in. For example, consider the code below:
概述
如果使用SceneKit或SpriteKit显示AR体验,则可以使用以下方法之一在视图坐标中指定的点处搜索相机图像以查找真实世界的内容:
ARSCNView hitTest:类型:
ARSKView hitTest:类型:
否则,您可以使用ARFrame hitTest:types:方法在摄像机图像中搜索真实世界的内容。 因为一个框架与视图无关,所以对于此方法,您将传递在标准化图像坐标中指定的点(其中(0,0)是图像的左上角,(1,1)是右下角)。
所有这些方法都返回一个ARHitTestResult对象数组,用于描述找到的内容。 数组中结果的数量和顺序取决于您指定的搜索类型以及您指定的搜索顺序。例如,请考虑以下代码:
This hitTest:types: call searches first for plane anchors already present in the session (according to the session configuration's planeDetection settings); returning any such results (in order of distance from the camera) as the first elements in the array. This call also (due to the estimatedHorizontalPlane request) attempts to determine whether the hit test ray intersects any horizontal surface not already found by plane detection, and returns that result (if any) as the last element in the array.
此hitTest:types: call 首先搜索会话中已存在的平面锚点(根据会话配置的planeDetection设置); 作为数组中的第一个元素返回任何这样的结果(按照距相机的距离的顺序)。 此调用(由于估计的水平平面请求)还会尝试确定命中的测试射线是否与平面检测未找到的任何水平面相交,并将该结果(如果有)作为数组中的最后一个元素返回。
Identifying Results
type
The kind of detected feature the search result represents.
搜索结果所代表的检测到的特征种类。
Discussion
You specify one or more result types to search for when calling a hit-testing method. A result object has only one result type.
讨论
指定一个或多个结果类型以在调用命中测试方法时进行搜索。 结果对象只有一个结果类型。
ARHitTestResultType
Possible types of hit-test searching to perform or type of objects found by a search.
用于执行搜索的命中测试搜索的可能类型或搜索找到的对象的类型。
Result Types
ARHitTestResultTypeFeaturePoint
A point automatically identified by ARKit as part of a continuous surface, but without a corresponding anchor.
一个点由ARKit自动识别为连续曲面的一部分,但没有相应的锚点。
ARHitTestResultTypeEstimatedHorizontalPlane
A real-world planar surface detected by the search (without a corresponding anchor), whose orientation is perpendicular to gravity.
由搜索检测到的实际平面曲面(没有相应的锚点),其方向垂直于重力。
ARHitTestResultTypeEstimatedVerticalPlane
A real-world planar surface detected by the search, whose orientation is parallel to gravity.
由搜索检测到的实际平面曲面,其方向与重力平行。
ARHitTestResultTypeExistingPlane
A plane anchor already in the scene (detected with the planeDetection option), without considering the plane's size.
已经在场景中的平面锚(用planeDetection选项检测到),而不考虑plane的尺寸。
ARHitTestResultTypeExistingPlaneUsingExtent
A plane anchor already in the scene (detected with the planeDetection option), respecting the plane's limited size.
plane锚点已经在场景中(用planeDetection选项检测到),尊重plane的有限尺寸。
ARHitTestResultTypeExistingPlaneUsingGeometry
A plane anchor already in the scene (detected with the planeDetection option), respecting the plane's estimated size and shape.
已经在场景中的平面锚点(用planeDetection选项检测),尊重plane的估计尺寸和形状。
anchor
The anchor representing the detected surface, if any.
表示检测到的表面的锚点,如果有的话。
Discussion
Results of the ARHitTestResultTypeFeaturePoint type do not include an anchor.
讨论
ARHitTestResultTypeFeaturePoint类型的结果不包含锚点。
Examining Result Geometry
distance
The distance, in meters, from the camera to the detected surface.
从照相机到检测到的表面的距离(以米为单位)。
worldTransform
The position and orientation of the hit test result relative to the world coordinate system.
命中测试结果相对于世界坐标系的位置和方向。
localTransform
The position and orientation of the hit test result relative to the nearest anchor or feature point.
命中测试结果相对于最近锚点或特征点的位置和方向。
Discussion
This transform matrix indicates the intersection point between the detected surface and the ray that created the hit test result. A hit test projects a 2D point in the image or view coordinate system along a ray into the 3D world space and reports results where that line intersects detected surfaces.
讨论
该变换矩阵表示检测到的表面与创建命中测试结果的射线之间的交点。 命中测试将图像中的二维点或视图坐标系中的光线投射到三维世界空间中,并在该线与检测到的表面相交的位置报告结果。
Inherits From NSObject