Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Bad Results - Stereo Calibration - Rectification - Correspondence

Hi I am trying to calibration intrinsics and extrinsic of my stereo camera, then rectify them and find the correspondence point.

Original Image :

Left_Camera_ RAW

Right_camera_RAW

Stereo Calibration :

 Below Results are taken from Single camera calibration and the results are convincing for my application  
            // Intrensics for camera 1
            cam1.D.at<double>(0,0) = -0.398815188578848;
            cam1.D.at<double>(0,1) = 0.1905857048302127;
            cam1.D.at<double>(0,4) =  -0.04680318003634255;
            cam1.D.at<double>(0,2) = -0.0002812901909228356;
            cam1.D.at<double>(0,3) = 0.000243137481893496;
            cam1.K.at<double>(0,0) = 628.9172544601657;
            cam1.K.at<double>(1,1) = 628.1819415926257;
            cam1.K.at<double>(0,2) = 535.8228969975479;
            cam1.K.at<double>(1,2) = 475.3861663058648;

            // Intrensics for camera 2
            cam2.D.at<double>(0,0) = -0.3967195994789521;
            cam2.D.at<double>(0,1) = 0.1857154225235964;
            cam2.D.at<double>(0,4) =-0.04381265364547015;
            cam2.D.at<double>(0,2) = 0.00001706655; //1.706655057178016e-05;
            cam2.D.at<double>(0,3) = -0.0003073193941007271;
            cam2.K.at<double>(0,0) = 626.3824461449379;
            cam2.K.at<double>(1,1) = 625.8431445566149;
            cam2.K.at<double>(0,2) = 487.1998524151916;
            cam2.K.at<double>(1,2) = 476.4919964592192;

Question 1 : What flag parameters should I add below statement to use the above intrinsic? Should I need to

CV_CALIB_FIX_INTRINSIC

             double rms = stereoCalibrate(cam1.RealP, cam1.ImageP, cam2.ImageP, cam1.K, cam1.D, cam2.K, cam2.D, cam1.img.size(), R, T, E, F);

Then I do rectification and undistort the original :

         stereoRectify(cam1.K, cam1.D, cam2.K, cam2.D, cam1.img.size(), R, T, R1, R2, P1, P2, Q, CALIB_ZERO_DISPARITY);
        initUndistortRectifyMap(cam1.K, cam1.D, R1, P1, cam1.img.size(), CV_32FC1, map1, map2);
        initUndistortRectifyMap(cam2.K, cam2.D, R2, P2, cam2.img.size(), CV_32FC1, map3, map4);

I then write my own function to remap this and save it to an image

        rectifiedimage(imgs_directory1, number, map1,map2, 1);
        rectifiedimage(imgs_directory2, number, map3,map4, 2);

above function uses the below CV fnction :

remap(img, imgdis_corrected, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar());

Resultant Image :

Left_Corrected and Rectified

Right_corrected and Rectified

Question 2: Why does this initUndistortRectifyMap() does not provide me (only) the undistorted Area by just cropping. I want to measure the FOV after distortion correction. Is there a way to achieve it ?

Question 3: Currently my RMS value is 26.2957 , how I can improve my results ?

*Question 4: Do stereo matching and stereo correspondence both same? *

*Question 5: I want to draw an epipolar line in the right image for the selected pixel in the left image after rectification. Any idea on how to implement it? Good reference? *

Bad Results - Stereo Calibration - Rectification - Correspondence

Hi I am trying to calibration intrinsics and extrinsic of my stereo camera, then rectify them and find the correspondence point.

Original Image :

Left_Camera_ RAW

Right_camera_RAW

Stereo Calibration :

 Below Results are taken from Single camera calibration and the results are convincing for my application  
            // Intrensics for camera 1
            cam1.D.at<double>(0,0) = -0.398815188578848;
            cam1.D.at<double>(0,1) = 0.1905857048302127;
            cam1.D.at<double>(0,4) =  -0.04680318003634255;
            cam1.D.at<double>(0,2) = -0.0002812901909228356;
            cam1.D.at<double>(0,3) = 0.000243137481893496;
            cam1.K.at<double>(0,0) = 628.9172544601657;
            cam1.K.at<double>(1,1) = 628.1819415926257;
            cam1.K.at<double>(0,2) = 535.8228969975479;
            cam1.K.at<double>(1,2) = 475.3861663058648;

            // Intrensics for camera 2
            cam2.D.at<double>(0,0) = -0.3967195994789521;
            cam2.D.at<double>(0,1) = 0.1857154225235964;
            cam2.D.at<double>(0,4) =-0.04381265364547015;
            cam2.D.at<double>(0,2) = 0.00001706655; //1.706655057178016e-05;
            cam2.D.at<double>(0,3) = -0.0003073193941007271;
            cam2.K.at<double>(0,0) = 626.3824461449379;
            cam2.K.at<double>(1,1) = 625.8431445566149;
            cam2.K.at<double>(0,2) = 487.1998524151916;
            cam2.K.at<double>(1,2) = 476.4919964592192;

