我正在尝试比较每个SolvePnP可能性之间的精度和时间:CV_ITERATIVE,CV_EPNP和CV_P3P
我还将我的结果与Matlab EPNP进行了比较。
看起来像EPNP和P3P失败了:
std::vector<cv::Point2f> imgPoints;
imgPoints.push_back(cv::Point2f(400,188));
imgPoints.push_back(cv::Point2f(400,300));
imgPoints.push_back(cv::Point2f(512,300));
imgPoints.push_back(cv::Point2f(512,188));
double size = 80.0;
std::vector<cv::Point3f> objPoints;
objPoints.push_back(cv::Point3f(0,0,0));
objPoints.push_back(cv::Point3f(0,size,0));
objPoints.push_back(cv::Point3f(size,size,0));
objPoints.push_back(cv::Point3f(size,0,0));
cv::Mat rvec0 = cv::Mat::zeros(3, 1, CV_64FC1);
cv::Mat tvec0 = cv::Mat::zeros(3, 1, CV_64FC1);
cv::Mat rvec1 = cv::Mat::zeros(3, 1, CV_64FC1);
cv::Mat tvec1 = cv::Mat::zeros(3, 1, CV_64FC1);
cv::Mat rvec2 = cv::Mat::zeros(3, 1, CV_64FC1);
cv::Mat tvec2 = cv::Mat::zeros(3, 1, CV_64FC1);
cv::Mat cam, coeff;
cam = (cv::Mat_<double>(3,3) << 700,0,300,0,700,400,0,0,1);
cv::solvePnP(objPoints,imgPoints,cam,coeff,rvec0,tvec0,CV_ITERATIVE);
cv::solvePnP(objPoints,imgPoints,cam,coeff,rvec1,tvec1,CV_P3P);
cv::solvePnP(objPoints,imgPoints,cam,coeff,rvec2,tvec2,CV_EPNP);
cv::Mat rmat0,rmat1,rmat2;
cv::Rodrigues(rvec0,rmat0);
cv::Rodrigues(rvec1,rmat1);
cv::Rodrigues(rvec2,rmat2);
std::cout << "ITERATIVE : Rotation matrix : " << std::endl << rmat0 << std::endl;
std::cout << "ITERATIVE : Tranlation vector : " << std::endl << tvec0 << std::endl << std::endl;
std::cout << "P3P : Rotation matrix : " << std::endl << rmat1 << std::endl;
std::cout << "P3P : Tranlation vector : " << std::endl << tvec1 << std::endl << std::endl;
std::cout << "EPNP : Rotation matrix : " << std::endl << rmat2 << std::endl;
std::cout << "EPNP : Tranlation vector : " << std::endl << tvec2 << std::endl << std::endl;
给我:
ITERATIVE:旋转矩阵:[1,-2.196885546074445e-016,9.692430825310778e-016; 2.196885546074445e-016,1,11012059558506939e-015; -9.692430825310778e-016,-1.012059558506939e-015,1]
ITERATIVE:Tranlation vector:[71.42857142857143; -151.4285714285714; 500]
P3P:旋转矩阵:[1,0,0; 0,1,0; 0,0,1]
P3P:Tranlation载体:[ - 3.97771428571427e-015; -4.022285714285698e-015; 9.989999999999962e-017] EPNP:旋转矩阵:[1,0,0; 0,1,0; 0,0,1]EPNP:Tranlation vector:[ - 3.97771428571427e-015; -4.022285714285698e-015; 9.989999999999962e-017]
有什么建议吗?
Alexandre Kornmann
答案 0 :(得分:1)
我有你的提示,有些事情对我来说很奇怪:
答案 1 :(得分:0)
P3P'不是一个好方法,它的精度非常差.EPNP似乎是精度的最佳选择。但是你不应该只使用EPNP,Ransac算法会更好。