首页 > 解决方案 > Place Graphic on Forehead ARFaceGeometry Vertex

问题描述

I'm trying to find the way to reference ARFaceGeometry mesh indices in order to place graphics on specific parts of a face using ARKit.

I've seen a number of examples where the feature is placed with some index number but I cannot find any reference to this list. It seems there are over 1200 locations. One tutorial used index 1064 for the left eye. What is the source of those numbers? and it seems poor practice to reference a hard number - what if Apple adds more?

Just for example purposes, let's say I made a tattoo graphic and wanted to attach it to the user forehead. How do I find a reference?

I can paste a graphic over a nose like this - but again, I cannot find a list of the numbered vertices - I am blindly using a number someone mentioned.

func updateFeatures(for node : SCNNode, using anchor : ARFaceAnchor) {

    let child = node.childNode(withName: "myNose", recursively: false) as? MyGraphicNode
    let vertices = [anchor.geometry.vertices[9]]
    child?.updatePosition(for: vertices)

}

Any guidance would be appreciated.Xcode 10 beta 6, iPhoneX

标签: iosxcodearkit

解决方案


虽然到目前为止,ARFaceGeometry网格在所有 iOS 11.x 版本和 iOS 12 测试版中都保持稳定——并且至少可以保证在一个会话中保持拓扑稳定——但没有说 Apple 是否或何时会改变网格(例如,有更多的顶点)。并且没有用于语义标记顶点的 API。

因此,正如您所怀疑的,如果您通过反复试验找出该点的相应顶点索引,则可以将3D 艺术资产锚定到兴趣点(如鼻尖或左眼外角或其他任何地方) ,但很难知道该索引在未来的 iOS 版本、未来的硬件等中是否仍然有意义。

但是,您说的是“纹身图形”,这听起来像是 2D 艺术资产——您想要的视觉效果可能不是将平面固定到 3D 脸上,而是让您的 2D 艺术看起来好像印在皮肤上. 在这种情况下,您根本不想处理顶点。只需将纹理图像应用于几何体/材质 - 与网格拓扑不同,更容易想象纹理映射坐标在不同版本中保持不变,因为几何体可以更改而纹理保持不变。找到纹理图像的哪些区域适用于面部的哪些区域可能再次需要反复试验,但是一旦找到结果,您就可以无限期地重复使用它。


推荐阅读