Question 1 : What flag parameters should I add below statement to use the above intrinsic? Should I need to

CV_CALIB_FIX_INTRINSIC

             double rms = stereoCalibrate(cam1.RealP, cam1.ImageP, cam2.ImageP, cam1.K, cam1.D, cam2.K, cam2.D, cam1.img.size(), R, T, E, F);

Then I do rectification and undistort the original :

         stereoRectify(cam1.K, cam1.D, cam2.K, cam2.D, cam1.img.size(), R, T, R1, R2, P1, P2, Q, CALIB_ZERO_DISPARITY);
        initUndistortRectifyMap(cam1.K, cam1.D, R1, P1, cam1.img.size(), CV_32FC1, map1, map2);
        initUndistortRectifyMap(cam2.K, cam2.D, R2, P2, cam2.img.size(), CV_32FC1, map3, map4);

I then write my own function to remap this and save it to an image

        rectifiedimage(imgs_directory1, number, map1,map2, 1);
        rectifiedimage(imgs_directory2, number, map3,map4, 2);

above function uses the below CV fnction :

remap(img, imgdis_corrected, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar());

Resultant Image :

Left_Corrected and Rectified

Right_corrected and Rectified

Question 2: Why does this initUndistortRectifyMap() does not provide me (only) the undistorted Area by just cropping. I want to measure the FOV after distortion correction. Is there a way to achieve it ?

Question 3: Currently my RMS value is 26.2957 , how I can improve my results ?

*Question 4: Do stereo matching and stereo correspondence both same? *

*Question 5: I want to draw an epipolar line in the right image for the selected pixel in the left image after rectification. Any idea on how to implement it? Good reference? *

Bad Results - Stereo Calibration - Rectification - Correspondence

Hi I am trying to calibration intrinsics and extrinsic of my stereo camera, then rectify them and find the correspondence point.

Original Image :

Left_Camera_ RAW

Right_camera_RAW

Stereo Calibration :

 Below Results are taken from Single camera calibration and the results are convincing for my application  
            // Intrensics for camera 1
            cam1.D.at<double>(0,0) = -0.398815188578848;
            cam1.D.at<double>(0,1) = 0.1905857048302127;
            cam1.D.at<double>(0,4) =  -0.04680318003634255;
            cam1.D.at<double>(0,2) = -0.0002812901909228356;
            cam1.D.at<double>(0,3) = 0.000243137481893496;
            cam1.K.at<double>(0,0) = 628.9172544601657;
            cam1.K.at<double>(1,1) = 628.1819415926257;
            cam1.K.at<double>(0,2) = 535.8228969975479;
            cam1.K.at<double>(1,2) = 475.3861663058648;

            // Intrensics for camera 2
            cam2.D.at<double>(0,0) = -0.3967195994789521;
            cam2.D.at<double>(0,1) = 0.1857154225235964;
            cam2.D.at<double>(0,4) =-0.04381265364547015;
            cam2.D.at<double>(0,2) = 0.00001706655; //1.706655057178016e-05;
            cam2.D.at<double>(0,3) = -0.0003073193941007271;
            cam2.K.at<double>(0,0) = 626.3824461449379;
            cam2.K.at<double>(1,1) = 625.8431445566149;
            cam2.K.at<double>(0,2) = 487.1998524151916;
            cam2.K.at<double>(1,2) = 476.4919964592192;

Question 1 : What flag parameters should I add below statement to use the above intrinsic? Should I need to

CV_CALIB_FIX_INTRINSIC

             double rms = stereoCalibrate(cam1.RealP, cam1.ImageP, cam2.ImageP, cam1.K, cam1.D, cam2.K, cam2.D, cam1.img.size(), R, T, E, F);

