I have a fair background with camera geometry, but I am new to Swift and ARKit development, and I am getting a bit confused between the different types of transform matrices that can be returned.
In particular, one tutorial I followed had me grabbing the ARSCNView as sceneView and then printing sceneView.pointOfView.transform. This showed me what I expect: when the session is begun, the 4x4 matrix is very close to identity.
However, when using the ARCamera associated with each ARFrame, as in this code snippet:
extension ViewController: ARSessionDelegate {
func session(_ session: ARSession, didUpdate frame: ARFrame) {
print(frame.camera.transform.transpose)
}
}
I instead get a camera matrix that looks like (note the transpose is on purpose as I am more familiar with the row-major layout):
[0 1 0 0]
[-1 0 0 0]
[0 0 1 0]
[0 0 0 1]
I've tried explicitly the ARWorldAlignment property to .gravity and .gravityAndHeading, but neither produces the expected identity matrix when the session is run.
I also added the .showWorldOrigin debug option, which shows the world axes as I would expect: +X to the right of my phone, +Y up, and -Z down the view axis.
What am I missing here? Can someone please clarify the coordinate systems of the transforms that ARFrame is returning and how they differ from those of ARSCNView?