Ask Your Question
1

Are cv::fisheye::undistortImage and (cv::initUndistortRectifyMap + cv::remap) different ?

asked 2016-07-04 07:44:55 -0500

Major Squirrel gravatar image

updated 2016-07-07 02:48:23 -0500

Hello there,

I am having trouble understanding the functioning of both processes as written in the title.

I am working with a micro-camera (with which seems a barrel distortion) and I would like to undistort the frames given by the camera. I am not working with the camera calibration at the moment, because the micro-camera vendor (DFRobot) already provides the distortion coefficients for this type of lens. I am just having fun with the different functions for the camera calibration. Here are some basic points that might help to understand:

  • The frame has a size of 640x480.
  • The X center projection is assumed to be 320.
  • The Y center projection is assumed to be 240.
  • The focal length is manually set to 544 (for both fx and fy).
  • The R matrix (the rectification transformation matrix) is set as an identity matrix.
  • The newCameraMatrix is set using cv::getOptimalNewCameraMatrix.

This is a picture taken when I execute my program using cv::fisheye::undistortImage :

image description

I was expecting to get the same result using cv::initUndistortRectifyMap and cv::remap, because the OpenCV documentation for undistortImage stipulates :

The function is simply a combination of fisheye::initUndistortRectifyMap (with unity R ) and remap (with bilinear interpolation).

Here is what I am getting using both functions above :

image description

Why is that ? I don't really understand, I might miss something over there. I can provide some code for further help if needed. :)

Have a good day !

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-07-07 02:52:38 -0500

Major Squirrel gravatar image

See my comment behind @Tetragramm answer : I was using a function from the wrong module !

You get the same result between cv::fisheye::undistortImage and cv::fisheye::initUndistortRectifyMap + cv::remap, but if you use cv::initUndistortRectifyMap + cv::remap it seems that the transformation is contained in the frame (meaning no loss of data, the frame isn't cropped on the corners).

edit flag offensive delete link more
1

answered 2016-07-04 12:13:25 -0500

Tetragramm gravatar image

getOptimalNewCameraMatrix is the difference, I believe. Notice how the right picture on top has no black to the left or right, where the one on the bottom does. The image is being scaled so that that is removed. Set the free scaling parameter in the Optimal... function to 1 and try again.

edit flag offensive delete link more

Comments

Hello @Tetragramm, sorry for the delay.

I figured out that I was using the wrong function : I was using cv::initUndistortRectifyMap instead of cv::fisheye::initUndistortRectifyMap

The thing I don't understand is : what is the difference between the fisheye module and the imgproc for these functions ?

Major Squirrel gravatar imageMajor Squirrel ( 2016-07-06 09:25:22 -0500 )edit
1

The Detailed Description section on this page explains the normal camera model while the Detailed Description on this page explains the fisheye camera model.

In short, the distortion coefficients mean something different.

Tetragramm gravatar imageTetragramm ( 2016-07-06 17:34:43 -0500 )edit

Thank you for pointing me the detailed description of both modules. :)

Major Squirrel gravatar imageMajor Squirrel ( 2016-07-07 02:38:18 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-07-04 07:44:55 -0500

Seen: 2,822 times

Last updated: Jul 07 '16