1

I am trying to undistort a barrel/radial distortion from an image. When I see the equations they do not require the focal length of the camera. But the openCV API initundistortrectifymap requires them in form of the camera intrinsic matrix. Why so ? Anyway to do it without them? Because I understand the undistort is common for various distortion corrections.

vvvv
  • 135
  • 10

1 Answers1

1

The focal length is essential in distortion removal -since it provides info on the intrinsic parameters of the camera- and it is fairly simple to add it to the camera matrix. Just remember that you have to convert it from millimeters to pixels. This is done to ensure that the pixels are rectangular. For the conversion you need to know the sensor's height and width in millimeters, the horizontal (Sh) and vertical (Sv) number of pixels of the sensor and the focal length in millimeters. The conversion is done using the following equations:
fx = (f(mm) x Sh(px))/sensorwidth(mm)
fy = (f(mm) x Sv(px))/sensorheight(mm)

More on the camera matrix elements can be found here.

Nikos
  • 198
  • 1
  • 9
  • Hi, thanks for the answer. In the link you mentioned, the equations of xcorrected and ycorrected do not require fx and fy. This is what made me wonder whether we really need them ? – vvvv Jul 14 '16 at 10:43
  • The equations you mention are used to calculate the pixel position after the removal of the radial distortion (first set of equations) and the tangential distortion (second set of equations). If you look after these equations you will notice an equation that is composed by 3 matrices. The first matrix after the '=' is the camera matrix. You will see the elements fx, fy, cx and cy. The two latter elements (cx and cy) are the principal point offset in the x and y direction accordingly. These two, as well as the focal length, can be calculated after a camera calibration. – Nikos Jul 14 '16 at 11:57
  • Also, if you don't know the value for the cx and cy, you can assume that the p.p. has no offset (it is exactly at the center of the image), so you give both the value 0. Though personally I have never seen a camera with 0 p.p. offset, which is completely normal and caused due to manufactoring imperfections of the optical system. – Nikos Jul 14 '16 at 12:01