I am doing this Augmented Reality project starting from Xcode's default AR project.
I need to know the focal length of the camera used by ARKit.
This page defines Focal Length well:
Focal length, usually represented in millimeters (mm), is the basic description of a photographic lens. It is not a measurement of the actual length of a lens, but a calculation of an optical distance from the point where light rays converge to form a sharp image of an object to the digital sensor or 35mm film at the focal plane in the camera. The focal length of a lens is determined when the lens is focused at infinity.
Said that, Apple offers this camera matrix called intrinsics, defined as
According to Apple,
The values fx and fy are the pixel focal length, and are identical for square pixels. The values ox and oy are the offsets of the principal point from the top-left corner of the image frame. All values are expressed in pixels.
I am getting the same number for fx
and fy
, that is 1515.481
.
To obtain the real focal length in millimeters,
- This page says I need to use this formula:
F(mm) = F(pixels) * SensorWidth(mm) / ImageWidth (pixel)
but I don't have the sensor dimensions. - this other page says
FC = fx/sx = fy/sy
, wheresx
andsy
are the image dimensions width and height, what I suppose will give me two numbers, becausefx
=fy
... and this is back to square zero.
On iPhone 11, ARCamera captures a frame with the following dimensions: 1920x1440, at least this number is reported by the property camera.imageResolution
.
In the name of mental sanity, is there a way to get the focal length of ARCamera
used by RealityKit
?