ARFaceAnchor

Information about the pose, topology, and expression of a face detected in a face-tracking AR session.

有关在面部跟踪AR Session中检测到的人脸姿态,拓扑和表情的信息。


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.

概述

当您运行人脸跟踪AR Session(请参阅ARFaceTrackingConfiguration)时,Session会在用前置摄像头检测到用户的脸部时自动向其锚点列表中添加一个ARFaceAnchor对象。 每个脸部锚点提供关于脸部的当前位置和方向,拓扑和面部表情的信息。

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属性描述了人脸在世界坐标中的当前位置和方向; 即在相对于Session配置的worldAlignment属性指定的坐标空间中。 使用这个变换矩阵来定位想要“附加”到AR场景中的脸部的虚拟内容。

该变换矩阵创建用于定位其他元素相对于脸部的脸部坐标系统。 如下图所示,脸部坐标空间单位为米,原点位于脸部后方。


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).

坐标系是右手的,正x方向指向观察者的右侧(即,脸部自己的左侧),正y方向指向(相对于脸部本身而不是世界),以及正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.

使用面拓扑

geometry属性提供了一个ARFaceGeometry对象,该对象表示面部的详细拓扑结构,它符合通用面部模型以匹配检测到的面部的尺寸,形状和当前表达式。

您可以使用此模型作为覆盖用户脸部形状的内容的基础 - 例如,应用虚拟化妆或纹身。 您还可以使用此模型创建遮挡几何图形 - 一种不会呈现任何可见内容(允许摄像机图像显示)的3D模型,但会妨碍相机对场景中其他虚拟内容的查看。

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属性提供当前面部表情的高级模型,通过一系列多个命名系数进行描述,这些系数表示特定面部特征相对于其中配置的移动。 您可以使用混合形状系数按照用户面部表情的方式为2D或3D内容(如角色或头像)制作动画。


                                     Using Face Geometry


geometry
A coarse triangle mesh representing the topology of the detected face.
表示检测到的脸部拓扑的粗糙三角形网格。

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.

讨论

该网格提供了描述脸部三维形状的顶点,索引和纹理坐标缓冲区,使通用脸部模型符合检测脸部的尺寸,形状和当前表达式。

您可以通过将这些缓冲区传递给您的首选渲染引擎来可视化人脸几何。 要使用SceneKit可视化人脸几何,请创建一个ARSCNFaceGeometry实例并使用其updateFromFaceGeometry:方法更新它以加工人脸几何。

ARFaceGeometry
A 3D mesh describing face topology used in face-tracking AR sessions
描述用于面部跟踪ARSession的面部拓扑的3D网格

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.

概述

该类为适用于各种渲染技术或用于导出3D Asset的3D网格提供了面部详细拓扑的一般模型。 (要使用SceneKit快速查看面部几何图形,请参阅ARSCNFaceGeometry类。)

当您从面部跟踪AR会话中的ARFaceAnchor对象获取面部几何体时,该模型符合检测到的面部的尺寸,形状和当前表达式。 您还可以使用名为混合形状系数的字典创建脸部网格,其中提供了有关脸部当前表情的详细但更有效的描述。

在AR会话中,您可以使用此模型作为覆盖用户脸部形状的内容的基础 - 例如,应用虚拟化妆或纹身。 您还可以使用此模型创建遮挡几何图形,该遮挡几何图形将其他虚拟内容隐藏在摄像机图像中检测到的脸部的3D形状后面。

Note

Face mesh topology is constant across ARFaceGeometry instances. That is, the values of the vertexCounttextureCoordinateCount, 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.

注意

面网格拓扑在ARFaceGeometry实例中保持不变。 也就是说,vertexCount,textureCoordinateCount和triangleCount属性的值始终不变,triangleIndices缓冲区始终描述相同的顶点排列,并且textureCoordinates缓冲区始终将相同的顶点索引映射到相同的纹理坐标。

只有顶点缓冲区在AR Session提供的面孔网格之间变化,指示顶点位置的变化,因为ARKit将网格调整为用户面部的形状和表情。

