How can I get the screen coordinates of a Unity3D ARFace?

53 views Asked by At

I'm making an Android Unity3D project that involves face tracking with ARFoundation, and I want to be able to access the coordinates on screen where a point of my face is located. That is to say, I don't want the 3D coordinates of a Transform, but the 2D coordinates as if they were relative to a Canvas object.

I've managed to have my face recognised and to place a Prefab in front of it, such as a FaceMesh or just a Sphere, and I'm also able to access both the ARFace object and the face prefab in my script. However, when I try to get the latter's coordinates calling FaceManager.facePrefab.transform.position, all I get are the coordinates of the Prefab in the Unity editor, and these coordinates are static; they don't change even if I move my face. I've tried plugging these coordinates into Camera.WorldToScreenPoint() just in case, but it also returned static coordinates.

As to the ARFace, I've also tried accessing its vertices and getting the coordinates of one of them, but these coordinates are relative to the centre of my face and only change slightly if I frown or open my eyes very wide or stuff like that; moving my face makes no difference.

I get the feeling that accessing the screen coordinates of the face prefab should be pretty simple since Unity is able to easily find my face and draw something on it, but so far I've achieved nothing.

I'd appreciate any help!

0

There are 0 answers