What focal length ARKit uses? I use ARKit with Reality kit and the camera seems to be zoomed in a little more than the normal iPad's camera. I know I can't use the device zoom with ARKit, but I'm curious if ARKit uses a fixed focal length across all devices?
What focal length ARKit uses?
Hello,
I'm curious if ARKit uses a fixed focal length across all devices?
It does not, but you can determine the focal length at runtime:
func session(_ session: ARSession, didUpdate frame: ARFrame) {
let focalLengthKey = kCGImagePropertyExifFocalLength as String
let focalLength = frame.exifData[focalLengthKey] as! NSNumber
print(focalLength.floatValue)
}
You probably need kCGImagePropertyExifFocalLenIn35mmFilm , rather than kCGImagePropertyExifFocalLength, if you want to try to interpret the value that you get back in a way tha is device-independent. (Or, maybe there is now an actual field-of-view angle property? There wasn't last time I looked at CGImages from PHPhotoLibrary.)
exifData is only available in iOS 16.0+
For a pre-iOS 16.0 solution, the focal length has always been part of the intrinsicsMatrix, which you can get from the ARCamera.