Accessing Mesh Data

vertexCount
The number of elements in the vertices buffer.
顶点缓冲中的元素数量。

Discussion

Face mesh topology is constant across ARFaceGeometry instances, so the value of this property is the same for all instances.

讨论

面网格拓扑在ARFaceGeometry实例中保持不变,因此此属性的值对于所有实例都是相同的。

vertices
A buffer of vertex positions for each point in the face mesh.
面网格中每个点的顶点位置的缓冲区。

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.

讨论

此缓冲区中的每个float3值表示网格中顶点的位置,以面坐标表示。 (请参阅跟踪脸部位置和方向。)

vertexCount属性提供缓冲区中元素的数量。

textureCoordinateCount
The number of elements in the textureCoordinates buffer.
textureCoordinates缓冲区中元素的数量。

Discussion

Face mesh topology is constant across ARFaceGeometry instances, so the value of this property is the same for all instances.

讨论

面网格拓扑在ARFaceGeometry实例中保持不变,因此此属性的值对于所有实例都是相同的。

textureCoordinates
A buffer of texture coordinate values for each point in the face mesh.
面部网格中每个点的纹理坐标值的缓冲区。

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.

讨论

此缓冲区中的每个float2值表示顶点缓冲区中相应索引处顶点的UV纹理坐标。

textureCoordinateCount属性提供缓冲区中元素的数量。

面网格拓扑在ARFaceGeometry实例中保持不变,因此此缓冲区中的数据始终将相同的顶点索引映射到相同的纹理坐标。

triangleCount
The number of triangles described by the triangleIndices buffer.
描述的三角形的数量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.

讨论

每组三个索引形成一个三角形,因此triangleIndices缓冲区中索引的数量是triangleCount值的三倍。

面网格拓扑在ARFaceGeometry实例中保持不变,因此此属性的值对于所有实例都是相同的。

triangleIndices
A buffer of indices describing the triangle mesh formed by the face geometry's vertex data.
索引缓冲区,用于描述由面几何的顶点数据形成的三角形网格。

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.

讨论

此缓冲区中的每个16位整数值都表示顶点和textureCoordinates缓冲区的索引。 每组三个索引都标识形成网格中单个三角形的顶点。 (也就是说,此缓冲区适合用作基于GPU渲染或创建3D模型 Asset文件的三角形网格的索引缓冲区。)

每组三个索引形成一个三角形,因此triangleIndices缓冲区中索引的数量是triangleCount值的三倍。

面网格拓扑在ARFaceGeometry实例中保持不变,因此此缓冲区始终描述相同的顶点排列。 只有顶点缓冲区在AR Session提供的面孔网格之间变化,指示顶点位置的变化,因为ARKit将网格调整为用户面部的形状和表情。


               Creating a Mesh from Blend Shapes


- initWithBlendShapes:
Creates a face geometry matching the facial expression described in the specified dictionary.
创建与指定字典中描述的面部表情匹配的面部几何。

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.
混合形状系数字典,用于描述特定脸部特征位置的脸部表情。 对于本字典中未指定的任何系数,ARKit假定值为0.0。

Return Value

A face geometry object, or nil if ARKit face tracking is not supported on the current device.

返回类型

面部几何对象,如果ARKit面部跟踪在当前设备上不受支持,则为零。

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字典中的每个键都是标识面部特征的ARBlendShapeLocation常量。 相应的值是该特征相对于内在配置的位置,范围从0.0(中性)到1.0(最大移动)。

该字典的格式与ARFaceAnchor blendShapes属性提供的格式相同。 您可以使用该属性和此初始化程序有效地保存和恢复面部表情数据; 混合形状词典的序列化形式比那些系数描述的脸部网格更容易携带。


Inherits From NSObject

Conforms To NSCopyingNSSecureCoding

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,736评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,167评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,442评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,902评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,302评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,573评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,847评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,562评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,260评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,531评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,021评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,367评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,016评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,068评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,827评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,610评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,514评论 2 269

推荐阅读更多精彩内容