Passing Disparity Shift as a parameter.

This commit is contained in:
Your Name
2016-07-20 22:57:55 -03:00
parent 0e9c8e2dd5
commit 440ba2e4a7

View File

@@ -317,7 +317,6 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
} }
static int DISPARITY_SHIFT;
static const int DISPARITY_SHIFT_16S = 4; static const int DISPARITY_SHIFT_16S = 4;
static const int DISPARITY_SHIFT_32S = 8; static const int DISPARITY_SHIFT_32S = 8;
@@ -574,7 +573,7 @@ template <typename mType>
static void static void
findStereoCorrespondenceBM_( const Mat& left, const Mat& right, findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
Mat& disp, Mat& cost, const StereoBMParams& state, Mat& disp, Mat& cost, const StereoBMParams& state,
uchar* buf, int _dy0, int _dy1 ) uchar* buf, int _dy0, int _dy1, const int disp_shift )
{ {
const int ALIGN = 16; const int ALIGN = 16;
@@ -590,7 +589,7 @@ findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
int ftzero = state.preFilterCap; int ftzero = state.preFilterCap;
int textureThreshold = state.textureThreshold; int textureThreshold = state.textureThreshold;
int uniquenessRatio = state.uniquenessRatio; int uniquenessRatio = state.uniquenessRatio;
mType FILTERED = (mType)((mindisp - 1) << DISPARITY_SHIFT); mType FILTERED = (mType)((mindisp - 1) << disp_shift);
#if CV_NEON #if CV_NEON
CV_Assert (ndisp % 8 == 0); CV_Assert (ndisp % 8 == 0);
@@ -850,7 +849,7 @@ findStereoCorrespondenceBM_( const Mat& left, const Mat& right,
int p = sad[mind+1], n = sad[mind-1]; int p = sad[mind+1], n = sad[mind-1];
d = p + n - 2*sad[mind] + std::abs(p - n); d = p + n - 2*sad[mind] + std::abs(p - n);
dptr[y*dstep] = (mType)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*256/d : 0) + 15) dptr[y*dstep] = (mType)(((ndisp - mind - 1 + mindisp)*256 + (d != 0 ? (p-n)*256/d : 0) + 15)
>> (DISPARITY_SHIFT_32S - DISPARITY_SHIFT)); >> (DISPARITY_SHIFT_32S - disp_shift));
costptr[y*coststep] = sad[mind]; costptr[y*coststep] = sad[mind];
} }
} }
@@ -862,15 +861,12 @@ findStereoCorrespondenceBM( const Mat& left, const Mat& right,
Mat& disp, Mat& cost, const StereoBMParams& state, Mat& disp, Mat& cost, const StereoBMParams& state,
uchar* buf, int _dy0, int _dy1 ) uchar* buf, int _dy0, int _dy1 )
{ {
if(disp.type() == CV_16S){ if(disp.type() == CV_16S)
DISPARITY_SHIFT = DISPARITY_SHIFT_16S;
findStereoCorrespondenceBM_<short>(left, right, disp, cost, state, findStereoCorrespondenceBM_<short>(left, right, disp, cost, state,
buf, _dy0, _dy1 ); buf, _dy0, _dy1, DISPARITY_SHIFT_16S );
} else { else
DISPARITY_SHIFT = DISPARITY_SHIFT_32S;
findStereoCorrespondenceBM_<int>(left, right, disp, cost, state, findStereoCorrespondenceBM_<int>(left, right, disp, cost, state,
buf, _dy0, _dy1 ); buf, _dy0, _dy1, DISPARITY_SHIFT_32S );
}
} }
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL