繁体   English   中英

使用保存的参数进行立体摄像机矫正

[英]Stereo Camera Rectification using saved parameters

我使用我的相机校准中的内在和外在文件纠正我的图像对,以便我可以制作更好的深度图,但是每次我尝试运行程序时。 我的深度图输出仅显示为空白。

这是我的纠正代码:

    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);

我的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);

每次我校准相机并运行程序时,它就会给出不错的深度图。 但立体声对未对准,因为它没有整流。 校准相机需要花费几个小时,所以我只是尝试加载相机的参数,所以我不必每次都校准几个小时就可以获得像样的深度图

先感谢您!

这是我的输出:

https://docs.google.com/document/d/1ajS3vgoVPx2RgbroV8qH2WYHU85PL_SJ-9A4q8aa8e8/edit?usp=sharing

纠正过程似乎还可以,您的数据是否可能有问题? 我建议确保您的整流输入正确无误,并且重新映射步骤会给出正确的,行对齐的立体声对。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM