Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

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::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 !

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

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::undistortImagecv::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 !