Stereo Camera Rectification using saved parametersRectifying images on opencv with intrinsic and extrinsic parameters already found3D stereo, bad 3D coordinatesHow do I get the projection matrix of a camera after stereo rectification?Is reprojection error enough in stereo calibration?In stereo calibration, how the extrinsic matrix changes if i change the resolution of stereo camera3D world Coordinate estimation using stereo cameraRectifiy stereo images - Matlab to OpenCV PythonLow average reprojection error for stereo calibration but stereo rectification shows wrong resultProblem with stereo rectification using OpenCV and PythonHow can you rectify cropped stereo images in OpenCV?

mini sub panel?

Program for finding longest run of zeros from a list of 100 random integers which are either 0 or 1

What is the oldest instrument ever?

Examples where existence is harder than evaluation

How do I give a darkroom course without negatives from the attendees?

Expl3 and recent xparse on overleaf: No expl3 loader detected

Why doesn't a particle exert force on itself?

And now you see it II (the B side)

What should I use to get rid of some kind of weed in my onions

My Sixteen Friendly Students

Capturing the entire webpage with WebExecute's CaptureImage

Opposite party turned away from voting when ballot is all opposing party

Do oversize pulley wheels increase derailleur capacity?

Are wands in any sort of book going to be too much like Harry Potter?

Why is the episode called "The Last of the Starks"?

I need some help understanding the grammar of しのげそうな in この寒さをしのげそうな防寒服を手渡され

Mindfulness of Watching Youtube

Is it a good idea to copy a trader when investing?

Names of the Six Tastes

Is this strange Morse signal type common?

Is there an idiom that means "revealing a secret unintentionally"?

Is it possible to do moon sighting in advance for 5 years with 100% accuracy?

Why doesn't increasing the temperature of something like wood or paper set them on fire?

Visual Studio Code download existing code



Stereo Camera Rectification using saved parameters


Rectifying images on opencv with intrinsic and extrinsic parameters already found3D stereo, bad 3D coordinatesHow do I get the projection matrix of a camera after stereo rectification?Is reprojection error enough in stereo calibration?In stereo calibration, how the extrinsic matrix changes if i change the resolution of stereo camera3D world Coordinate estimation using stereo cameraRectifiy stereo images - Matlab to OpenCV PythonLow average reprojection error for stereo calibration but stereo rectification shows wrong resultProblem with stereo rectification using OpenCV and PythonHow can you rectify cropped stereo images in OpenCV?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















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:



 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










