Ask Your Question
2

Conversion focal distance from mm to pixels

asked 2013-07-19 01:55:15 -0600

tenta4 gravatar image

updated 2013-07-19 03:00:40 -0600

berak gravatar image

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 flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
7

answered 2013-07-20 05:46:11 -0600

Nghia gravatar image

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)

edit flag offensive delete link more

Comments

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.

tenta4 gravatar imagetenta4 ( 2013-07-24 06:12:26 -0600 )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

Hemang gravatar imageHemang ( 2017-10-30 13:24:24 -0600 )edit

Hi, I have the below questions, could you please throw some light?

  1. How do I calculate Cx and Cy, given the focal_mm, sensor_width_mm and image_width_in_pixels?
  2. Is "image_width_in_pixels" the maximum width of the sensor or the one application receives. For example, my sensor can support maximum of 1600x1300. However, in my application I'm getting 1280x720. So should I use Sensor width as 1600 or 1280?

Thank you.

santo4_opencv gravatar imagesanto4_opencv ( 2020-04-26 01:10:18 -0600 )edit
-3

answered 2013-07-19 03:19:34 -0600

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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-07-19 01:55:15 -0600

Seen: 43,277 times

Last updated: Jul 20 '13