Repository navigation
Add solvePnPRefineLM and solvePnPRefineVVS - #14431
Conversation
alalek
left a comment
There was a problem hiding this comment.
Thank you for the contribution!
SolvePnP() with SOLVEPNP_ITERATIVE should use Levenberg-Marquardt too.
| 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.
After opoints_.convertTo(opoints, CV_64F); this check should always fail: opoints.checkVector(3, CV_32F)
| 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.
Consider using of std::fabs() instead of abs()
| double wy = twist.at<double>(4,0); | ||
| double wz = twist.at<double>(5,0); | ||
|
|
||
| Mat rvec = (Mat_<double>(3,1) << 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 |
|
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
solvePnPwould look:solvePnPRefineLMthe classical Levenberg-Marquardt iterative minimization processsolvePnPRefineVVSminimize the projection error using a virtual visual servoing schemeLMSolvershould 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.