I posted this question over on Stack Overflow, but someone suggested this site might be of more help to me.
I'm doing a college project where I'm trying to calculate the focal length of a camera from a photo. The project is part of my final year computing course (that's why I assumed Stack Overflow would be the best place to ask)
I'm using vanishing lines identified by the user to try and calculate the focal length. say you have a cube, the user can select 3 sides to intersect. For each side, 2 lines are drawn to infinity. Where 2 lines intersect = intersection point. This is done for all 3 sides giving 3 intersection points. These points are then used to draw a new triangle and from this triangle to focal length can be calculated as shown in this research. But my values are way off. For this image the focal length is known as 18mm but the value I get is 478.634....
Would anyone have any experience with this type of problem?
I have also come across this formula on this website. Does anyone know what
alphaX (fx = (imageWidth)2*tan(alphaX))
Any help would be appreciated
Ive made a few pics to show how I calculate the focal length (images not to scale or size). Starting with a photo of a cube I extend each one of the 3 sides till they intersect (shown by the green dots). Then using those intersection points I construct a rectangle as shown here . Then I calculate the ortho-centre of the triangle. Then using the formula here I calculate the focal length as shown here . In my application the focal length is simply a value (integer) that is calculated from the square root of the length of the intersecting points (IP1) to the centre, multiplied by the length from the centre to the opposite midpoint (MP2)