OpenCV鱼眼校准在相同点上产生较大误差

时间:2019-01-30 03:24:16

标签: opencv camera-calibration fisheye

我正在尝试使用OpenCV校正图像中的鱼眼。

我无法执行校准步骤。我尝试过下面的代码进行校准,即使在输入和输出中使用相同的x和y坐标,返回的均方根值也至少为100。

std::vector<std::vector<cv::Point3d>> objpts;
std::vector<std::vector<cv::Point2d>> imgpts;
cv::Size img_size(1292,964); //dimension of input image in pixels
cv::Mat K, D;
std::vector<cv::Mat> rvecs, tvecs;

objpts.push_back(std::vector<cv::Point3d>());
imgpts.push_back(std::vector<cv::Point2d>());

//loading identical data into each
objpts[0].push_back(cv::Point3d(100, 100, 0));
objpts[0].push_back(cv::Point3d(0, 100, 0));
objpts[0].push_back(cv::Point3d(100, 0, 0));
objpts[0].push_back(cv::Point3d(0, 0, 0));
objpts[0].push_back(cv::Point3d(0, 50, 0));

imgpts[0].push_back(cv::Point2d(100, 100));
imgpts[0].push_back(cv::Point2d(0, 100));
imgpts[0].push_back(cv::Point2d(100, 0));
imgpts[0].push_back(cv::Point2d(0, 0));
imgpts[0].push_back(cv::Point2d(0, 50));

//ret changes depending on the points, but is always around 100-500
double ret = cv::fisheye::calibrate(objpts, imgpts, img_size, K, D, rvecs, tvecs);

//This produces the images seen below
cv::Mat im = cv::imread("env.jpg");
cv::Mat out;
cv::fisheye::undistortImage(im, out, K, D);
cv::imwrite("out_env.jpg", out);

当我尝试使用这些校准的K和D矩阵使图像不失真时,我得到的结果如下所示: out_image

作为参考,这是源图像: in_image

当我尝试将实际像素坐标用于imgpt和将物理尺寸用于objpts时,我遇到了类似的问题。

使用opencv 3.4.5

感谢您的帮助!谢谢!

0 个答案:

没有答案