使用OpenCv
calibrateCamera
方法校准我的相机并获取其参数后,当我尝试重现原始对象点时,我得到无意义的输出。
这是我的代码:
vector<vector<cv::Point3f> > object_points;
vector<vector<cv::Point2f> > image_points;
cv::Mat cam_mat;
cv::Mat dist_coeffs;
vector<cv::Mat> rvecs, tvecs;
std::vector<cv::Point3f> t_3d;
t_3d.push_back(cv::Point3f(0.9, -3, 57.5));
t_3d.push_back(cv::Point3f(1.45, -3, 57.5));
t_3d.push_back(cv::Point3f(2, -3, 57.5));
t_3d.push_back(cv::Point3f(0.9, -3, 53));
t_3d.push_back(cv::Point3f(1.45, -3, 53));
t_3d.push_back(cv::Point3f(2, -3, 53));
object_points.push_back(t_3d);
std::vector<cv::Point2f> t_2d;
t_2d.push_back(cv::Point2f(434, 362));
t_2d.push_back(cv::Point2f(570, 362));
t_2d.push_back(cv::Point2f(706, 325));
t_2d.push_back(cv::Point2f(513, 574));
t_2d.push_back(cv::Point2f(513, 574));
t_2d.push_back(cv::Point2f(654, 557));
image_points.push_back(t_2d);
cv::calibrateCamera(object_points, image_points, cv::Size(1440, 900), cam_mat,
dist_coeffs, rvecs, tvecs, CV_CALIB_USE_INTRINSIC_GUESS);
cv::Mat tx(4, 1, CV_64F, cv::Scalar(1.0));
tx.at<double>(0, 0) = 0.9;
tx.at<double>(1, 0) = -3;
tx.at<double>(2, 0) = 57.5;
cv::Mat rrr ;
cv::projectPoints(object_points.at(0), rvecs.at(0), tvecs.at(0),cam_mat,
dist_coeffs, rrr);
我的rrr
变量除了包含(434, 362)
的值,但它填充了6个无意义的值:
rrr = [1.53232e+18, 1.08633e+18, 7.72618e+17, 7.09485e+19, 7.192e+19, 7.26505e+19]
有什么问题?