MATLAB: How to calculate the focal length from an image
data importimage acquisitionimage processing
How do I get the focal length of an image taken using MATLAB (getsnapshot)
Best Answer
if the camera is of fixed focal length,using the camera caliberation toolbox,we can find the focal length as well as the extrinsic parameters.for that,use a chekerboard,take different photos of it at different angles and store them with a common basename..eg:image1, image2 etc..and add this folder to the current directory of matlab.then use the caliberation tool box.
but i dont know the case if the camera is autofocus..
Matt's is almost correct. The extrinsics R and t represent the transformation from the world coordinates into camera's coordinates. Sot is not the camera center. You have to rotate as well. The only problem with Matt's solution is that it does not follow the vector-matrix multiplication convention used by the Computer Vision System Toolbox. The camera center in the world coordinates is
c = -t * R';
becauset is a row vector.
Also, you do not have to use one of your calibration images. You can calibrate your cameras and then take a new picture of a checkerboard, and use theextrinsics function to compute the R and t relative to that board. See thisexample.
The magnification of a positive lens is M=f/(f-v) (see wikipedia), with f the focal length and v the distance of the center of the lens to the object. So if you can find the magnification with your pixel difference and know distance to the lens, you can find it with this formula.
It is also written on the lens in 99% of the cases.
Best Answer