可以使用原始顶点而不是 blendShapes 创建一个 ARFaceGeometry 实例,就像 ARSession 在 运行 和 ARFaceTrackingConfiguration 时所做的那样吗?

Can one create an ARFaceGeometry instance with raw vertices instead of blendShapes, like ARSession does when run with ARFaceTrackingConfiguration?

ARFaceGeometry 有一个用于混合形状数组的初始化方法,但是如何使用 ARFaceGeometry 顶点数组创建这个对象?

在 Apple 的 Creating Face-Based AR Experiences 中,向 ViewController 传递了一个 ARFaceTrackingConfiguration 实例,因此 ARSession 似乎创建了一个 ARFaceAnchor 实例,并使用 TrueDepth Camera 跟踪的面部保持更新。这在 VirtualContentUpdater 中的 ARSession 委托的渲染器方法 renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) 中可以清楚地看到。

由于此 ARAnchor 的 ARFaceGeometry 已通过 VirtualContentUpdater 中的 virtualFaceNode?.update(withFaceAnchor: faceAnchor) 成功更新以匹配面部的当前状态,并且在 Mask 作为几何图形的情况下通过 faceGeometry.update(from: anchor.geometry) ,它必须是真的在幕后某处,正在从比 blendShapes 提供的更高分辨率的数据(TD 相机)创建或更新 ARFaceGeometry 实例。

你知道这是怎么发生的吗?我自己会怎么做?如果不知道,你知道我如何找到幕后代码来挖掘并发现它是如何使用的吗?使用 iOS 库的此类非 public 部分可行吗?

抱歉,我对 swift 和 iOS 开发生态系统非常陌生,所以我不确定 where/how 能否找到相关代码,或者它是否可用.非常感谢任何想法或帮助,非常感谢!

ARFaceGeometry has a vertices property and according to the documentation

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 已经根据 ARFaceAnchor 内部状态发生了变化。它是如何完成的完全是 ARKit 内部的,没有公开。

ARFaceGeometry 的顶点位置然后仅用于更新 ARSCNFaceGeometry 的顶点位置,ARSCNFaceGeometrySCNGeometry.[=20= 的子类]

从你对@mnuages 的回答的评论来看,你的问题听起来并不是真正关于操纵 ARSCNFaceGeometry — 它是关于尝试将在一台设备上获得的面部几何数据发送到另一个设备然后渲染它(使用 SceneKit)。

有两个很好的方向可以解决这个问题:

尝试混合形状

您假设传输 blendShapes 不会给您想要的结果,但您尝试过吗?根据我的经验,从 ARFaceAnchor 拉动 faceGeometry 与拉动锚点的 blendShapes 然后使用它们创建新的 ARFaceGeometry 产生几乎相同的结果。

自带几何

ARSCNFaceGeometry 无法从“原始”顶点数据进行初始化。但它的超类 SCNGeometry 确实:

  1. 事先,为 ARFaceGeometry 的文档注释为静态的数据部分创建 SCNGeometrySourceSCNGeometryElement 实例:textureCoordinatestriangleIndices 个缓冲区。

  2. 当你从 ARKit 获得一个新的面部锚点时,从它的 vertices 数据创建一个 SCNGeometrySource。然后使用您事先制作的顶点源和纹理坐标源和几何元素创建一个 SCNGeometry

  3. 在节点上设置新的几何体,然后就可以渲染了。

(在 SceneKit 中可能有更有效的方法来处理这个顶点数据,但这应该足以让你得到你的第一个可见结果,至少。另外,抱歉......没有代码,因为我目前写在 iPad 上——但检查文档中提到的符号,其余的应该清楚。)