简体   繁体   English

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

[英]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.

相关问题 OpenCV立体摄像机校准/图像校正 - OpenCV Stereo Camera Calibration/Image Rectification 从手动创建的矩阵中进行OpenCV立体声校正 - OpenCV Stereo rectification from manually created matrices 使用MYNTEYE立体相机在ROS中发布左右视频输入 - Publishing Left and Right video feeds in ROS using a MYNTEYE stereo camera 如何使用Triclops和FlyCapture SDK从PointGrey BumbleBee2立体摄像机创建深度图? - How to create a depth map from PointGrey BumbleBee2 stereo camera using Triclops and FlyCapture SDKs? 使用Opencv通过单端口多头(立体声)USB摄像头捕获视频,提供单输出 - Video capture using Opencv through single port multi-head (stereo) usb camera giving single output 用opencv分离两个立体摄像机图像 - Separating two Images of Stereo Camera with opencv OpenCV摄像机立体声校准-奇怪的结果 - OpenCV Camera Stereo Calibration - Strange results 在立体声校准中,如果我更改立体声相机的分辨率,外部矩阵将如何变化 - In stereo calibration, how the extrinsic matrix changes if i change the resolution of stereo camera 使用Matlab中Opencv的摄像机校准参数重新计算图像点 - Recalculating the image points using camera calibration parameters from Opencv in Matlab 如何从外部参数获取立体图像中的点 - How to get points in stereo image from extrinsic parameters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM