我通过分解基本矩阵创建旋转和平移矩阵,并使用cv :: Rodrigues函数创建旋转矢量。但是使用projectPoints显示一些非常奇怪的值,例如1.00e10等值。任何人都可以提示为什么会出现这种情况?
我正在使用visual studio 2012并构建opencv vs11版本。
Matx34d P1 = Matx34d(R1(0,0), R1(0,1), R1(0,2), t1(0),
R1(1,0), R1(1,1), R1(1,2), t1(1),
R1(2,0), R1(2,1), R1(2,2), t1(2));
vector<double> reproj_error1, reproj_error2;
unsigned int pts_size = good_matches.size();
//undistort
Mat pt_set1_pt,pt_set2_pt;
undistortPoints(matchedpoints1, pt_set1_pt, K, distcoeff);
undistortPoints(matchedpoints2, pt_set2_pt, K, distcoeff);
//triangulate
Mat pt_set1_pt_2r = pt_set1_pt.reshape(1, 2);
Mat pt_set2_pt_2r = pt_set2_pt.reshape(1, 2);
Mat pt_3d_h(1,pts_size,CV_32FC1);
cv::triangulatePoints(P1,P2,pt_set1_pt_2r,pt_set2_pt_2r,pt_3d_h);
vector<Point3f> pt_3d;
convertPointsHomogeneous(pt_3d_h.reshape(4, 1), pt_3d);
cv::Mat_<double> R = (cv::Mat_<double>(3,3) << P1(0,0),P1(0,1),P1(0,2),
P1(1,0),P1(1,1),P1(1,2), P1(2,0),P1(2,1),P1(2,2));
cout<<R<<endl;
cv::Mat rvec(3,1,cv::DataType<double>::type);
cv::Mat tvec(3,1,cv::DataType<double>::type);
tvec = (Mat_<double>(3,1) <<P1(0,3),P1(1,3),P1(2,3));
cv::Rodrigues(R,rvec);
Rodrigues(R ,rvec);
vector<Point2f> reprojected_pt_set1;
cv::projectPoints(pt_3d,rvec,tvec,K,distcoeff,reprojected_pt_set1);
rvec的值= [-0.92863; 0.30439; 0.21210]和tvec = [-0.309466; -2.16395; 0.03796]。