From 4b3771ce320aa17a849074e04e4bb89dcd42de1d Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Wed, 26 May 2010 20:35:09 +0000 Subject: [PATCH] modified the sub-pixel disparity interpolation (by K. Konolige) --- modules/calib3d/src/stereobm.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/calib3d/src/stereobm.cpp b/modules/calib3d/src/stereobm.cpp index 8f414fe86d..f01c41e0bf 100644 --- a/modules/calib3d/src/stereobm.cpp +++ b/modules/calib3d/src/stereobm.cpp @@ -492,8 +492,8 @@ static void findStereoCorrespondenceBM_SSE2( const Mat& left, const Mat& right, if( 0 < mind && mind < ndisp - 1 ) { - int p = sad[mind+1], n = sad[mind-1], d = p + n - 2*sad[mind]; - dptr[y*dstep] = (short)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*128/d : 0) + 15) >> 4); + int p = sad[mind+1], n = sad[mind-1], d = p + n - 2*sad[mind] + std::abs(p - n); + dptr[y*dstep] = (short)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*256/d : 0) + 15) >> 4); } else dptr[y*dstep] = (short)((ndisp - mind - 1)*16); @@ -662,8 +662,8 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right, { sad[-1] = sad[1]; sad[ndisp] = sad[ndisp-2]; - int p = sad[mind+1], n = sad[mind-1], d = p + n - 2*sad[mind]; - dptr[y*dstep] = (short)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*128/d : 0) + 15) >> 4); + int p = sad[mind+1], n = sad[mind-1], d = p + n - 2*sad[mind] + std::abs(p - n); + dptr[y*dstep] = (short)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*256/d : 0) + 15) >> 4); costptr[y*coststep] = sad[mind]; } }