robotology-playground/Robust-View-Graph-SLAM

Tracker.process() wrong undistortion

Nicogene opened this issue · 0 comments

In process(), you compute the Essential matrix using distorted points, and then you use the undistorted one to get R and t from E. Moreover, you do undistortion twice(not necessary).
I report the portion of code that I'm referring to(Tracker.cpp lines 845 to 872):

//-- Normalize
vector<Point2f> vismatched1_, vismatched2_;
undistortPoints(vismatched1, vismatched1_, K1, k1, noArray(), K1);
undistortPoints(vismatched2, vismatched2_, K2, k2, noArray(), K2);

//-- Essential matrix with RANSAC
Mat E, R, t, mask;
E = findEssentialMat(vismatched2, vismatched1, 1.0, Point2d(0,0), RANSAC, 0.999, 0.0001, mask);
//correctMatches(E, vismatched1, vismatched2, vismatched1, vismatched2);

//Mat F = findFundamentalMat(vismatched2_, vismatched1_, FM_RANSAC, 0.1, 0.99, mask);
//correctMatches(F, vismatched1_, vismatched2_, vismatched1_, vismatched2_);
//E = K2.t()*F*K1;

//SVD svd(E);
//Matx33d W(0,-1,0,   //HZ 9.13
//      1,0,0,
//      0,0,1);
//Matx33d Winv(0,1,0,
//     -1,0,0,
//     0,0,1);
//R = svd.u * Mat(W) * svd.vt; //HZ 9.19
//t = svd.u.col(2); //u3

//-- Pose recovery
undistortPoints(vismatched1, vismatched1_, K1, k1);
undistortPoints(vismatched2, vismatched2_, K2, k2);
recoverPose(E, vismatched2_, vismatched1_, R, t, 1.0, Point2d(0,0), noArray());