0

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

JohnSF
  • 3,736
  • 3
  • 36
  • 72
  • Check this out: https://github.com/bobbymay/ARFaceGeometry-Map – Bobby Nov 25 '19 at 01:20
  • At first glance that looks like it could do the trick. I will test it to see if the vertex numbers are repeatable. Thanks. – JohnSF Nov 25 '19 at 19:12
  • The vertex numbers have been the same since iPhone X, but it might change in the future. There's no other way to get those positions that I could find. – Bobby Nov 26 '19 at 18:14

1 Answers1

2

While, thus far, the ARFaceGeometry mesh has remained stable across all iOS 11.x releases and iOS 12 betas — and it's at least guaranteed to stay topographically stable within a session — there's no saying if or when Apple might change the mesh (say, to have more vertices). And there's no API for semantically labeled vertices.

So, as you suspect, it's possible to anchor 3D art assets to points of interest (like the tip of the nose or the outside corner of the left eye or whatever) if you figure out the corresponding vertex index for that point by trial and error, but it's hard to know whether that index will remain meaningful in future iOS builds, future hardware, etc.

However, you're talking about a "tattoo graphic", which sounds like a 2D art asset — your desired visual effect is probably not to anchor a flat surface to the 3D face but for your 2D art to appear as if printed on the skin. In that case, you don't want to deal with the vertexes at all. Just apply a texture image to the geometry / material — unlike the mesh topology, it's easier to imagine the texture mapping coordinates staying the same across releases, because the geometry can be changes while the texture stays the same. It may again take some trial and error to find which areas of a texture image apply to which areas on the face, but once you've found your result you can reuse it indefinitely.

rickster
  • 124,678
  • 26
  • 272
  • 326
  • Thanks. I guess that's why I could not find the info. Yes, I see that your suggestion for the tattoo is a better approach. I'll give it a shot. I would still like to be able to apply 3D items to the face too, but maybe I'll have to wait on that until some future changes. I have indeed mapped rough items like "00" for glasses with an occlusion node, but it was totally trial and error to find the right place. Certainly not good for generalities. – JohnSF Aug 23 '18 at 22:29
  • Texture map! Apply directly to forehead. – rickster Aug 24 '18 at 00:24
  • @rickster Sorry to bother you…… I'm struggling with a SceneKit problem could you help me out? Question:https://stackoverflow.com/questions/52428397/confused-about-orthographic-projection-of-camera-in-scenekit – ooOlly Sep 23 '18 at 12:07