Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

StereoRectify - does it work

Hi all,

I have a stereo camera setup - about 100mm apart

Simply I would like to get the matrix R1 R2 P1 P2 and Q so that I can first create a disparity map and next a point cloud

I am using StereoCalibrate with the following flags and pass in the intrinsic information that I have got from separate calibrations of each camera

CALIB_ZERO_TANGENT_DIST + CALIB_FIX_INTRINSIC + CALIB_SAME_FOCAL_LENGTH

I get around 0.8 rms for stereoCalibrate ()

I then use StereoRectify to get R1 R2 P1 P2

When I use StereoRectify it doesn't matter what setting I put into this function (CALIB_ZERO_DISPARITY set / not set) and what I change alpha value (-1, 0, 1) too the images do not rectify properly.

Also when I look at the extrinsic values for R1 R2 P1 P2 they look totally incorrect -even for simple values like fx and fy even though they are passed into sterocalibrate correctly

Now when I use StereoRectifyUncalibrated it computes R1 R2 P1 P2 correctly and the images are rectified correctly

I tried running the same code on both 3.3.1 and 3.4.2 as there has been talk of something wrong with StereoRectify in 3.4.1.

Am I missing something or is there a bug with StereoRectify in version 3.4.2 and 3.3.1?? (I would prefer to use it over stereocalibrateUncalibrated)

Thanks in advance for your inputs

JT

StereoRectify - does it work

Hi all,

I have a stereo camera setup - about 100mm apart

Simply I would like to get the matrix R1 R2 P1 P2 and Q so that I can first create a disparity map and next a point cloud

I am using StereoCalibrate with the following flags and pass in the intrinsic information that I have got from separate calibrations of each camera

CALIB_ZERO_TANGENT_DIST + CALIB_FIX_INTRINSIC + CALIB_SAME_FOCAL_LENGTH

I get around 0.8 rms for stereoCalibrate ()

I then use StereoRectify to get R1 R2 P1 P2

When I use StereoRectify it doesn't matter what setting I put into this function (CALIB_ZERO_DISPARITY set / not set) and what I change alpha value (-1, 0, 1) too the images do not rectify properly.

Also when I look at the extrinsic values for R1 R2 P1 P2 they look totally incorrect -even for simple values like fx and fy even though they are passed into sterocalibrate correctly

Now when I use StereoRectifyUncalibrated it computes R1 R2 P1 P2 correctly and the images are rectified correctly

I tried running the same code on both 3.3.1 and 3.4.2 as there has been talk of something wrong with StereoRectify in 3.4.1.

Am I missing something or is there a bug with StereoRectify in version 3.4.2 and 3.3.1?? (I would prefer to use it over stereocalibrateUncalibrated)

Thanks in advance for your inputs

JT

Update:

Hi all,

Attached is an image where I use StereoRectify. You can see the images are not row aligned.

When I use SterreoRectifyUncalibrated it works fine

C:\fakepath\StereorectifyResultsIncorrectvsUncalibratedVersion.PNG

I have tried this on the following versions

3.4.2 & 3.3.1

The problem I have looks very similar to this problem but I am not sure if this is still open or not

https://github.com/opencv/opencv/issues/11131

The code I am using is stereo_calib.cpp which is available from the examples folder in cpp in OpenCV

Any inputs would be very welcome.

Thanks

StereoRectify - does it work

Hi all,

I have a stereo camera setup - about 100mm apart

Simply I would like to get the matrix R1 R2 P1 P2 and Q so that I can first create a disparity map and next a point cloud

I am using StereoCalibrate with the following flags and pass in the intrinsic information that I have got from separate calibrations of each camera

CALIB_ZERO_TANGENT_DIST + CALIB_FIX_INTRINSIC + CALIB_SAME_FOCAL_LENGTH

I get around 0.8 rms for stereoCalibrate ()

I then use StereoRectify to get R1 R2 P1 P2

When I use StereoRectify it doesn't matter what setting I put into this function (CALIB_ZERO_DISPARITY set / not set) and what I change alpha value (-1, 0, 1) too the images do not rectify properly.

Also when I look at the extrinsic values for R1 R2 P1 P2 they look totally incorrect -even for simple values like fx and fy even though they are passed into sterocalibrate correctly

Now when I use StereoRectifyUncalibrated it computes R1 R2 P1 P2 correctly and the images are rectified correctly

I tried running the same code on both 3.3.1 and 3.4.2 as there has been talk of something wrong with StereoRectify in 3.4.1.

Am I missing something or is there a bug with StereoRectify in version 3.4.2 and 3.3.1?? (I would prefer to use it over stereocalibrateUncalibrated)

Thanks in advance for your inputs

JT

Update:Update 1:

Hi all,

Attached is an image where I use StereoRectify. You can see the images are not row aligned.

