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