I am using ARKit3.
I tried DL the sample code from the following URL.
Tracking and Visualizing Faces
https://developer.apple.com/documentation/arkit/tracking_and_visualizing_faces
I tried to get a face rotation value by inserting a print statement into TransformVisualization.swift as shown in the code below.
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
guard #available(iOS 12.0, *), let faceAnchor = anchor as? ARFaceAnchor else { return }
print(faceAnchor.transform.columns.2)
rightEyeNode.simdTransform = faceAnchor.rightEyeTransform
leftEyeNode.simdTransform = faceAnchor.leftEyeTransform
}
faceanchor.transform can get 4x4 matrix.
Doesn't faceanchor.transform.columns.2 contain head rotation values?
When I actually moved my head and checked the printed numbers, the values of rotation.x(faceAnchor.transform.columns.2.x) and rotation.y(faceAnchor.transform.columns.2.y) were obtained correctly.
However, the initial value of rotation.z(faceAnchor.transform.columns.2.z) is strange, and hardly changes even if I move my head.
How can I get the rotation value around the Z axis?
Doesn't faceanchor.transform.columns.2 contain head rotation values?
No. Transformation matrix is sort of combined representation of rotation, translation and scaling.
Any of the rows does not contain rotation values separately.
You can find how to separate the rotation matrix from the transformation matrix, if you learn 4x4 transformation matrix theory.
I do not understand what you mean by rotation values, but there may be some ways to calculate it from the transformation matrix.
You would have a better chance that some ARKit experts find your your question, if you choose an appropriate topic area: ARKit