When I use SterreoRectifyUncalibrated it works fine

C:\fakepath\StereorectifyResultsIncorrectvsUncalibratedVersion.PNG

I have tried this on the following versions

3.4.2 & 3.3.1

The problem I have looks very similar to this problem but I am not sure if this is still open or not

https://github.com/opencv/opencv/issues/11131

The code I am using is stereo_calib.cpp which is available from the examples folder in cpp in OpenCV

Any inputs would be very welcome.

Thanks

update 2:

This is the calibration file I am using. You can see the R & T matrix in here along with the intrinsic values I am using. The cameras are 2448 x 2048 with a 12.5mm lens which should equate to 3623 for f (12.5mm / 0.00345(size of pixels in camera))

cam1_intrinsics: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ 3.720140438796924e+03, 0., 1.285507273110709e+03, 0., 3.724303519202642e+03, 1.005642652331629e+03, 0., 0., 1. ] cam1_distorsion: !!opencv-matrix rows: 1 cols: 5 dt: d data: [ -0.057043329274289, 0.223182551657098, 0., 0., 0. ] cam2_intrinsics: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ 3.782786803634638e+03, 0., 1.241950747511028e+03, 0., 3.788182391361000e+03, 9.782339357588124e+02, 0., 0., 1. ] cam2_distorsion: !!opencv-matrix rows: 1 cols: 5 dt: d data: [ -0.062491094405233, 0.252016985281970, 0., 0., 0. ] R: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ 9.5956335394786729e-01, -4.0891553813976841e-02, -2.7850682323239140e-01, 3.9918591084260990e-02, 9.9916089220343407e-01, -9.1661102483683431e-03, 2.7864794247610625e-01, -2.3221364982101583e-03, 9.6039051007177079e-01 ] T: !!opencv-matrix rows: 3 cols: 1 dt: d data: [ 1.0624361144822345e-01, 2.2580758313824108e-03, 1.3820089188378556e-02 ]

R1: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ -3.0011085810446082e-02, 5.6916733894551877e-04, -7.8185877362471103e-04, -2.0141573317075944e-04, -3.0029323494341204e-02, 1.1228021654532613e-04, -4.2988512575849302e-03, 2.1081439682467428e-04, -2.9876473788679050e-02 ] R2: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ 9.9984527415231661e-01, 3.1983854974017484e-02, -4.2058492718333174e-04, -3.3654741000479792e-02, 9.9943348035179158e-01, -8.1087449409267265e-05, -1.3497999780933678e-01, -4.3178487571361420e-03, 9.9970165498120289e-01 ] P1: !!opencv-matrix rows: 3 cols: 4 dt: d data: [ 3.7562429552818212e+03, 0., 1.1477068481445313e+03, 0., 0., 3.7562429552818212e+03, 1.0575966339111328e+03, 0., 0., 0., 1., 0. ] P2: !!opencv-matrix rows: 3 cols: 4 dt: d data: [ 3.7562429552818212e+03, 0., 1.1477068481445313e+03, -401.896931356825439, 0., 3.7562429552818212e+03, 1.0575966339111328e+03, 0., 0., 0., 1., 0. ] Q: !!opencv-matrix rows: 4 cols: 4 dt: d data: [ 1., 0., 0., -1.1477068481445313e+03, 0., 1., 0., -1.0575966339111328e+03, 0., 0., 0., 3.7562429552818212e+03, 0., 0., 9.3316236170415525e+00, 0. ] F: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ 2.928136131458271e-08, -1.026442171738228e-06, 0.001943807649734, -1.104658972872981e-06, 2.136952233150114e-08, -0.027155717479924, 0.001267632917175, 0.029960008152147, -4.612881932573043 ]


I tried running the same code against opencv 3.1.0 and I get the same result so I doubt it's a bug in the opencv SW as surely it would be caught before now but I am at a loss. The intrinsics look correct and are comparable to results I get in Mathlab using the stereo calibration app.

StereoRectify - does it work

Hi all,

I have a stereo camera setup - about 100mm apart

Simply I would like to get the matrix R1 R2 P1 P2 and Q so that I can first create a disparity map and next a point cloud

I am using StereoCalibrate with the following flags and pass in the intrinsic information that I have got from separate calibrations of each camera

CALIB_ZERO_TANGENT_DIST + CALIB_FIX_INTRINSIC + CALIB_SAME_FOCAL_LENGTH

I get around 0.8 rms for stereoCalibrate ()

I then use StereoRectify to get R1 R2 P1 P2

When I use StereoRectify it doesn't matter what setting I put into this function (CALIB_ZERO_DISPARITY set / not set) and what I change alpha value (-1, 0, 1) too the images do not rectify properly.

