我有一个广角镜头(> 160度)。我尝试了Pinhole和Fisheye模型,它们似乎提供了一些FOV牺牲的清晰校正图像。因此,我决定尝试使用全方位模型。
使用全向模型:
double rms = cv::omnidir::stereoCalibrate(Omni_L.RealP, Omni_L.ImageP, Omni_R.ImageP, Omni_L.img.size(), Omni_R.img.size(), K1, xi1, D1, K2, xi2, D2, rvec, tvec, rvecsL, tvecsL, flags, critia);
std::cout << "RMS : " << rms << std::endl;
立体校准后,我得到以下结果
RMS : 0.527522
Camera_Matrix1 :
[773.9380049495828, 0, 394.6697338356358;
0, 776.2094223216956, 382.016762545214;
0, 0, 1]
Xi-1 :[1.804945374650817]
Distortion Parameters1:
[0, 0, -0.009983732008104793, -0.004530718062523464]
Camera_Matrix2:
[783.1807043871861, 0, 393.2120687911561;
0, 784.4790955477508, 386.7954078861521;
0, 0, 1]
Xi-2 :[1.837909340970556]
Distortion Parameters2:
[0, 0, -0.009779422171305124, -0.003723193186299092]
rvec :[-0.003821627764900316;
0.005567569400892289;
0.001491183114878044]
tvec:[-63.09243360480385;
0.1195353275271446;
0.9082801155496641]
R:
[1, 0, 0;
0, 1, 0;
0, 0, 1]
P:
[773.9380049495828, 0, 394.6697338356358;
0, 776.2094223216956, 382.016762545214;
0, 0, 1]
然后我不失真:
cv::Mat R = cv::Mat::eye(3, 3, CV_32FC1);
cv::Mat Mapx, Mapy;
cv::Mat P(3, 3, CV_32FC1);
P = K1;
cv::Mat orid = cv::imread("Left\\1.jpg");
std::cout << orid.size();
std::cout << "R : "<<R<<std::endl;
std::cout << "P : " << P << std::endl;
cv::Size s= orid.size();
try {
cv::omnidir::initUndistortRectifyMap(K1, D1, xi1, R, P, s, CV_32FC1, Mapx, Mapy, cv::omnidir::RECTIFY_PERSPECTIVE);// Knew, new_size);
cv::remap(orid, DC, Mapx, Mapy, cv::INTER_CUBIC);
}
catch (cv::Exception & e)
{
std::cerr << e.msg << std::endl; // output exception message
}
std::string Save_Original = "Distorted_Original" + std::to_string(10) + EXT;
cv::imwrite(Save_Original, orid);
std::string Save_Corrected = "Distorted_Corrected" + std::to_string(10) + EXT;
cv::imwrite(Save_Corrected, DC);
问题1:
为什么径向变形为零?
问题2:
经过校正的不失真图像的输出大大降低了FOV。我的代码有问题吗?
问题3:
P和R在cv :: omnidir :: initUndistortRectifyMap()函数中做什么?
问题4:
需要关于如何通过全向标定获得更多FoV的良好校正图像的想法?
发布试用:
由@sushi建议(以下注释)尝试对同一张图片尝试RECTIFY_CYLINDRICAL,以下是结果:
cv::omnidir::RECTIFY_CYLINDRICAL
->结果更糟
答案 0 :(得分:1)
首先,我建议您阅读本教程:https://docs.opencv.org/master/dd/d12/tutorial_omnidir_calib_main.html 回答您的问题:
这是我使用RECTIFY_PERSPECTIVE的方法的结果,我不知道为什么RECTIFY_CYLINDRICAL在这种情况下不起作用: 要实现它,只需像这样扭曲图像即可:
cv::Size s = orid.size();
cv::Mat Knew = cv::Mat(cv::Matx33f(s.width / 4, 0, s.width / 2,
0, s.height / 4, s.width / 2,
0, 0, 1));
cv::MAt undistorted;
cv::omnidir::undistortImage(orid, undistorted, K1, D1, xi1, cv::omnidir::RECTIFY_PERSPECTIVE, Knew, orid.size());