From 93ff1fb2f21a552c258fc2e9f7973f7d5b159cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D1=83=D0=BD=20=D0=92=D0=B8=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80?= Date: Mon, 28 Mar 2016 15:59:18 +0300 Subject: [PATCH] Correct image borders and principal point computation in cv::stereoRectify --- modules/calib3d/src/calibration.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/calib3d/src/calibration.cpp b/modules/calib3d/src/calibration.cpp index b8f569aeb8..8ff0c2cc8c 100644 --- a/modules/calib3d/src/calibration.cpp +++ b/modules/calib3d/src/calibration.cpp @@ -2289,8 +2289,8 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2, for( i = 0; i < 4; i++ ) { int j = (i<2) ? 0 : 1; - _pts[i].x = (float)((i % 2)*(nx-1)); - _pts[i].y = (float)(j*(ny-1)); + _pts[i].x = (float)((i % 2)*(nx)); + _pts[i].y = (float)(j*(ny)); } cvUndistortPoints( &pts, &pts, A, Dk, 0, 0 ); cvConvertPointsHomogeneous( &pts, &pts_3 ); @@ -2304,8 +2304,8 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2, _a_tmp[1][2]=0.0; cvProjectPoints2( &pts_3, k == 0 ? _R1 : _R2, &Z, &A_tmp, 0, &pts ); CvScalar avg = cvAvg(&pts); - cc_new[k].x = (nx-1)/2 - avg.val[0]; - cc_new[k].y = (ny-1)/2 - avg.val[1]; + cc_new[k].x = (nx)/2 - avg.val[0]; + cc_new[k].y = (ny)/2 - avg.val[1]; } // vertical focal length must be the same for both images to keep the epipolar constraint