OpenSfM
OpenSfM copied to clipboard
Fix: Arbitrary focal plane and length conversion to 35 mm film focal length
https://github.com/mapillary/OpenSfM/blob/2005aae849ae5c43e781c2ae8ced1d550e36675e/opensfm/exif.py#L63-L64
Apparently, OpenSfM assumes or works with 35 mm film focal length internally (I was not aware of that), which is not great but okay. Anyhow, the current conversion from an arbitrary focal plane and length to full-frame/35 mm film focal length is incomplete, to say the least. So, you get things like this.
To fix this we have to compute the true equivalent focal length in 35 mm film:
focalLengthIn35mmFilm = focalLength /
sqrt(focalPlaneWidth^2 + focalPlaneHeight^2) *
sqrt(36.0^2 + 24.0^2)
We have to convert to 35 mm film via the focal plane’s hypotenuse because we have to take into account all the different aspect ratios which are out there.
Besides, I would also prefer evaluating FocalLength
, FocalPlaneXResolution
, FocalPlaneYResolution
first before evaluating FocalLengthIn35mmFilm
because FocalLengthIn35mmFilm
is just a lazy imprecise equivalent of the true focal length; it is an integer value of type Short
in the Exif metadata header. Exactly for that reason the fully precise FocalLength
, FocalPlaneXResolution
, FocalPlaneYResolution
(and FocalPlaneResolutionUnit
) Exif tags have been introduced after FocalLengthIn35mmFilm
has been found or deemed unfit for many purposes. The amount of deviation caused by FocalLengthIn35mmFilm
’s imprecision does not seem like much on a per image basis but it accumulates rapidly over many images (like OpenSfM is used). Note, that it is still okay for OpenSfM to use the 35 mm film focal length internally because we can compute fractions of millimeters in the metadata extraction step.
@paulinus Do you want me to create a PR or would you like to add a quick fix?