ARFaceAnchor

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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末筋蓖,一起剝皮案震驚了整個(gè)濱河市扭勉,隨后出現(xiàn)的幾起案子苛聘,更是在濱河造成了極大的恐慌设哗,老刑警劉巖,帶你破解...
    沈念sama閱讀 221,695評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件震缭,死亡現(xiàn)場離奇詭異拣宰,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)膛堤,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,569評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門肥荔,熙熙樓的掌柜王于貴愁眉苦臉地迎上來朝群,“玉大人,你說我怎么就攤上這事誉帅《碌冢” “怎么了隧出?”我有些...
    開封第一講書人閱讀 168,130評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵胀瞪,是天一觀的道長。 經(jīng)常有香客問我圆雁,道長伪朽,這世上最難降的妖魔是什么汛蝙? 我笑而不...
    開封第一講書人閱讀 59,648評(píng)論 1 297
  • 正文 為了忘掉前任窖剑,我火速辦了婚禮,結(jié)果婚禮上讶舰,老公的妹妹穿的比我還像新娘跳昼。我一直安慰自己,他們只是感情好欣除,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,655評(píng)論 6 397
  • 文/花漫 我一把揭開白布历帚。 她就那樣靜靜地躺著杠娱,像睡著了一般摊求。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上睹栖,一...
    開封第一講書人閱讀 52,268評(píng)論 1 309
  • 那天野来,我揣著相機(jī)與錄音踪旷,去河邊找鬼令野。 笑死,一個(gè)胖子當(dāng)著我的面吹牛聊浅,可吹牛的內(nèi)容都是我干的现使。 我是一名探鬼主播,決...
    沈念sama閱讀 40,835評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼苦蒿,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了团滥?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,740評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤拱燃,失蹤者是張志新(化名)和其女友劉穎碗誉,沒想到半個(gè)月后父晶,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體甲喝,經(jīng)...
    沈念sama閱讀 46,286評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡埠胖,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,375評(píng)論 3 340
  • 正文 我和宋清朗相戀三年直撤,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片汽馋。...
    茶點(diǎn)故事閱讀 40,505評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡豹芯,死狀恐怖驱敲,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情握牧,我是刑警寧澤娩梨,帶...
    沈念sama閱讀 36,185評(píng)論 5 350
  • 正文 年R本政府宣布狈定,位于F島的核電站习蓬,受9級(jí)特大地震影響措嵌,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜枫慷,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,873評(píng)論 3 333
  • 文/蒙蒙 一或听、第九天 我趴在偏房一處隱蔽的房頂上張望笋婿。 院中可真熱鬧萌抵,春花似錦、人聲如沸霎桅。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,357評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽锻霎。三九已至,卻和暖如春吏口,著一層夾襖步出監(jiān)牢的瞬間冰更,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,466評(píng)論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留谆刨,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,921評(píng)論 3 376
  • 正文 我出身青樓,卻偏偏與公主長得像生兆,于是被迫代替她去往敵國和親膝宁。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,515評(píng)論 2 359

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