diff --git a/modules/calib3d/src/stereobm.cpp b/modules/calib3d/src/stereobm.cpp index afc404bffe..96c8d0662d 100644 --- a/modules/calib3d/src/stereobm.cpp +++ b/modules/calib3d/src/stereobm.cpp @@ -347,7 +347,8 @@ public: htext(nstripes, NULL), cbuf0(nstripes, NULL), sad_short(nstripes, NULL), - hsad_short(nstripes, NULL) + hsad_short(nstripes, NULL), + prefilter() { const int wsz = params.SADWindowSize; const int ndisp = params.numDisparities; @@ -379,7 +380,7 @@ public: if (params.useNormPrefilter()) { for (size_t i = 0; i < 2; ++i) - area.allocate(prefilter[0], width + params.preFilterSize + 2); + area.allocate(prefilter[i], width + params.preFilterSize + 2); } area.commit(); diff --git a/modules/calib3d/test/test_stereomatching.cpp b/modules/calib3d/test/test_stereomatching.cpp index 94fc9718cc..e92c170c00 100644 --- a/modules/calib3d/test/test_stereomatching.cpp +++ b/modules/calib3d/test/test_stereomatching.cpp @@ -809,6 +809,55 @@ protected: } }; +TEST(Calib3d_StereoBM, regression) { CV_StereoBMTest test; test.safe_run(); } + +/* < preFilter, < preFilterCap, SADWindowSize > >*/ +typedef tuple < int, tuple < int, int > > BufferBM_Params_t; + +typedef testing::TestWithParam< BufferBM_Params_t > Calib3d_StereoBM_BufferBM; + +const int preFilters[] = +{ + StereoBM::PREFILTER_NORMALIZED_RESPONSE, + StereoBM::PREFILTER_XSOBEL +}; + +const tuple < int, int > useShortsConditions[] = +{ + make_tuple(30, 19), + make_tuple(32, 23) +}; + +TEST_P(Calib3d_StereoBM_BufferBM, memAllocsTest) +{ + const int preFilter = get<0>(GetParam()); + const int preFilterCap = get<0>(get<1>(GetParam())); + const int SADWindowSize = get<1>(get<1>(GetParam())); + + String path = cvtest::TS::ptr()->get_data_path() + "cv/stereomatching/datasets/teddy/"; + Mat leftImg = imread(path + "im2.png", 0); + ASSERT_FALSE(leftImg.empty()); + Mat rightImg = imread(path + "im6.png", 0); + ASSERT_FALSE(rightImg.empty()); + Mat leftDisp; + { + Ptr bm = StereoBM::create(16,9); + bm->setPreFilterType(preFilter); + bm->setPreFilterCap(preFilterCap); + bm->setBlockSize(SADWindowSize); + bm->compute( leftImg, rightImg, leftDisp); + + ASSERT_FALSE(leftDisp.empty()); + } +} + +INSTANTIATE_TEST_CASE_P(/*nothing*/, Calib3d_StereoBM_BufferBM, + testing::Combine( + testing::ValuesIn(preFilters), + testing::ValuesIn(useShortsConditions) + ) + ); + //----------------------------------- StereoSGBM test ----------------------------------------------------- class CV_StereoSGBMTest : public CV_StereoMatchingTest @@ -869,8 +918,6 @@ protected: } }; - -TEST(Calib3d_StereoBM, regression) { CV_StereoBMTest test; test.safe_run(); } TEST(Calib3d_StereoSGBM, regression) { CV_StereoSGBMTest test; test.safe_run(); } TEST(Calib3d_StereoSGBM_HH4, regression)