share|improve this question






























    1















    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:



     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










    share|improve this question


























      1












      1








      1








      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:



       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










      share|improve this question
















      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:



       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







      c++ opencv






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 20 at 9:02









      HansHirse

      2,200826




      2,200826










      asked Mar 20 at 8:53









      Chester LigutanChester Ligutan

      83




      83






















          2 Answers
          2






          active

          oldest

          votes


















          0














          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.






          share|improve this answer























          • i used the opencv sample code of stereo camera calibration to get my intrinsic and extrinsic parameters. i did get an average error of 1.5 with 150 image pairs.

            – Chester Ligutan
            Mar 25 at 7:57


















          0














          i also tried adding try catch but it seems to be not showing any kind of error but still when i tried rectifying my image pair then getting its depth map i still get an empty white depth map



          try 
          FileStorage fs("intrinsics.yml", FileStorage::READ);
          fs["intrinsics.yml"] >> intrinsics;

          catch (cv::Exception& e)

          cerr << "Error opening file "" << intrinsics << "". Reason: " << e.msg << endl;


          FileStorage fs("intrinsics.yml", FileStorage::READ);
          fs["intrinsics.yml"] >> intrinsics;

          Mat M1, D1, M2, D2;
          fs["M1"] >> M1;
          fs["D1"] >> D1;
          fs["M2"] >> M2;
          fs["D2"] >> D2;

          M1 *= scale;
          M2 *= scale;

          try
          FileStorage fs("extrinsics.yml", FileStorage::READ);
          fs["extrinsics.yml"] >> extrinsics;

          catch (cv::Exception& e)

          cerr << "Error opening file "" << extrinsics << "". Reason: " << e.msg << endl;


          fs.open("extrinsics.yml", FileStorage::READ);
          fs["extrinsics.yml"] >> 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, CALIB_ZERO_DISPARITY, -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);


          do i also have an error in my try catch?






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55256780%2fstereo-camera-rectification-using-saved-parameters%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            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.






            share|improve this answer























            • i used the opencv sample code of stereo camera calibration to get my intrinsic and extrinsic parameters. i did get an average error of 1.5 with 150 image pairs.

              – Chester Ligutan
              Mar 25 at 7:57















            0














            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.






            share|improve this answer























            • i used the opencv sample code of stereo camera calibration to get my intrinsic and extrinsic parameters. i did get an average error of 1.5 with 150 image pairs.

              – Chester Ligutan
              Mar 25 at 7:57













            0












            0








            0







            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.






            share|improve this answer













            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 23 at 7:04









            wen daiwen dai

            285




            285












            • i used the opencv sample code of stereo camera calibration to get my intrinsic and extrinsic parameters. i did get an average error of 1.5 with 150 image pairs.

              – Chester Ligutan
              Mar 25 at 7:57

















            • i used the opencv sample code of stereo camera calibration to get my intrinsic and extrinsic parameters. i did get an average error of 1.5 with 150 image pairs.

              – Chester Ligutan
              Mar 25 at 7:57
















            i used the opencv sample code of stereo camera calibration to get my intrinsic and extrinsic parameters. i did get an average error of 1.5 with 150 image pairs.

            – Chester Ligutan
            Mar 25 at 7:57





            i used the opencv sample code of stereo camera calibration to get my intrinsic and extrinsic parameters. i did get an average error of 1.5 with 150 image pairs.

            – Chester Ligutan
            Mar 25 at 7:57













            0














            i also tried adding try catch but it seems to be not showing any kind of error but still when i tried rectifying my image pair then getting its depth map i still get an empty white depth map



            try 
            FileStorage fs("intrinsics.yml", FileStorage::READ);
            fs["intrinsics.yml"] >> intrinsics;

            catch (cv::Exception& e)

            cerr << "Error opening file "" << intrinsics << "". Reason: " << e.msg << endl;


            FileStorage fs("intrinsics.yml", FileStorage::READ);
            fs["intrinsics.yml"] >> intrinsics;

            Mat M1, D1, M2, D2;
            fs["M1"] >> M1;
            fs["D1"] >> D1;
            fs["M2"] >> M2;
            fs["D2"] >> D2;

            M1 *= scale;
            M2 *= scale;

            try
            FileStorage fs("extrinsics.yml", FileStorage::READ);
            fs["extrinsics.yml"] >> extrinsics;

            catch (cv::Exception& e)

            cerr << "Error opening file "" << extrinsics << "". Reason: " << e.msg << endl;


            fs.open("extrinsics.yml", FileStorage::READ);
            fs["extrinsics.yml"] >> 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, CALIB_ZERO_DISPARITY, -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);


            do i also have an error in my try catch?






            share|improve this answer



























              0














              i also tried adding try catch but it seems to be not showing any kind of error but still when i tried rectifying my image pair then getting its depth map i still get an empty white depth map



              try 
              FileStorage fs("intrinsics.yml", FileStorage::READ);
              fs["intrinsics.yml"] >> intrinsics;

              catch (cv::Exception& e)

              cerr << "Error opening file "" << intrinsics << "". Reason: " << e.msg << endl;


              FileStorage fs("intrinsics.yml", FileStorage::READ);
              fs["intrinsics.yml"] >> intrinsics;

              Mat M1, D1, M2, D2;
              fs["M1"] >> M1;
              fs["D1"] >> D1;
              fs["M2"] >> M2;
              fs["D2"] >> D2;

              M1 *= scale;
              M2 *= scale;

              try
              FileStorage fs("extrinsics.yml", FileStorage::READ);
              fs["extrinsics.yml"] >> extrinsics;

              catch (cv::Exception& e)

              cerr << "Error opening file "" << extrinsics << "". Reason: " << e.msg << endl;


              fs.open("extrinsics.yml", FileStorage::READ);
              fs["extrinsics.yml"] >> 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, CALIB_ZERO_DISPARITY, -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);


              do i also have an error in my try catch?






              share|improve this answer

























                0












                0








                0







                i also tried adding try catch but it seems to be not showing any kind of error but still when i tried rectifying my image pair then getting its depth map i still get an empty white depth map



                try 
                FileStorage fs("intrinsics.yml", FileStorage::READ);
                fs["intrinsics.yml"] >> intrinsics;

                catch (cv::Exception& e)

                cerr << "Error opening file "" << intrinsics << "". Reason: " << e.msg << endl;


                FileStorage fs("intrinsics.yml", FileStorage::READ);
                fs["intrinsics.yml"] >> intrinsics;

                Mat M1, D1, M2, D2;
                fs["M1"] >> M1;
                fs["D1"] >> D1;
                fs["M2"] >> M2;
                fs["D2"] >> D2;

                M1 *= scale;
                M2 *= scale;

                try
                FileStorage fs("extrinsics.yml", FileStorage::READ);
                fs["extrinsics.yml"] >> extrinsics;

                catch (cv::Exception& e)

                cerr << "Error opening file "" << extrinsics << "". Reason: " << e.msg << endl;


                fs.open("extrinsics.yml", FileStorage::READ);
                fs["extrinsics.yml"] >> 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, CALIB_ZERO_DISPARITY, -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);


                do i also have an error in my try catch?






                share|improve this answer













                i also tried adding try catch but it seems to be not showing any kind of error but still when i tried rectifying my image pair then getting its depth map i still get an empty white depth map



                try 
                FileStorage fs("intrinsics.yml", FileStorage::READ);
                fs["intrinsics.yml"] >> intrinsics;

                catch (cv::Exception& e)

                cerr << "Error opening file "" << intrinsics << "". Reason: " << e.msg << endl;


                FileStorage fs("intrinsics.yml", FileStorage::READ);
                fs["intrinsics.yml"] >> intrinsics;

                Mat M1, D1, M2, D2;
                fs["M1"] >> M1;
                fs["D1"] >> D1;
                fs["M2"] >> M2;
                fs["D2"] >> D2;

                M1 *= scale;
                M2 *= scale;

                try
                FileStorage fs("extrinsics.yml", FileStorage::READ);
                fs["extrinsics.yml"] >> extrinsics;

                catch (cv::Exception& e)

                cerr << "Error opening file "" << extrinsics << "". Reason: " << e.msg << endl;


                fs.open("extrinsics.yml", FileStorage::READ);
                fs["extrinsics.yml"] >> 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, CALIB_ZERO_DISPARITY, -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);


                do i also have an error in my try catch?







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 8:23









                Chester LigutanChester Ligutan

                83




                83



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55256780%2fstereo-camera-rectification-using-saved-parameters%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현