Then I do rectification and undistort the original :

         stereoRectify(cam1.K, cam1.D, cam2.K, cam2.D, cam1.img.size(), R, T, R1, R2, P1, P2, Q, CALIB_ZERO_DISPARITY);
        initUndistortRectifyMap(cam1.K, cam1.D, R1, P1, cam1.img.size(), CV_32FC1, map1, map2);
        initUndistortRectifyMap(cam2.K, cam2.D, R2, P2, cam2.img.size(), CV_32FC1, map3, map4);

I then write my own function to remap this and save it to an image

        rectifiedimage(imgs_directory1, number, map1,map2, 1);
        rectifiedimage(imgs_directory2, number, map3,map4, 2);

above function uses the below CV fnction :

remap(img, imgdis_corrected, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar());

Resultant Image :

Left_Corrected and Rectified

Right_corrected and Rectified

Question 2: Why does this initUndistortRectifyMap() does not provide me (only) the undistorted Area by just cropping. I want to measure the FOV after distortion correction. Is there a way to achieve it ?

Question 3: Currently my RMS value is 26.2957 , how I can improve my results ?

*Question 4: Do stereo matching and stereo correspondence both same? *

*Question 5: I want to draw an epipolar line in the right image for the selected pixel in the left image after rectification. Any idea on how to implement it? Good reference? *

Bad Results - Stereo Calibration - Rectification - Correspondence

Hi I am trying to calibration intrinsics and extrinsic of my stereo camera, then rectify them and find the correspondence point.

Original and Result Image :

Images

Stereo Calibration :

 Below Results are taken from Single camera calibration and the results are convincing for my application  
            // Intrensics for camera 1
            cam1.D.at<double>(0,0) = -0.398815188578848;
            cam1.D.at<double>(0,1) = 0.1905857048302127;
            cam1.D.at<double>(0,4) =  -0.04680318003634255;
            cam1.D.at<double>(0,2) = -0.0002812901909228356;
            cam1.D.at<double>(0,3) = 0.000243137481893496;
            cam1.K.at<double>(0,0) = 628.9172544601657;
            cam1.K.at<double>(1,1) = 628.1819415926257;
            cam1.K.at<double>(0,2) = 535.8228969975479;
            cam1.K.at<double>(1,2) = 475.3861663058648;

            // Intrensics for camera 2
            cam2.D.at<double>(0,0) = -0.3967195994789521;
            cam2.D.at<double>(0,1) = 0.1857154225235964;
            cam2.D.at<double>(0,4) =-0.04381265364547015;
            cam2.D.at<double>(0,2) = 0.00001706655; //1.706655057178016e-05;
            cam2.D.at<double>(0,3) = -0.0003073193941007271;
            cam2.K.at<double>(0,0) = 626.3824461449379;
            cam2.K.at<double>(1,1) = 625.8431445566149;
            cam2.K.at<double>(0,2) = 487.1998524151916;
            cam2.K.at<double>(1,2) = 476.4919964592192;

Question 1 : What flag parameters should I add below statement to use the above intrinsic? Should I need to

CV_CALIB_FIX_INTRINSIC

             double rms = stereoCalibrate(cam1.RealP, cam1.ImageP, cam2.ImageP, cam1.K, cam1.D, cam2.K, cam2.D, cam1.img.size(), R, T, E, F);

Then I do rectification and undistort the original :

         stereoRectify(cam1.K, cam1.D, cam2.K, cam2.D, cam1.img.size(), R, T, R1, R2, P1, P2, Q, CALIB_ZERO_DISPARITY);
        initUndistortRectifyMap(cam1.K, cam1.D, R1, P1, cam1.img.size(), CV_32FC1, map1, map2);
        initUndistortRectifyMap(cam2.K, cam2.D, R2, P2, cam2.img.size(), CV_32FC1, map3, map4);

I then write my own function to remap this and save it to an image

        rectifiedimage(imgs_directory1, number, map1,map2, 1);
        rectifiedimage(imgs_directory2, number, map3,map4, 2);

above function uses the below CV fnction :

remap(img, imgdis_corrected, mapx, mapy, cv::INTER_LINEAR, cv::BORDER_CONSTANT, cv::Scalar());

Resultant Image :

Question 2: Why does this initUndistortRectifyMap() does not provide me (only) the undistorted Area by just cropping. I want to measure the FOV after distortion correction. Is there a way to achieve it ?

Question 3: Currently my RMS value is 26.2957 , how I can improve my results ?

*Question 4: Do stereo matching and stereo correspondence both same? *

*Question 5: I want to draw an epipolar line in the right image for the selected pixel in the left image after rectification. Any idea on how to implement it? Good reference? *