solvePnPRefineLM function

void solvePnPRefineLM(
  1. InputArray objectPoints,
  2. InputArray imagePoints,
  3. InputArray cameraMatrix,
  4. InputArray distCoeffs,
  5. InputOutputArray rvec,
  6. InputOutputArray tvec, {
  7. TermCriteria? criteria,
})

Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.

https://docs.opencv.org/4.11.0/d9/d0c/group__calib3d.html#ga650ba4d286a96d992f82c3e6dfa525fa

Implementation

void solvePnPRefineLM(
  InputArray objectPoints,
  InputArray imagePoints,
  InputArray cameraMatrix,
  InputArray distCoeffs,
  InputOutputArray rvec,
  InputOutputArray tvec, {
  TermCriteria? criteria,
}) {
  // in opencv, this is TermCriteria(TermCriteria::EPS+TermCriteria::COUNT, 20, FLT_EPSILON)
  // FLT_EPSILON depends on the platform, here we use 1e-7 to simplify this.
  // which may get different results on than opencv c++.
  criteria ??= TermCriteria(TERM_EPS + TERM_COUNT, 20, 1e-7);
  return cvRun(
    () => ccalib3d.cv_solvePnPRefineLM(
      objectPoints.ref,
      imagePoints.ref,
      cameraMatrix.ref,
      distCoeffs.ref,
      rvec.ref,
      tvec.ref,
      criteria!.ref,
      ffi.nullptr,
    ),
  );
}