solvePnPRansacAsync static method

Future<(bool, Mat, Mat, Mat)> solvePnPRansacAsync(
  1. InputArray objectPoints,
  2. InputArray imagePoints,
  3. InputArray cameraMatrix,
  4. InputArray distCoeffs, {
  5. OutputArray? rvec,
  6. OutputArray? tvec,
  7. OutputArray? inliers,
  8. double reprojectionError = 8.0,
  9. int iterationsCount = 100,
  10. double confidence = 0.99,
  11. bool useExtrinsicGuess = false,
  12. int flags = SOLVEPNP_ITERATIVE,
  13. TermCriteria? criteria,
})

Finds an object pose from 3D-2D point correspondences using the RANSAC scheme for fisheye camera moodel.

https://docs.opencv.org/4.x/db/d58/group__calib3d__fisheye.html#gabc1c7a253a8cf2a09f948f8426967a56

Implementation

static Future<(bool rval, Mat rvec, Mat tvec, Mat inliers)> solvePnPRansacAsync(
  InputArray objectPoints,
  InputArray imagePoints,
  InputArray cameraMatrix,
  InputArray distCoeffs, {
  OutputArray? rvec,
  OutputArray? tvec,
  OutputArray? inliers,
  double reprojectionError = 8.0,
  int iterationsCount = 100,
  double confidence = 0.99,
  bool useExtrinsicGuess = false,
  int flags = SOLVEPNP_ITERATIVE,
  TermCriteria? criteria,
}) async {
  rvec ??= Mat.empty();
  tvec ??= Mat.empty();
  inliers ??= Mat.empty();
  criteria ??= TermCriteria(TERM_MAX_ITER + TERM_EPS, 10, 1e-8);
  final prval = calloc<ffi.Bool>();
  return cvRunAsync0(
    (callback) => ccalib3d.cv_fisheye_solvePnPRansac(
      objectPoints.ref,
      imagePoints.ref,
      cameraMatrix.ref,
      distCoeffs.ref,
      rvec!.ref,
      tvec!.ref,
      useExtrinsicGuess,
      iterationsCount,
      reprojectionError,
      confidence,
      inliers!.ref,
      flags,
      criteria!.ref,
      prval,
      callback,
    ),
    (c) {
      final rval = prval.value;
      calloc.free(prval);
      return c.complete((rval, rvec!, tvec!, inliers!));
    },
  );
}