[][src]Function opencv::imgproc::undistort

pub fn undistort(
    src: &dyn ToInputArray,
    dst: &mut dyn ToOutputArray,
    camera_matrix: &dyn ToInputArray,
    dist_coeffs: &dyn ToInputArray,
    new_camera_matrix: &dyn ToInputArray
) -> Result<()>

Transforms an image to compensate for lens distortion.

The function transforms an image to compensate radial and tangential lens distortion.

The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap (with bilinear interpolation). See the former function for details of the transformation being performed.

Those pixels in the destination image, for which there is no correspondent pixels in the source image, are filled with zeros (black color).

A particular subset of the source image that will be visible in the corrected image can be regulated by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate newCameraMatrix depending on your requirements.

The camera matrix and the distortion parameters can be determined using #calibrateCamera. If the resolution of images is different from the resolution used at the calibration stage, inline formula and inline formula need to be scaled accordingly, while the distortion coefficients remain the same.

Parameters

  • src: Input (distorted) image.
  • dst: Output (corrected) image that has the same size and type as src .
  • cameraMatrix: Input camera matrix inline formula .
  • distCoeffs: Input vector of distortion coefficients inline formula of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  • newCameraMatrix: Camera matrix of the distorted image. By default, it is the same as cameraMatrix but you may additionally scale and shift the result by using a different matrix.

C++ default parameters

  • new_camera_matrix: noArray()