2

I have tried OpenCV cvStereoCalibrate function to calibrate pair of stereo camera. It works fine while calibrating a pair of cameras with the same resolution. But when I tried to calibrate a pair of cameras with very different resolution (right image is about 10 times as big as the left image). I got big reprojection error and not very meaningful results.

Below is the part of code I call cvStereoCalibrate in my program:

rpErr = cvStereoCalibrate( &_objectPoints, &_imagePoints1,
    &_imagePoints2, &_npoints,
    &_M1, &_D1, &_M2, &_D2,
    imageSize, &_R, &_T, &_E, &_F,
    cvTermCriteria(CV_TERMCRIT_ITER+
    CV_TERMCRIT_EPS, 100, 1e-5),
    CV_CALIB_ZERO_TANGENT_DIST);

If have also tried

rpErr = cvStereoCalibrate( &_objectPoints, &_imagePoints1,
    &_imagePoints2, &_npoints,
    &_M1, &_D1, &_M2, &_D2,
    imageSize, &_R, &_T, &_E, &_F,
    cvTermCriteria(CV_TERMCRIT_ITER+
    CV_TERMCRIT_EPS, 100, 1e-5),
);

I did not improve the result.

Anyone encountered similar problem before ? What could be wrong?

songyuanyao
  • 169,198
  • 16
  • 310
  • 405
miao
  • 41
  • 4
  • Try resize bigger image to have the same resolution as the small one. Notice that in stereoCalibrate you pass one image size, not two so it is a clue to use the same resolution for both images. – marol Apr 22 '14 at 09:06
  • Thank you very much for your reply. Yes, I ignored the parameter imageSize. My problem here is the two cameras have different aspect ratio. One is 5184*3456 (3:2) . The other is 1600*1200. If I resize the bigger image to the same size as the smaller one. I will distort the image's aspect ratio. Then things get a bit complicated. – miao Apr 23 '14 at 05:26
  • 1
    As far as I know opencv does not support different images aspect ratio. You can see an answer here: http://stackoverflow.com/questions/22877869/stereocalibrate-for-different-cameras-rgb-and-infrared Hope it helps. – marol Apr 23 '14 at 07:55
  • Thank you marol. the link really helps. please see my answer below. – miao Apr 24 '14 at 01:58

1 Answers1

2

I did individual intrinsic calibration on each camera first using cvCalibrateCamera2, then used the output for cvStereoCalibrate (with parameter CV_CALIB_FIX_INTRINSIC) . This gave me small reprojection error and quite meaningful results.

It seems it is not necessary to resize the bigger image. In cvStereoCalibrate, we can set imageSize as the size of one camera image. As this parameter is only useful for initialization in intrinsic camera calibration (according to openCV documentation), which is not used if cvStereoCalibrate is called with parameter CV_CALIB_FIX_INTRINSIC.

Below is the part of code

rpErr_intrinsic1 =cvCalibrateCamera2(&_objectPoints, &_imagePoints1, &_npoints, imageSize1, &_M1, &_D1, NULL, NULL,
CV_CALIB_ZERO_TANGENT_DIST);

rpErr_intrinsic2 = cvCalibrateCamera2(&_objectPoints, &_imagePoints2, &_npoints, imageSize2, &_M2, &_D2, NULL, NULL,
CV_CALIB_ZERO_TANGENT_DIST);

rpErr = cvStereoCalibrate( &_objectPoints, &_imagePoints1, &_imagePoints2, &_npoints, &_M1, &_D1, &_M2, &_D2, imageSize, &_R, &_T, &_E, &_F, cvTermCriteria(CV_TERMCRIT_ITER+ CV_TERMCRIT_EPS, 100, 1e-5), CV_CALIB_FIX_INTRINSIC+ CV_CALIB_ZERO_TANGENT_DIST);

miao
  • 41
  • 4
  • Nice. You could also post what values of calibration error you've got the lease (for people dealing with two different image sizes stereo calibration problem) can be helpful information. – marol Apr 24 '14 at 07:35
  • Are the images you used for CalibrateCamera and stereoCalibrate the same? – spurra Jul 14 '15 at 13:39