From 7fd7bbc9f15dfc6fefdc3dc2888a7f2bbcdb11b5 Mon Sep 17 00:00:00 2001 From: look4pritam Date: Thu, 12 Sep 2013 15:17:11 +0530 Subject: [PATCH] The prism distortion coefficients are added for the stereo calibration. --- modules/calib3d/src/calibration.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/calib3d/src/calibration.cpp b/modules/calib3d/src/calibration.cpp index 132220d..5be2886 100644 --- a/modules/calib3d/src/calibration.cpp +++ b/modules/calib3d/src/calibration.cpp @@ -1638,12 +1638,12 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 CvTermCriteria termCrit, int flags ) { - const int NINTRINSIC = 12; + const int NINTRINSIC = 16; Ptr npoints, err, J_LR, Je, Ji, imagePoints[2], objectPoints, RT0; CvLevMarq solver; double reprojErr = 0; - double A[2][9], dk[2][8]={{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0}}, rlr[9]; + double A[2][9], dk[2][12]={{0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0}}, rlr[9]; CvMat K[2], Dist[2], om_LR, T_LR; CvMat R_LR = cvMat(3, 3, CV_64F, rlr); int i, k, p, ni = 0, ofs, nimages, pointsTotal, maxPoints = 0; @@ -1689,7 +1689,7 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 (_imagePoints1->rows == 1 && _imagePoints1->cols == pointsTotal && cn == 2)) ); K[k] = cvMat(3,3,CV_64F,A[k]); - Dist[k] = cvMat(1,8,CV_64F,dk[k]); + Dist[k] = cvMat(1,12,CV_64F,dk[k]); imagePoints[k].reset(cvCreateMat( points->rows, points->cols, CV_64FC(CV_MAT_CN(points->type)))); cvConvert( points, imagePoints[k] ); @@ -1768,6 +1768,13 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 imask[10] = imask[NINTRINSIC+10] = 0; if( flags & CV_CALIB_FIX_K6 ) imask[11] = imask[NINTRINSIC+11] = 0; + if( flags & CV_CALIB_FIX_S1_S2_S3_S4 ) + { + imask[12] = imask[NINTRINSIC+12] = 0; + imask[13] = imask[NINTRINSIC+13] = 0; + imask[14] = imask[NINTRINSIC+14] = 0; + imask[15] = imask[NINTRINSIC+15] = 0; + } } /* @@ -1842,6 +1849,10 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 iparam[4] = dk[k][0]; iparam[5] = dk[k][1]; iparam[6] = dk[k][2]; iparam[7] = dk[k][3]; iparam[8] = dk[k][4]; iparam[9] = dk[k][5]; iparam[10] = dk[k][6]; iparam[11] = dk[k][7]; + iparam[12] = dk[k][8]; + iparam[13] = dk[k][9]; + iparam[14] = dk[k][10]; + iparam[15] = dk[k][11]; } om_LR = cvMat(3, 1, CV_64F, solver.param->data.db); @@ -1908,6 +1919,10 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 dk[k][5] = iparam[k*NINTRINSIC+9]; dk[k][6] = iparam[k*NINTRINSIC+10]; dk[k][7] = iparam[k*NINTRINSIC+11]; + dk[k][8] = iparam[k*NINTRINSIC+12]; + dk[k][9] = iparam[k*NINTRINSIC+13]; + dk[k][10] = iparam[k*NINTRINSIC+14]; + dk[k][11] = iparam[k*NINTRINSIC+15]; } } -- 2.7.4