# Conversion focal distance from mm to pixels

For my calculations i need the local length in pixels(opencv format). The andriod API getFocusDistances(float[]) give me the focal length in mm. I try to convert from mm to pixels

In opencv exists the function cv::CalibrationMatrixValues that convert from pixels to mm. I want to do the inverse conversion (based on the function's source code). But i can't understand the apertureWidth and apertureHeight parameters.

Can someone help me?

edit retag close merge delete

Sort by » oldest newest most voted

Depending on how accurate you need the focal you can get a good quick estimate if you know either of the following:

• CCD/CMOS sensor physical size
• Horizontal field of view (FOV)

If you know the sensor's physical width in mm, then the focal in pixels is:

focal_pixel = (focal_mm / sensor_width_mm) * image_width_in_pixels

And if you know the horizontal field of view, say in degrees,

focal_pixel = (image_width_in_pixels * 0.5) / tan(FOV * 0.5 * PI/180)

more

Thank you for answer. Unfortunately the android API return the correct values of FOV not for all devices, That's why i use OpenCV autocalibration APIs, namely cv::СalibrateСamera.

( 2013-07-24 06:12:26 -0500 )edit

I am getting different results using image sesnor size and foca length size in mm i.e focal length is 4.25mm, horizontal field of view is 85 degrees and sensor width is 6.9 mm so when I use first equation answer is 394 and the second equation gives me 293

( 2017-10-30 13:24:24 -0500 )edit

I think that google'ing isn't that hard right? The aperture is the width of the opening before your CCD or CMOS sensor and it defines the amount of light that is entering the camera.

An ideal model makes this a point, leading to a single dot focal point. However, in real situations this aperture can be adapted to get more of less light through at a single shot. It is a camera specific setting, which is in the metadata of most images taken with decent camera equipment.

more