GithubHelp home page GithubHelp logo

ydsf16 / pnp_solver Goto Github PK

View Code? Open in Web Editor NEW
94.0 94.0 30.0 18 KB

Personal implementations of solvers for PnP problem, including DLT and EPnP.

Home Page: https://zhuanlan.zhihu.com/p/59070440

CMake 1.01% C++ 98.99%

pnp_solver's People

Contributors

ydsf16 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pnp_solver's Issues

关于使用Gauss-Newton求解过程中,雅克比矩阵J的构造

PnP_Solver/pnp_solver.cpp

Lines 530 to 534 in 835e358

// [B11 B12 B22 B13 B23 B33 B14 B24 B34 B44]
J ( i, 0 ) = 2 * betas[0] * L ( i, 0 ) + betas[1]* L ( i, 1 ) + betas[2]*L ( i, 3 ) + betas[3]*L ( i, 6 );
J ( i, 1 ) = betas[0] * L ( i, 1 ) + 2 * betas[1]* L ( i, 2 ) + betas[2]*L ( i, 3 ) + betas[3]*L ( i, 7 );
J ( i, 2 ) = betas[0] * L ( i, 3 ) + betas[1]* L ( i, 4 ) + 2 * betas[2]*L ( i, 5 ) + betas[3]*L ( i, 8 );
J ( i, 3 ) = betas[0] * L ( i, 6 ) + betas[1]* L ( i, 7 ) + betas[2]*L ( i, 8 ) + 2 * betas[3]*L ( i, 9 );

作者您好,我从您的知乎[PnP]PnP问题之EPnP解法这篇文章过来的,关于使用Gauss-Newton求解文章中公式19,您在文章中构造的雅克比矩阵J的形式如下:
image
image
但是似乎在您给出的代码中,关于J矩阵中的各个系数似乎并不全为2,似乎是下面这种形式:
image
哪一种写法是正确的呢?

EPnP: sign of the betas for N>1

Thanks for open sourcing this great repo :)

If you have the time, I am curious about one aspect of the EPnP implementation:
Why the sign of the betas when $N > 1$ should be decided as the way they are implemented?

E.g. when $N=2$ :

PnP_Solver/pnp_solver.cpp

Lines 436 to 446 in 835e358

if ( b3[0] < 0 ) {
betas[0] = sqrt ( -b3[0] );
betas[1] = ( b3[2] < 0 ) ? sqrt ( -b3[2] ) : 0.0;
} else {
betas[0] = sqrt ( b3[0] );
betas[1] = ( b3[2] > 0 ) ? sqrt ( b3[2] ) : 0.0;
}
if ( b3[1] < 0 ) {
betas[0] = -betas[0];
}

However, by definition, $\beta_{11} = \beta_1 * \beta_1 &gt; 0$. Thereby, why an estimate $\beta_{11}&lt;0$ is still considered valid (keeping it as an absolute value), and is not ignored (thus assuming that solutions is spurious)?

Thanks in advance.

Assertion error (bug)

Hi, I tried your code, its perfect! It worked well on my laptop except one place.
On line 278 pop_solver.cpp
C.block ( 3, 0, 1, 4 ) = Eigen::Vector4d ( 1.0, 1.0, 1.0, 1.0 );
When I run the program, it got stuck here. assertion error. rows and cols != problem.
my fix is C.block ( 3, 0, 1, 4 ) = Eigen::Vector4d ( 1.0, 1.0, 1.0, 1.0 ).transpose();

Good job! I found your result is much much better than OpenCV's epnp!

different result with Eigen 3.2.0 and Eigen 3.3.4

I ran a simple program in two systems. Mac with Eigen3.3.4 and Linux with Eigen3.2.0. I got super different results.

Here's my code.

Eigen::Matrix3d m_K = Eigen::Matrix3d::Identity();
    m_K(0, 0) = 672.062;
    m_K(1, 1) = 674.562;
    m_K(0, 2) = 398.838;
    m_K(1, 2) = 279.38;

    std::vector< Eigen::Vector3d > vecPts3d;
    std::vector< Eigen::Vector2d > vecPts2d;

    Eigen::Vector3d p3d0(492.681, 1.73013, 159.257);
    Eigen::Vector3d p3d1(493.724, -4.69578, 69.9289);
    Eigen::Vector3d p3d2(597.975, -10.3263, 9.82591);
    Eigen::Vector3d p3d3(623.276, -9.67869, -303.368);
    Eigen::Vector3d p3d4(502.611, -4.8012, 66.27);

    Eigen::Vector2d p2d0(507.6, 327.6);
    Eigen::Vector2d p2d1(624.248, 239.454);
    Eigen::Vector2d p2d2(222.731, 263.926);
    Eigen::Vector2d p2d3(432.868, 275.006);
    Eigen::Vector2d p2d4(561.6, 244.384);

    vecPts3d.emplace_back(p3d0);
    vecPts3d.emplace_back(p3d1);
    vecPts3d.emplace_back(p3d2);
    vecPts3d.emplace_back(p3d3);
    vecPts3d.emplace_back(p3d4);
    vecPts2d.emplace_back(p2d0);
    vecPts2d.emplace_back(p2d1);
    vecPts2d.emplace_back(p2d2);
    vecPts2d.emplace_back(p2d3);
    vecPts2d.emplace_back(p2d4);

    Eigen::Matrix3d R;
    Eigen::Vector3d t;

    solvePnPbyEPnP(m_K, vecPts3d, vecPts2d, R, t);
    std::cout << R << std::endl;
    std::cout << t.transpose() << std::endl;

With Mac&Eigen3.3.4, I got

-0.947487  0.0657636  -0.312958
 0.0680975   0.997673 0.00347973
  0.312459 -0.0180147   -0.94976
  521.61 -34.9744  13.0391

With Linux&Eigen3.2.0 I got

 -0.931891   0.142008  -0.333785
 -0.142497  -0.989524 -0.0231554
 -0.333577   0.025985   0.942365
-1.94579e+156 -6.07921e+156  2.88192e+158

Also I tried Mac&Eigen3.2.0, another differnt result.

-0.946419 0.0664846  0.316023
0.0906903  0.993916 0.0624984
-0.309945 0.0878099 -0.946691
 5336.94 -628.954  38868.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.