I am trying to understand the exact definition of the face transform returned by getCenterPose(), so I can get the position and orientation of the face center relative to the physical camera/phone, for tracking the user.
The code extract shows how the tracking matrix is found:
Frame frame = session.update();
Camera camera = frame.getCamera();
float[] cameraMatrix = new float[16];
float[] faceMatrix = new float[16];
float[] trackingMatrix = new float[16];
// Find camera pose as matrix
cameraPose.toMatrix(cameraMatrix, 0);
Log.d("cameraMatrix ", Arrays.toString(cameraMatrix));
Collection<AugmentedFace> faces = session.getAllTrackables(AugmentedFace.class);
for (AugmentedFace face : faces) {
// Find faceMatrix used for drawing face graphics
face.getCenterPose().toMatrix(faceMatrix, 0);
// Find face center pose relative to camera,
// convert to matrix for tracking applications.
cameraPose.inverse().compose(face.getCenterPose()).toMatrix(trackingMatrix, 0);
Log.d("faceMatrix", Arrays.toString(faceMatrix));
Log.d("trackingMatrix", Arrays.toString(trackingMatrix));
// final float t[] = faceMatrix;
final float t[] = trackingMatrix;
Log.d( "P ", String.format("value = %.2f %.2f %.2f", t[12], t[13], t[14] ) );
Log.d( "N ", String.format("value = %.2f %.2f %.2f", t[8], t[9], t[10] ) );
}
If the user moves their face while keep orientation fixed, then both the translation and orientation parts of faceMatrix change, so the orientation part does not capture the user face orientation. In fact the frame vector “N” (out from the nose) is always (0,0,1) when facing directly towards the physical camera. Since arcore pose is relative to the world coordinates, which can change, trackingMatrix was calculated which is the face pose relative to the camera. However trackingMatrix also does not match with the physical pose.
Clearly the Augmented Faces is doing a good job, because faceMatrix is used to plot the face overlay, which registers perfectly, however I cannot yet relate this to the physical face pose relative to the camera.
ddddmmmm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.