Port of #30434 to 5.x. Since 4.7.0 the final SOLVEPNP_ITERATIVE
refinement starts from the minimal sample model. For a planar object
this model can be the mirrored pose, and Levenberg-Marquardt stays in
that local minimum. For planar inliers, also refine from the homography
based initialization of SOLVEPNP_ITERATIVE and keep the pose with the
lower reprojection error. Non-planar objects are not affected.
Fixes#27098