[][src]Function opencv::calib3d::get_optimal_new_camera_matrix

pub fn get_optimal_new_camera_matrix(
    camera_matrix: &dyn ToInputArray,
    dist_coeffs: &dyn ToInputArray,
    image_size: Size,
    alpha: f64,
    new_img_size: Size,
    valid_pix_roi: &mut Rect,
    center_principal_point: bool
) -> Result<Mat>

Returns the new camera matrix based on the free scaling parameter.

Parameters

  • cameraMatrix: Input camera matrix.
  • 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.
  • imageSize: Original image size.
  • alpha: Free scaling parameter between 0 (when all the pixels in the undistorted image are valid) and 1 (when all the source image pixels are retained in the undistorted image). See stereoRectify for details.
  • newImgSize: Image size after rectification. By default, it is set to imageSize .
  • validPixROI: Optional output rectangle that outlines all-good-pixels region in the undistorted image. See roi1, roi2 description in stereoRectify .
  • centerPrincipalPoint: Optional flag that indicates whether in the new camera matrix the principal point should be at the image center or not. By default, the principal point is chosen to best fit a subset of the source image (determined by alpha) to the corrected image.

Returns

new_camera_matrix Output new camera matrix.

The function computes and returns the optimal new camera matrix based on the free scaling parameter. By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original image pixels if there is valuable information in the corners alpha=1 , or get something in between. When alpha>0 , the undistorted result is likely to have some black pixels corresponding to "virtual" pixels outside of the captured distorted image. The original camera matrix, distortion coefficients, the computed new camera matrix, and newImageSize should be passed to initUndistortRectifyMap to produce the maps for remap .

C++ default parameters

  • new_img_size: Size()
  • valid_pix_roi: 0
  • center_principal_point: false