Can focal length be calculated from vanishing points in a single photo?
Asked 3/23/2012
1 views
2 answers
0
I’m trying to estimate a camera’s focal length from one photograph for a college computing project. My approach uses user-marked vanishing lines: for three sets of parallel edges in the scene, I extend the lines to get three vanishing points, then use the triangle formed by those points to estimate the camera geometry.
The problem is that my result is far from the known lens value. For an image said to be shot at 18mm, my calculation gives about 478.6.
Am I misunderstanding how focal length can be recovered from perspective geometry? Do vanishing-point methods require extra calibration information such as sensor size or known real-world angles? If sensor size is unknown, is angle of view the better quantity to calculate instead of focal length?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
14y ago
2 Answers
10
(1) By inspection it is "clear" [tm] that a relatively wide angle lens is in use. In a 35mm full frame system a guesstimate far far far closer to 18mm than 480 mm would be arrived at.
(2) Without having got my brain fully around the triple vanishing point method described in a reference, I would think that for vanishing points to be relevant you would need to deal with lines which were parallel in reality but rendered apparently not so by perspective OR perhaps wit lines whose actual interposing angle was known and which were rendered at another apparent angle in the image. However, in the example photo given, the actual angle between the two walls on either side of the island seems to be arbitrary and unknown (except to their builders) and that changing this angle changes the answer you would get. HOWEVER, I may just be wholly missing the point :-).
(3) I am reasonably certain that the formula quoted by the original poster in your reference as
- fx = (imageWidth)2*tan(alphaX))
Is intended to read
- fx = (imageWidth) / (2 * tan(alphaX) )
Where:
fx = focal length
imagewidth = sensor width
alphaX = HALF angle of view
This is consistent with the diagram below whose precision of rendition will hopefully be excused or ignored. The above formula then reduces to a simple geometric statement.
I have used slightly different terms to assist and/or confuse the mental process :-)

HALF the angle of view = alpha has tan(alpha) = Y/X = height/distance.
The identical tan is produced by half the image height on the sensor / focal length.
So
(sensor_height/2) / focal_length = height/distance = tan (alpha)
so
(IW/2) / fx = tan_alpha
invert
fx / (Iw/2) = 1/tan_alpha
fx = Iw/(2 x tan_alpha)
Originally by user6263. Source · Licensed CC BY-SA 4.0
user6263
14y ago
0
Generated from our catalog & community — verify before relying on it.
Yes—your result can be numerically correct in image-space units while still not being 478.6 mm.
Vanishing points from a single photo let you recover camera geometry only up to the scale of the image unless you also know a calibration value, especially sensor size (or equivalent camera intrinsics). Without that, the computed value is not in millimeters, so it can’t be directly compared to an 18mm lens specification.
Also, vanishing-point methods depend on using scene lines that are parallel in the real world, or on having known real-world angles. If the angles in the scene are unknown, the estimate can be wrong.
So the likely issues are:
- missing camera calibration / sensor dimensions
- comparing image-space units to millimeters
- possibly using lines whose real-world relationships aren’t known well enough
If you don’t know the sensor size, a better target is angle of view rather than focal length, because it avoids needing to convert into mm.
If you want a practical reference, tools like fSpy use 1-, 2-, or 3-point perspective to estimate camera position, rotation, and focal length from an image.
Recommended products
UniqueBot
AI14y ago
Your Answer
Related Questions
How can I estimate horizontal field of view from one image using vanishing points?
How can I estimate an object's real size from one image if I know the camera-to-subject distance?
Can smartphone autofocus distance be used to measure a nearby object's size accurately?
Can moving the camera and comparing object size in the frame be used to estimate distance?
Can you estimate camera tilt from vanishing points in a single photo?