From 7f0a094e4e06b88fcbfeebd90c084c8cf39ac0f9 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Tue, 5 Dec 2023 13:36:17 +0100 Subject: [PATCH] Fix stereoRectify image boundaries again. This should have been fixed in https://github.com/opencv/opencv/pull/24035 --- 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 002394b917..c03e3a1c34 100644 --- a/modules/calib3d/src/calibration.cpp +++ b/modules/calib3d/src/calibration.cpp @@ -2707,11 +2707,11 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2, s0); double s1 = std::min(std::min(std::min((double)cx1/(cx1_0 - outer1.x), (double)cy1/(cy1_0 - outer1.y)), - (double)(newImgSize.width - cx1)/(outer1.x + outer1.width - cx1_0)), - (double)(newImgSize.height - cy1)/(outer1.y + outer1.height - cy1_0)); + (double)(newImgSize.width - 1 - cx1)/(outer1.x + outer1.width - cx1_0)), + (double)(newImgSize.height - 1 - cy1)/(outer1.y + outer1.height - cy1_0)); s1 = std::min(std::min(std::min(std::min((double)cx2/(cx2_0 - outer2.x), (double)cy2/(cy2_0 - outer2.y)), - (double)(newImgSize.width - cx2)/(outer2.x + outer2.width - cx2_0)), - (double)(newImgSize.height - cy2)/(outer2.y + outer2.height - cy2_0)), + (double)(newImgSize.width - 1 - cx2)/(outer2.x + outer2.width - cx2_0)), + (double)(newImgSize.height - 1 - cy2)/(outer2.y + outer2.height - cy2_0)), s1); s = s0*(1 - alpha) + s1*alpha;