getOptimalNewCameraMatrix function

(Mat, Rect) getOptimalNewCameraMatrix(
  1. InputArray cameraMatrix,
  2. InputArray distCoeffs,
  3. (int, int) imageSize,
  4. double alpha, {
  5. (int, int) newImgSize = (0, 0),
  6. bool centerPrincipalPoint = false,
})

GetOptimalNewCameraMatrixWithParams computes and returns the optimal new camera matrix based on the free scaling parameter.

For further details, please see: https://docs.opencv.org/master/d9/d0c/group__calib3d.html#ga7a6c4e032c97f03ba747966e6ad862b1

Implementation

(Mat rval, Rect validPixROI) getOptimalNewCameraMatrix(
  InputArray cameraMatrix,
  InputArray distCoeffs,
  (int, int) imageSize,
  double alpha, {
  (int, int) newImgSize = (0, 0),
  bool centerPrincipalPoint = false,
}) {
  final validPixROI = calloc<ccalib3d.Rect>();
  final matPtr = calloc<ccalib3d.Mat>();
  cvRun(
    () => ccalib3d.GetOptimalNewCameraMatrixWithParams(
      cameraMatrix.ref,
      distCoeffs.ref,
      imageSize.cvd.ref,
      alpha,
      newImgSize.cvd.ref,
      validPixROI,
      centerPrincipalPoint,
      matPtr,
    ),
  );
  return (Mat.fromPointer(matPtr), Rect.fromPointer(validPixROI));
}