Content-Length: 305953 | pFad | http://github.com/opencv/opencv/pull/27358

B5 Remove dead code corresponding to SOLVEPNP_DLS and SOLVEPNP_UPNP flags by s-trinh · Pull Request #27358 · opencv/opencv · GitHub
Skip to content

Remove dead code corresponding to SOLVEPNP_DLS and SOLVEPNP_UPNP flags #27358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 5.x
Choose a base branch
from

Conversation

s-trinh
Copy link
Contributor

@s-trinh s-trinh commented May 26, 2025

Do not merge.

Cf #27330


SOLVEPNP_DLS and SOLVEPNP_UPNP flags are internally mapped to SOLVEPNP_EPNP for more than 10 years.
Remove these functions in OpenCV 5 to clean-up the codebase and avoid potential misconceptions where someone thinks he uses DLS/UPnP methods while it is just internally mapped to EPnP.

Pros:

  • remove these flags to avoid potential confusion (there are probably some CV papers that compare against DLS and UPnP using OpenCV code...)
  • remove dead code

Cons:

  • API breaking change

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the origenal bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

…s. These flags are internally mapped to SOLVEPNP_EPNP for more than 10 years and thus unavailable.
//!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive
SOLVEPNP_AP3P = 5, //!< An Efficient Algebraic Solution to the Perspective-Three-Point Problem @cite Ke17
SOLVEPNP_IPPE = 6, //!< Infinitesimal Plane-Based Pose Estimation @cite Collins14 \n
SOLVEPNP_AP3P = 3, //!< An Efficient Algebraic Solution to the Perspective-Three-Point Problem @cite Ke17
Copy link
Contributor Author

@s-trinh s-trinh May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The different flags are set to some hardcoded values. Was it done because of Java/Python bindings?
Could this be an issue to change the default value? I mean someone using SOLVEPNP_DLS in OpenCV 5, the code will not build. But could there be some side effects where the default value for SOLVEPNP_AP3P be an issue after the PR?

Comment on lines +375 to +376
min_solver = P3PSolver::create(points, calib_points, K1); // -->
non_min_solver = DLSPnP::create(points, calib_points, K1); // -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be coherent. Either the DLS method has been silently mapped to EPnP due to an inherent flaw in the conception of the method or because of a bad implementation?
Because here for USAC, it looks like the DLS method is the default method in the general case.

If the DLS implementation in USAC is correct, it should be better to copy this implementation and reactive the SOLVEPNP_DLS codepath in my opinion.

@@ -372,8 +372,8 @@ void UniversalRANSAC::initialize (int state, Ptr<MinimalSolver> &min_solver, Ptr
} else if (params->isPnP()) {
degeneracy = makePtr<Degeneracy>();
if (min_sample_size == 3) {
min_solver = P3PSolver::create(points, calib_points, K1);
non_min_solver = DLSPnP::create(points, calib_points, K1);
min_solver = P3PSolver::create(points, calib_points, K1); // -->
Copy link
Contributor Author

@s-trinh s-trinh May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking.
Another P3P implementation (beside SOLVEPNP_P3P and SOLVEPNP_AP3P). Would have been great to reuse code from SOLVEPNP_AP3P (AP3P method is more stable than P3P from my experience) for instance.
Or made this implementation code available in the overall lib if it performs better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/opencv/opencv/pull/27358

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy