[英]Stereo Camera Rectification using saved parameters
im using intrinsics and extrinsics files from my calibration of my camera to rectify my image pair so i can make a better depth map, but every time i try to run my program. 我使用我的相机校准中的内在和外在文件纠正我的图像对,以便我可以制作更好的深度图,但是每次我尝试运行程序时。 my depth map output only shows blank. 我的深度图输出仅显示为空白。
here is the code of my rectification: 这是我的纠正代码:
FileStorage fs("intrinsics.yml", FileStorage::READ);
fs["intrisics"] >> intrinsics;
Mat M1, D1, M2, D2;
fs["M1"] >> M1;
fs["D1"] >> D1;
fs["M2"] >> M2;
fs["D2"] >> D2;
M1 *= scale;
M2 *= scale;
fs.open("extrinsics.yml", FileStorage::READ);
fs["extrinsics"] >> extrinsics;
Mat R, T, R1, R2, P1, P2;
fs["R"] >> R;
fs["T"] >> T;
fs["R1"] >> R1;
fs["R2"] >> R2;
fs["P1"] >> P1;
fs["P2"] >> P2;
fs["Q"] >> Q;
stereoRectify(M1, D1, M2, D2, img_size, R, T, R1, R2, P1, P2, Q, 0, -1, img_size, &roi1, &roi2);
Mat map11, map12, map21, map22;
initUndistortRectifyMap(M1, D1, R1, P1, img_size, CV_32FC1, map11, map12);
initUndistortRectifyMap(M2, D2, R2, P2, img_size, CV_32FC1, map21, map22);
Mat img1r, img2r;
remap(grayL, img1r, map11, map12, INTER_LINEAR);
remap(grayR, img2r, map21, map22, INTER_LINEAR);
My SGBM code: 我的SGBM代码:
Ptr<StereoSGBM> sgbm = StereoSGBM::create
(0, //int minDisparity
96, //int numDisparities
5, //int SADWindowSize
600, //int P1 = 0
2400, //int P2 = 0
20, //int disp12MaxDiff = 0
16, //int preFilterCap = 0
1, //int uniquenessRatio = 0
100, //int speckleWindowSize = 0
20, //int speckleRange = 0
true); //bool fullDP = false
sgbm->compute(img1r, img2r, disparity_sgbm);
normalize(disparity_sgbm, disp_done_sgbm, 0, 255, CV_MINMAX, CV_8U);
everytime i calibrate my camera and running my program works and gives decent depth map. 每次我校准相机并运行程序时,它就会给出不错的深度图。 but the stereo pair is not aligned because its not rectified. 但立体声对未对准,因为它没有整流。 calibrating my camera takes few hours so im trying to just load the parameters of my camera so i dont have to calibrate for hours every time to get a decent depth map 校准相机需要花费几个小时,所以我只是尝试加载相机的参数,所以我不必每次都校准几个小时就可以获得像样的深度图
Thank you in advance! 先感谢您!
Here are my outputs: 这是我的输出:
https://docs.google.com/document/d/1ajS3vgoVPx2RgbroV8qH2WYHU85PL_SJ-9A4q8aa8e8/edit?usp=sharing https://docs.google.com/document/d/1ajS3vgoVPx2RgbroV8qH2WYHU85PL_SJ-9A4q8aa8e8/edit?usp=sharing
The rectification process seems ok, is it possibly something wrong with your data? 纠正过程似乎还可以,您的数据是否可能有问题? I suggest to make sure that your rectification inputs are loaded with no error and the remapping step gives the right row-aligned stereo pairs. 我建议确保您的整流输入正确无误,并且重新映射步骤会给出正确的,行对齐的立体声对。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.