Information about the pose, topology, and expression of a face detected in a face-tracking AR session.
有關(guān)在面部跟蹤AR Session中檢測到的人臉姿態(tài)睁本,拓?fù)浜捅砬榈男畔ⅰ?/p>
Overview
When you run a face-tracking AR session (see?ARFaceTrackingConfiguration), the session automatically adds to its list of anchors an?ARFaceAnchor?object when it detects the user’s face with the front-facing camera. Each face anchor provides information about the face’s current position and orientation, topology, and facial expression.
概述
當(dāng)您運(yùn)行人臉跟蹤AR Session(請(qǐng)參閱ARFaceTrackingConfiguration)時(shí),Session會(huì)在用前置攝像頭檢測到用戶的臉部時(shí)自動(dòng)向其錨點(diǎn)列表中添加一個(gè)ARFaceAnchor對(duì)象。 每個(gè)臉部錨點(diǎn)提供關(guān)于臉部的當(dāng)前位置和方向,拓?fù)浜兔娌勘砬榈男畔ⅰ?/p>
Tracking Face Position and Orientation
The inherited?transform?property describes the face’s current position and orientation in world coordinates; that is, in a coordinate space relative to that specified by the?worldAlignment?property of the session configuration. Use this transform matrix to position virtual content you want to “attach” to the face in your AR scene.
This transform matrix creates a face coordinates system for positioning other elements relative to the face. Units of face coordinate space are in meters, with the origin centered behind the face as indicated in the figure below.
跟蹤臉部位置和方向
繼承的transform屬性描述了人臉在世界坐標(biāo)中的當(dāng)前位置和方向; 即在相對(duì)于Session配置的worldAlignment屬性指定的坐標(biāo)空間中呜师。 使用這個(gè)變換矩陣來定位想要“附加”到AR場景中的臉部的虛擬內(nèi)容娶桦。
該變換矩陣創(chuàng)建用于定位其他元素相對(duì)于臉部的臉部坐標(biāo)系統(tǒng)。 如下圖所示衷畦,臉部坐標(biāo)空間單位為米,原點(diǎn)位于臉部后方斤程。
The coordinate system is right-handed—the positive x direction points to the viewer’s right (that is, the face’s own left), the positive y direction points up (relative to the face itself, not to the world), and the positive z direction points outward from the face (toward the viewer).
坐標(biāo)系是右手的忿墅,正x方向指向觀察者的右側(cè)(即沮峡,臉部自己的左側(cè)),正y方向指向(相對(duì)于臉部本身而不是世界)棍弄,以及正z 方向從臉部向外(朝向觀察者)指向疟游。
Using Face Topology
The?geometry?property provides an?ARFaceGeometry?object representing detailed topology for the face, which conforms a generic face model to match the dimensions, shape, and current expression of the detected face.?
You can use this model as the basis for overlaying content that follows the shape of the user’s face—for example, to apply virtual makeup or tattoos. You can also use this model to create?occlusion geometry—a 3D model that doesn't render any visible content (allowing the camera image to show through), but that obstructs the camera's view of other virtual content in the scene.
使用面拓?fù)?/h1>
geometry屬性提供了一個(gè)ARFaceGeometry對(duì)象颁虐,該對(duì)象表示面部的詳細(xì)拓?fù)浣Y(jié)構(gòu),它符合通用面部模型以匹配檢測到的面部的尺寸瞬痘,形狀和當(dāng)前表達(dá)式板熊。
您可以使用此模型作為覆蓋用戶臉部形狀的內(nèi)容的基礎(chǔ) - 例如,應(yīng)用虛擬化妝或紋身干签。 您還可以使用此模型創(chuàng)建遮擋幾何圖形 - 一種不會(huì)呈現(xiàn)任何可見內(nèi)容(允許攝像機(jī)圖像顯示)的3D模型,但會(huì)妨礙相機(jī)對(duì)場景中其他虛擬內(nèi)容的查看喘沿。
Tracking Facial Expressions
The?blendShapes?property provides a high-level model of the current facial expression, described via a series of many named coefficients that represent the movement of specific facial features relative to their neutral configurations. You can use blend shape coefficients to animate 2D or 3D content, such as a character or avatar, in ways that follow the user’s facial expressions.
跟蹤面部表情
blendShapes屬性提供當(dāng)前面部表情的高級(jí)模型蚜印,通過一系列多個(gè)命名系數(shù)進(jìn)行描述留量,這些系數(shù)表示特定面部特征相對(duì)于其中配置的移動(dòng)。 您可以使用混合形狀系數(shù)按照用戶面部表情的方式為2D或3D內(nèi)容(如角色或頭像)制作動(dòng)畫忆绰。
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Using Face Geometry
geometry
A coarse triangle mesh representing the topology of the detected face.
表示檢測到的臉部拓?fù)涞拇植谌切尉W(wǎng)格错敢。
Discussion
This mesh provides vertex, index, and texture coordinate buffers describing the 3D shape of the face, conforming a generic face model to match the dimensions, shape, and current expression of the detected face.?
You can visualize the face geometry by passing these buffers to your preferred rendering engine. To visualize a face geometry using SceneKit, create an?ARSCNFaceGeometry?instance and use its?updateFromFaceGeometry:?method to update it to mach the face geometry.
討論
該網(wǎng)格提供了描述臉部三維形狀的頂點(diǎn)稚茅,索引和紋理坐標(biāo)緩沖區(qū),使通用臉部模型符合檢測臉部的尺寸萎馅,形狀和當(dāng)前表達(dá)式虹蒋。
您可以通過將這些緩沖區(qū)傳遞給您的首選渲染引擎來可視化人臉幾何魄衅。 要使用SceneKit可視化人臉幾何塘辅,請(qǐng)創(chuàng)建一個(gè)ARSCNFaceGeometry實(shí)例并使用其updateFromFaceGeometry:方法更新它以加工人臉幾何扣墩。
ARFaceGeometry
A 3D mesh describing face topology used in face-tracking AR sessions
描述用于面部跟蹤ARSession的面部拓?fù)涞?D網(wǎng)格
Overview
This class provides a general model for the detailed topology of a face, in the form of a 3D mesh appropriate for use with various rendering technologies or for exporting 3D assets. (For a quick way to visualize a face geometry using SceneKit, see the?ARSCNFaceGeometry?class.)
When you obtain a face geometry from an?ARFaceAnchor?object in a face-tracking AR session, the model conforms to match the dimensions, shape, and current expression of the detected face. You can also create a face mesh using a dictionary of named blend shape coefficients, which provides a detailed, but more efficient, description of the face’s current expression.
In an AR session, you can use this model as the basis for overlaying content that follows the shape of the user’s face—for example, to apply virtual makeup or tattoos. You can also use this model to create occlusion geometry, which hides other virtual content behind the 3D shape of the detected face in the camera image.
概述
該類為適用于各種渲染技術(shù)或用于導(dǎo)出3D Asset的3D網(wǎng)格提供了面部詳細(xì)拓?fù)涞囊话隳P汀?(要使用SceneKit快速查看面部幾何圖形呻惕,請(qǐng)參閱ARSCNFaceGeometry類。)
當(dāng)您從面部跟蹤AR會(huì)話中的ARFaceAnchor對(duì)象獲取面部幾何體時(shí)做院,該模型符合檢測到的面部的尺寸濒持,形狀和當(dāng)前表達(dá)式柑营。 您還可以使用名為混合形狀系數(shù)的字典創(chuàng)建臉部網(wǎng)格,其中提供了有關(guān)臉部當(dāng)前表情的詳細(xì)但更有效的描述酒奶。
在AR會(huì)話中,您可以使用此模型作為覆蓋用戶臉部形狀的內(nèi)容的基礎(chǔ) - 例如勒虾,應(yīng)用虛擬化妝或紋身修然。 您還可以使用此模型創(chuàng)建遮擋幾何圖形质况,該遮擋幾何圖形將其他虛擬內(nèi)容隱藏在攝像機(jī)圖像中檢測到的臉部的3D形狀后面。
Note
Face mesh topology is constant across?ARFaceGeometry?instances. That is, the values of the?vertexCount,?textureCoordinateCount, and?triangleCount?properties never change, the?triangleIndices?buffer always describes the same arrangement of vertices, and the?textureCoordinates?buffer always maps the same vertex indices to the same texture coordinates.?
Only the?vertices?buffer changes between face meshes provided by an AR session, indicating the change in vertex positions as ARKit adapts the mesh to the shape and expression of the user's face.
注意
面網(wǎng)格拓?fù)湓贏RFaceGeometry實(shí)例中保持不變。 也就是說臼朗,vertexCount视哑,textureCoordinateCount和triangleCount屬性的值始終不變,triangleIndices緩沖區(qū)始終描述相同的頂點(diǎn)排列蒜撮,并且textureCoordinates緩沖區(qū)始終將相同的頂點(diǎn)索引映射到相同的紋理坐標(biāo)段磨。
只有頂點(diǎn)緩沖區(qū)在AR Session提供的面孔網(wǎng)格之間變化耗绿,指示頂點(diǎn)位置的變化,因?yàn)锳RKit將網(wǎng)格調(diào)整為用戶面部的形狀和表情沐序。
Accessing Mesh Data
vertexCount
The number of elements in the?vertices?buffer.
頂點(diǎn)緩沖中的元素?cái)?shù)量策幼。
Discussion
Face mesh topology is constant across?ARFaceGeometry?instances, so the value of this property is the same for all instances.
討論
面網(wǎng)格拓?fù)湓贏RFaceGeometry實(shí)例中保持不變奴紧,因此此屬性的值對(duì)于所有實(shí)例都是相同的黍氮。
vertices
A buffer of vertex positions for each point in the face mesh.
面網(wǎng)格中每個(gè)點(diǎn)的頂點(diǎn)位置的緩沖區(qū)浅浮。
Discussion
Each?float3?value in this buffer represents the position of a vertex in the mesh, in face coordinates. (See?Tracking Face Position and Orientation.)
The?vertexCount?property provides the number of elements in the buffer.
討論
此緩沖區(qū)中的每個(gè)float3值表示網(wǎng)格中頂點(diǎn)的位置滚秩,以面坐標(biāo)表示淮捆。 (請(qǐng)參閱跟蹤臉部位置和方向攀痊。)
vertexCount屬性提供緩沖區(qū)中元素的數(shù)量。
textureCoordinateCount
The number of elements in the?textureCoordinates?buffer.
textureCoordinates緩沖區(qū)中元素的數(shù)量案站。
Discussion
Face mesh topology is constant across?ARFaceGeometry?instances, so the value of this property is the same for all instances.
討論
面網(wǎng)格拓?fù)湓贏RFaceGeometry實(shí)例中保持不變蟆盐,因此此屬性的值對(duì)于所有實(shí)例都是相同的遭殉。
textureCoordinates
A buffer of texture coordinate values for each point in the face mesh.
面部網(wǎng)格中每個(gè)點(diǎn)的紋理坐標(biāo)值的緩沖區(qū)。
Discussion
Each?float2?value in this buffer represents the UV texture coordinates for the vertex at the corresponding index in the?vertices?buffer.
The?textureCoordinateCount?property provides the number of elements in the buffer.?
Face mesh topology is constant across?ARFaceGeometry?instances, so the data in this buffer always maps the same vertex indices to the same texture coordinates.
討論
此緩沖區(qū)中的每個(gè)float2值表示頂點(diǎn)緩沖區(qū)中相應(yīng)索引處頂點(diǎn)的UV紋理坐標(biāo)翔始。
textureCoordinateCount屬性提供緩沖區(qū)中元素的數(shù)量。
面網(wǎng)格拓?fù)湓贏RFaceGeometry實(shí)例中保持不變渤闷,因此此緩沖區(qū)中的數(shù)據(jù)始終將相同的頂點(diǎn)索引映射到相同的紋理坐標(biāo)脖镀。
triangleCount
The number of triangles described by the?triangleIndices?buffer.
描述的三角形的數(shù)量triangleIndices緩沖蜒灰。
Discussion
Each set of three indices forms a triangle, so the number of indices in the?triangleIndicesbuffer is three times the?triangleCount?value.
Face mesh topology is constant across?ARFaceGeometry?instances, so the value of this property is the same for all instances.
討論
每組三個(gè)索引形成一個(gè)三角形,因此triangleIndices緩沖區(qū)中索引的數(shù)量是triangleCount值的三倍凸椿。
面網(wǎng)格拓?fù)湓贏RFaceGeometry實(shí)例中保持不變脑漫,因此此屬性的值對(duì)于所有實(shí)例都是相同的。
triangleIndices
A buffer of indices describing the triangle mesh formed by the face geometry's vertex data.
索引緩沖區(qū)吨拍,用于描述由面幾何的頂點(diǎn)數(shù)據(jù)形成的三角形網(wǎng)格网杆。
Discussion
Each 16-bit integer value in this buffer represents an index into the?vertices?and?textureCoordinates?buffers. Each set of three indices identifies the vertices that form a single triangle in the mesh. (That is, this buffer is appropriate for use as an index buffer for a triangle mesh in GPU-based rendering or creating 3D model asset files.)
Each set of three indices forms a triangle, so the number of indices in the?triangleIndicesbuffer is three times the?triangleCount?value.
Face mesh topology is constant across?ARFaceGeometry?instances, so this buffer always describes the same arrangement of vertices. Only the?vertices?buffer changes between face meshes provided by an AR session, indicating the change in vertex positions as ARKit adapts the mesh to the shape and expression of the user's face.
討論
此緩沖區(qū)中的每個(gè)16位整數(shù)值都表示頂點(diǎn)和textureCoordinates緩沖區(qū)的索引严里。 每組三個(gè)索引都標(biāo)識(shí)形成網(wǎng)格中單個(gè)三角形的頂點(diǎn)追城。 (也就是說,此緩沖區(qū)適合用作基于GPU渲染或創(chuàng)建3D模型 Asset文件的三角形網(wǎng)格的索引緩沖區(qū)迷帜。)
每組三個(gè)索引形成一個(gè)三角形戏锹,因此triangleIndices緩沖區(qū)中索引的數(shù)量是triangleCount值的三倍火诸。
面網(wǎng)格拓?fù)湓贏RFaceGeometry實(shí)例中保持不變置蜀,因此此緩沖區(qū)始終描述相同的頂點(diǎn)排列。 只有頂點(diǎn)緩沖區(qū)在AR Session提供的面孔網(wǎng)格之間變化馋吗,指示頂點(diǎn)位置的變化秋秤,因?yàn)锳RKit將網(wǎng)格調(diào)整為用戶面部的形狀和表情灼卢。
? ? ? ? ? ? ? ?Creating a Mesh from Blend Shapes
-?initWithBlendShapes:
Creates a face geometry matching the facial expression described in the specified dictionary.
創(chuàng)建與指定字典中描述的面部表情匹配的面部幾何。
Parameters
blendShapes
A dictionary of blend shape coefficients describing a facial expression in terms of the positions of specific facial features. For any coefficient not specified in this dictionary, ARKit assumes a value of?0.0.
混合形狀系數(shù)字典蛇摸,用于描述特定臉部特征位置的臉部表情灿巧。 對(duì)于本字典中未指定的任何系數(shù),ARKit假定值為0.0饿肺。
Return Value
A face geometry object, or?nil?if ARKit face tracking is not supported on the current device.
返回類型
面部幾何對(duì)象,如果ARKit面部跟蹤在當(dāng)前設(shè)備上不受支持雪标,則為零溉跃。
Discussion
Each key in the?blendShapes?dictionary is an?ARBlendShapeLocation?constant identifying a facial feature. The corresponding value is the position of that feature relative to its neutral configuration, ranging from?0.0?(neutral) to?1.0?(maximum movement).?
The format of this dictionary is identical to that provided by the?ARFaceAnchor?blendShapesproperty. You can use that property and this initializer to efficiently save and restore facial expression data; the serialized form of a blend shapes dictionary is more portable than that of the face mesh those coefficients describe
討論
blendShapes字典中的每個(gè)鍵都是標(biāo)識(shí)面部特征的ARBlendShapeLocation常量撰茎。 相應(yīng)的值是該特征相對(duì)于內(nèi)在配置的位置龄糊,范圍從0.0(中性)到1.0(最大移動(dòng))。
該字典的格式與ARFaceAnchor blendShapes屬性提供的格式相同僻弹。 您可以使用該屬性和此初始化程序有效地保存和恢復(fù)面部表情數(shù)據(jù); 混合形狀詞典的序列化形式比那些系數(shù)描述的臉部網(wǎng)格更容易攜帶他嚷。
Inherits From?NSObject
Conforms To?NSCopying,?NSSecureCoding