c++ - undistortPoints, findEssentialMat, recoverPose: What is the relation between their arguments? -
in hope broader audience, repost question here asked on answers.opencv.org well.
tl;dr: relation should hold between arguments passed undistortpoints, findessentialmat , recoverpose?
i have code following in program, k , dist_coefficients being camera intrinsics , imgpts. matching feature points 2 images.
mat mask; // inlier mask undistortpoints(imgpts1, imgpts1, k, dist_coefficients, noarray(), k); undistortpoints(imgpts2, imgpts2, k, dist_coefficients, noarray(), k); mat e = findessentialmat(imgpts1, imgpts2, 1, point2d(0,0), ransac, 0.999, 3, mask); correctmatches(e, imgpts1, imgpts2, imgpts1, imgpts2); recoverpose(e, imgpts1, imgpts2, r, t, 1.0, point2d(0,0), mask); i undistort points before finding essential matrix. doc states 1 can pass new camera matrix last argument. when omitted, points in normalized coordinates (between -1 , 1). in case, expect pass 1 focal length , (0,0) principal point findessentialmat, points normalized. think way:
possibility 1 (normalize coordinates)
mat mask; // inlier mask undistortpoints(imgpts1, imgpts1, k, dist_coefficients); undistortpoints(imgpts2, imgpts2, k, dist_coefficients); mat e = findessentialmat(imgpts1, imgpts2, 1.0, point2d(0,0), ransac, 0.999, 3, mask); correctmatches(e, imgpts1, imgpts2, imgpts1, imgpts2); recoverpose(e, imgpts1, imgpts2, r, t, 1.0, point2d(0,0), mask);possibility 2 (do not normalize coordinates)
mat mask; // inlier mask undistortpoints(imgpts1, imgpts1, k, dist_coefficients, noarray(), k); undistortpoints(imgpts2, imgpts2, k, dist_coefficients, noarray(), k); double focal = k.at<double>(0,0); point2d principalpoint(k.at<double>(0,2), k.at<double>(1,2)); mat e = findessentialmat(imgpts1, imgpts2, focal, principalpoint, ransac, 0.999, 3, mask); correctmatches(e, imgpts1, imgpts2, imgpts1, imgpts2); recoverpose(e, imgpts1, imgpts2, r, t, focal, principalpoint, mask);
however, have found, reasonable results when tell undistortpoints old camera matrix shall still valid (i guess in case distortion removed) , pass arguments findessentialmat if points normalized, not.
is bug, insufficient documentation or user error?
update
it might correctedmatches should called (non-normalised) image/pixel coordinates , fundamental matrix, not e, may mistake in computation. can obtained f = k^-t * e * k^-1
as turns out, data seemingly off. using manually labelled correspondences determined possibility 1 , 2 indeed correct ones, 1 expect.
Comments
Post a Comment