-
Notifications
You must be signed in to change notification settings - Fork 133
Added H decomposition #121
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
The code was originally written by @yaqding Co-authored-by: <yaqding@users.noreply.github.com>
Eigen::Matrix3d V2 = svd.matrixV(); | ||
|
||
if (abs(S2(0) - S2(2)) < 1.0e-6) { | ||
poses->emplace_back(H2, Eigen::Vector3d(0.0, 0.0, 0.0)); |
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.
Should maybe also add a zero vector to normals here.
Also this check could be made invariant w.r.t. the scale of HH.
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.
So maybe scale this w.r.t. the determinant?
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.
Could divide by S2(0) as well.
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.
I think it's best to have poses.size() == normals.size()
even in these corner cases. So normals->emplace_back(0,0,0)
is reasonable here as well I think.
@@ -19,6 +20,10 @@ focals_from_fundamental_iterative(const Eigen::Matrix3d &F, const Camera &camera | |||
const int &max_iters = 50, | |||
const Eigen::Vector4d &weights = Eigen::Vector4d(5.0e-4, 1.0, 5.0e-4, 1.0)); | |||
|
|||
// Estimate the camera motion from homography. | |||
// If you use H obtained using correspondences in image coordinates from two cameras you need to input K2^-1 * H * K1. | |||
void motion_from_homography(Eigen::Matrix3d HH, std::vector<CameraPose> *poses, std::vector<Eigen::Vector3d> *normals); |
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.
HH could be const ref unless we need to copy.
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.
This is done so we can enforce the determinant to be positive inside the function.
} | ||
Eigen::Vector3d t2 = (H2 - R2) * n2; | ||
|
||
poses->emplace_back(R1, t1); |
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.
I guess there are four possible solutions here
(R1, t1, n1)
(R1, -t1, -n1)
(R2, t2, n2)
(R2, -t2, -n2)
So here we choose the solution pairs with n(2) > 0, but is it possible to decide that these are the correct ones without any correspondences?
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.
Might be better to return all four otherwise.
I forgot to comment. The requested changes have been committed. Let me know if this is ok so I can also add changes to README. |
Looks good to me, thanks! Please fix the normals thing in the comment, and then update the README and we can merge. |
* add H decomp description to README
I added the normals output and description in README. Should I also bump the version? I noticed there have been some other somewhat significant commits without version change since 2.0.4. |
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.
LGTM
Added homography decomposition into pose using SVD.
Original code by @yaqding I just changed the call signature and added bindings.
If approved I will add info to README and bump version.