CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Add solvePnPRefineLM and solvePnPRefineVVS #14431
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution!
SolvePnP()
with SOLVEPNP_ITERATIVE should use Levenberg-Marquardt too.
modules/calib3d/src/solvepnp.cpp
Outdated
Mat opoints, ipoints; | ||
opoints_.convertTo(opoints, CV_64F); | ||
ipoints_.convertTo(ipoints, CV_64F); | ||
int npoints = std::max(opoints.checkVector(3, CV_32F), opoints.checkVector(3, CV_64F)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After opoints_.convertTo(opoints, CV_64F);
this check should always fail: opoints.checkVector(3, CV_32F)
modules/calib3d/src/solvepnp.cpp
Outdated
double theta = sqrt(wx*wx + wy*wy + wz*wz); | ||
double sinc = abs(theta) < 1e-8 ? 1 : sin(theta) / theta; | ||
double mcosc = (abs(theta) < 1e-8) ? 0.5 : (1-cos(theta)) / (theta*theta); | ||
double msinc = (abs(theta) < 1e-8) ? (1/6.0) : (1-sinc) / (theta*theta); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using of std::fabs()
instead of abs()
modules/calib3d/src/solvepnp.cpp
Outdated
double wy = twist.at<double>(4,0); | ||
double wz = twist.at<double>(5,0); | ||
|
||
Mat rvec = (Mat_<double>(3,1) << wx, wy, wz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matx31d rvec(wx, wy, wz);
e8c2160
to
b66aaa3
Compare
@alalek
In the future, it would be good to drop the C-version and use
Related #5206 |
β¦rdt iterative minimization process. Add solvePnPRefineVVS to refine a pose using a virtual visual servoing scheme.
b66aaa3
to
dac31e8
Compare
For me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thank you π
I think the class approach is the good way to go. PnPSolver and PnPRefiner are clear names in my opinion. |
related #14181
This is a draft to see how adding a separate function to refine a pose after
solvePnP
would look:solvePnPRefineLM
the classical Levenberg-Marquardt iterative minimization processsolvePnPRefineVVS
minimize the projection error using a virtual visual servoing schemeLMSolver
should be compared to the C implementation code for the Levenberg-Marquardt:opencv/modules/calib3d/src/calibration.cpp
Lines 1221 to 1248 in 7b8ce63
Also, I have added the possibility to set the epsilon in the LM implementation.