Merge pull request #15399 from terfendail:perf_stereobm

This commit is contained in:
Alexander Alekhin 2019-09-17 14:26:43 +00:00
commit 46fd112f9b

View File

@ -41,20 +41,18 @@ namespace opencv_test
using namespace perf;
using namespace testing;
static void MakeArtificialExample(RNG rng, Mat& dst_left_view, Mat& dst_view);
static void MakeArtificialExample(Mat& dst_left_view, Mat& dst_view);
CV_ENUM(SGBMModes, StereoSGBM::MODE_SGBM, StereoSGBM::MODE_SGBM_3WAY, StereoSGBM::MODE_HH4);
typedef tuple<Size, int, SGBMModes> SGBMParams;
typedef TestBaseWithParam<SGBMParams> TestStereoCorresp;
typedef TestBaseWithParam<SGBMParams> TestStereoCorrespSGBM;
#ifndef _DEBUG
PERF_TEST_P( TestStereoCorresp, SGBM, Combine(Values(Size(1280,720),Size(640,480)), Values(256,128), SGBMModes::all()) )
PERF_TEST_P( TestStereoCorrespSGBM, SGBM, Combine(Values(Size(1280,720),Size(640,480)), Values(256,128), SGBMModes::all()) )
#else
PERF_TEST_P( TestStereoCorresp, DISABLED_TooLongInDebug_SGBM, Combine(Values(Size(1280,720),Size(640,480)), Values(256,128), SGBMModes::all()) )
PERF_TEST_P( TestStereoCorrespSGBM, DISABLED_TooLongInDebug_SGBM, Combine(Values(Size(1280,720),Size(640,480)), Values(256,128), SGBMModes::all()) )
#endif
{
RNG rng(0);
SGBMParams params = GetParam();
Size sz = get<0>(params);
@ -65,7 +63,7 @@ PERF_TEST_P( TestStereoCorresp, DISABLED_TooLongInDebug_SGBM, Combine(Values(Siz
Mat src_right(sz, CV_8UC3);
Mat dst(sz, CV_16S);
MakeArtificialExample(rng,src_left,src_right);
MakeArtificialExample(src_left,src_right);
int wsize = 3;
int P1 = 8*src_left.channels()*wsize*wsize;
@ -78,8 +76,34 @@ PERF_TEST_P( TestStereoCorresp, DISABLED_TooLongInDebug_SGBM, Combine(Values(Siz
SANITY_CHECK(dst, .01, ERROR_RELATIVE);
}
void MakeArtificialExample(RNG rng, Mat& dst_left_view, Mat& dst_right_view)
typedef tuple<Size, int> BMParams;
typedef TestBaseWithParam<BMParams> TestStereoCorrespBM;
PERF_TEST_P(TestStereoCorrespBM, BM, Combine(Values(Size(1280, 720), Size(640, 480)), Values(256, 128)))
{
BMParams params = GetParam();
Size sz = get<0>(params);
int num_disparities = get<1>(params);
Mat src_left(sz, CV_8UC1);
Mat src_right(sz, CV_8UC1);
Mat dst(sz, CV_16S);
MakeArtificialExample(src_left, src_right);
int wsize = 21;
TEST_CYCLE()
{
Ptr<StereoBM> bm = StereoBM::create(num_disparities, wsize);
bm->compute(src_left, src_right, dst);
}
SANITY_CHECK(dst, .01, ERROR_RELATIVE);
}
void MakeArtificialExample(Mat& dst_left_view, Mat& dst_right_view)
{
RNG rng(0);
int w = dst_left_view.cols;
int h = dst_left_view.rows;