Bad Results - Stereo Calibration - Rectification - Correspondence

asked 2018-07-03 10:23:23 -0500

Thiyaga gravatar image

updated 2018-07-03 10:29:48 -0500

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 :


Stereo Calibration :

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

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

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


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

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? *

edit retag flag offensive close merge delete


You shouldn't be hand writing/hard coding camera parameters. Have a look at cv::FileStorage().

Der Luftmensch gravatar imageDer Luftmensch ( 2018-07-03 10:44:00 -0500 )edit