Also when I look at the extrinsic values for R1 R2 P1 P2 they look totally incorrect -even for simple values like fx and fy even though they are passed into sterocalibrate correctly

Now when I use StereoRectifyUncalibrated it computes R1 R2 P1 P2 correctly and the images are rectified correctly

I tried running the same code on both 3.3.1 and 3.4.2 as there has been talk of something wrong with StereoRectify in 3.4.1.

Am I missing something or is there a bug with StereoRectify in version 3.4.2 and 3.3.1?? (I would prefer to use it over stereocalibrateUncalibrated)

Thanks in advance for your inputs

JT

Update 1:

Hi all,

Attached is an image where I use StereoRectify. You can see the images are not row aligned.

When I use SterreoRectifyUncalibrated it works fine

C:\fakepath\StereorectifyResultsIncorrectvsUncalibratedVersion.PNG

I have tried this on the following versions

3.4.2 & 3.3.1

The problem I have looks very similar to this problem but I am not sure if this is still open or not

https://github.com/opencv/opencv/issues/11131

The code I am using is stereo_calib.cpp which is available from the examples folder in cpp in OpenCV

Any inputs would be very welcome.

Thanks

update 2:

This is the calibration file I am using. You can see the R & T matrix in here along with the intrinsic values I am using. The cameras are 2448 x 2048 with a 12.5mm lens which should equate to 3623 for f (12.5mm / 0.00345(size of pixels in camera))

cam1_intrinsics: !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [ 3.720140438796924e+03, 0., 1.285507273110709e+03, 0.,
       3.724303519202642e+03, 1.005642652331629e+03, 0., 0., 1. ]
cam1_distorsion: !!opencv-matrix
   rows: 1
   cols: 5
   dt: d
   data: [ -0.057043329274289, 0.223182551657098,
       0., 0.,
       0. ]
cam2_intrinsics: !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [ 3.782786803634638e+03, 0., 1.241950747511028e+03, 0.,
       3.788182391361000e+03, 9.782339357588124e+02, 0., 0., 1. ]
cam2_distorsion: !!opencv-matrix
   rows: 1
   cols: 5
   dt: d
   data: [ -0.062491094405233, 0.252016985281970,
       0., 0.,
       0. ]
R: !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [ 9.5956335394786729e-01, -4.0891553813976841e-02,
       -2.7850682323239140e-01, 3.9918591084260990e-02,
       9.9916089220343407e-01, -9.1661102483683431e-03,
       2.7864794247610625e-01, -2.3221364982101583e-03,
       9.6039051007177079e-01 ]
T: !!opencv-matrix
   rows: 3
   cols: 1
   dt: d
   data: [ 1.0624361144822345e-01, 2.2580758313824108e-03,
       1.3820089188378556e-02 ]

] R1: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ -3.0011085810446082e-02, 5.6916733894551877e-04, -7.8185877362471103e-04, -2.0141573317075944e-04, -3.0029323494341204e-02, 1.1228021654532613e-04, -4.2988512575849302e-03, 2.1081439682467428e-04, -2.9876473788679050e-02 ] R2: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ 9.9984527415231661e-01, 3.1983854974017484e-02, -4.2058492718333174e-04, -3.3654741000479792e-02, 9.9943348035179158e-01, -8.1087449409267265e-05, -1.3497999780933678e-01, -4.3178487571361420e-03, 9.9970165498120289e-01 ] P1: !!opencv-matrix rows: 3 cols: 4 dt: d data: [ 3.7562429552818212e+03, 0., 1.1477068481445313e+03, 0., 0., 3.7562429552818212e+03, 1.0575966339111328e+03, 0., 0., 0., 1., 0. ] P2: !!opencv-matrix rows: 3 cols: 4 dt: d data: [ 3.7562429552818212e+03, 0., 1.1477068481445313e+03, -401.896931356825439, 0., 3.7562429552818212e+03, 1.0575966339111328e+03, 0., 0., 0., 1., 0. ] Q: !!opencv-matrix rows: 4 cols: 4 dt: d data: [ 1., 0., 0., -1.1477068481445313e+03, 0., 1., 0., -1.0575966339111328e+03, 0., 0., 0., 3.7562429552818212e+03, 0., 0., 9.3316236170415525e+00, 0. ] F: !!opencv-matrix rows: 3 cols: 3 dt: d data: [ 2.928136131458271e-08, -1.026442171738228e-06, 0.001943807649734, -1.104658972872981e-06, 2.136952233150114e-08, -0.027155717479924, 0.001267632917175, 0.029960008152147, -4.612881932573043 ]

]

I tried running the same code against opencv 3.1.0 and I get the same result so I doubt it's a bug in the opencv SW as surely it would be caught before now but I am at a loss. The intrinsics look correct and are comparable to results I get in Mathlab using the stereo calibration app.