Skip to content

The parameter types for cv::solvePnP() is misleading #12334

Open

Description

@csukuangfj
System information (version)
  • OpenCV => master
Detailed description

See the code

CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
InputArray cameraMatrix, InputArray distCoeffs,
OutputArray rvec, OutputArray tvec,
bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE );

rvec and tvec are of type OutputArray indicating that they are used only for ouput.

But the code

OutputArray _rvec, OutputArray _tvec, bool useExtrinsicGuess, int flags )

if( useExtrinsicGuess )
{
int rtype = _rvec.type(), ttype = _tvec.type();
Size rsize = _rvec.size(), tsize = _tvec.size();
CV_Assert( (rtype == CV_32F || rtype == CV_64F) &&
(ttype == CV_32F || ttype == CV_64F) );
CV_Assert( (rsize == Size(1, 3) || rsize == Size(3, 1)) &&
(tsize == Size(1, 3) || tsize == Size(3, 1)) );
}

treats them as input when useExtrinsicGuess==true.

Suggestions

The prototype should be decalared as InputOutputArray.

Activity

  1. alalek commented on Aug 29, 2018

    @alalek
    Member

    related issue with another function: #12012

  2. csukuangfj commented on Aug 29, 2018

    @csukuangfj
    ContributorAuthor

    @alalek
    The same problem exists for cv::solvePnPRansac()

  3. modified the milestones: 4.7.0, 4.8.0 on Dec 12, 2022
  4. modified the milestones: 4.8.0, 4.9.0 on Jun 20, 2023
  5. modified the milestones: 4.9.0, 4.10.0 on Dec 20, 2023
  6. self-assigned this
    on Jun 3, 2024
  7. modified the milestones: 4.10.0, 4.11.0 on Jun 3, 2024
  8. modified the milestones: 4.11.0, 4.12.0 on Dec 23, 2024
  9. modified the milestones: 4.12.0, 4.13.0 on Jun 19, 2025
  10. modified the milestones: 4.13.0, 5.0-release on Dec 5, 2025
  11. asmorkalov commented on Dec 5, 2025

    @asmorkalov
    Contributor

    Moved to 5.x as the changes break API.

  12. modified the milestones: 5.0-release, 5.1 on May 28, 2026
  13. modified the milestones: 5.1, 5.2 on Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions