# solvePnPGeneric() solution order

**URL:** <https://forum.opencv.org/t/solvepnpgeneric-solution-order/24402>\
**Category:** C++\
**Tags:** calib3d\
**Created:** [March 23, 2026, 1:49am UTC](https://forum.opencv.org/t/solvepnpgeneric-solution-order/24402 "2026-03-23T01:49:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdrianLopez](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/adrianlopez/32/11683_2.png) [@AdrianLopez](https://forum.opencv.org/u/AdrianLopez)\
**Post date:** [March 23, 2026, 1:49am UTC](https://forum.opencv.org/t/solvepnpgeneric-solution-order/24402/1 "2026-03-23T01:49:22Z")

</div>

Are the poses returned by [`solvePnPGeneric()`](https://docs.opencv.org/4.13.0/d9/d0c/group__calib3d.html#ga624af8a6641b9bdb487f63f694e8bb90) supposed to be ordered according to reprojection errors? Sorting by reprojection errors is an explicit, documented guarantee of `solveP3P()`, but not of `solvePnPGeneric()`. However, looking at the [source code](https://github.com/opencv/opencv/blob/4.13.0/modules/calib3d/src/solvepnp.cpp) for `solvePnP()` I can see it calls `solvePnPGeneric()` and takes `rvecs[0]` and `tvecs[0]`without checking for reprojection error.

I’m currently doing the following even though it currently always chooses index 0:

```cpp
        const int solution_index = err0 <= err1 ? 0 : 1;
        marker_rvecs[id] = rvecs[solution_index];
        marker_tvecs[id] = tvecs[solution_index];

```

The presence or absence of any ordering guarantees is something I think the documentation should address explicitly. Could I maybe get an official word on this?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [March 23, 2026, 1:50pm UTC](https://forum.opencv.org/t/solvepnpgeneric-solution-order/24402/2 "2026-03-23T13:50:25Z")

</div>

I’m not the official word.

If you would like that, I would recommend checking OpenCV’s github for related issues. If you see none, you should file an issue and request a change to the docs. Make sure that you get answers justified by references to the source code, ideally from the core developers.
