ARFaceAnchor

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

有關(guān)在面部跟蹤AR Session中檢測(cè)到的人臉姿態(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ì)在用前置攝像頭檢測(cè)到用戶(hù)的臉部時(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è)變換矩陣來(lái)定位想要“附加”到AR場(chǎng)景中的臉部的虛擬內(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),它符合通用面部模型以匹配檢測(cè)到的面部的尺寸,形狀和當(dāng)前表達(dá)式。

您可以使用此模型作為覆蓋用戶(hù)臉部形狀的內(nèi)容的基礎(chǔ) - 例如,應(yīng)用虛擬化妝或紋身。 您還可以使用此模型創(chuàng)建遮擋幾何圖形 - 一種不會(huì)呈現(xiàn)任何可見(jiàn)內(nèi)容(允許攝像機(jī)圖像顯示)的3D模型,但會(huì)妨礙相機(jī)對(duì)場(chǎng)景中其他虛擬內(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í)模型,通過(guò)一系列多個(gè)命名系數(shù)進(jìn)行描述,這些系數(shù)表示特定面部特征相對(duì)于其中配置的移動(dòng)。 您可以使用混合形狀系數(shù)按照用戶(hù)面部表情的方式為2D或3D內(nèi)容(如角色或頭像)制作動(dòng)畫(huà)。


? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Using Face Geometry


geometry
A coarse triangle mesh representing the topology of the detected face.
表示檢測(cè)到的臉部拓?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ū),使通用臉部模型符合檢測(cè)臉部的尺寸,形狀和當(dāng)前表達(dá)式。

您可以通過(guò)將這些緩沖區(qū)傳遞給您的首選渲染引擎來(lái)可視化人臉幾何。 要使用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.

概述

該類(lèi)為適用于各種渲染技術(shù)或用于導(dǎo)出3D Asset的3D網(wǎng)格提供了面部詳細(xì)拓?fù)涞囊话隳P汀?(要使用SceneKit快速查看面部幾何圖形,請(qǐng)參閱ARSCNFaceGeometry類(lèi)。)

當(dāng)您從面部跟蹤AR會(huì)話(huà)中的ARFaceAnchor對(duì)象獲取面部幾何體時(shí),該模型符合檢測(cè)到的面部的尺寸,形狀和當(dāng)前表達(dá)式。 您還可以使用名為混合形狀系數(shù)的字典創(chuàng)建臉部網(wǎng)格,其中提供了有關(guān)臉部當(dāng)前表情的詳細(xì)但更有效的描述。

在AR會(huì)話(huà)中,您可以使用此模型作為覆蓋用戶(hù)臉部形狀的內(nèi)容的基礎(chǔ) - 例如,應(yīng)用虛擬化妝或紋身。 您還可以使用此模型創(chuàng)建遮擋幾何圖形,該遮擋幾何圖形將其他虛擬內(nèi)容隱藏在攝像機(jī)圖像中檢測(cè)到的臉部的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í)例中保持不變。 也就是說(shuō),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)整為用戶(hù)面部的形狀和表情。

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)。 (也就是說(shuō),此緩沖區(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)整為用戶(hù)面部的形狀和表情。


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

返回類(lèi)型

面部幾何對(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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,197評(píng)論 6 531
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 98,415評(píng)論 3 415
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人,你說(shuō)我怎么就攤上這事。” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 176,104評(píng)論 0 373
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我,道長(zhǎng),這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 62,884評(píng)論 1 309
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 71,647評(píng)論 6 408
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 55,130評(píng)論 1 323
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,208評(píng)論 3 441
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 42,366評(píng)論 0 288
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 48,887評(píng)論 1 334
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 40,737評(píng)論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 42,939評(píng)論 1 369
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,478評(píng)論 5 358
  • 正文 年R本政府宣布,位于F島的核電站,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,174評(píng)論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 34,586評(píng)論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 35,827評(píng)論 1 283
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 51,608評(píng)論 3 390
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 47,914評(píng)論 2 372

推薦閱讀更多精彩內(nèi)容