Skip to content

Commit ab006c9

Browse files
authored
Merge pull request #3081 from asmorkalov:as/stereo_bm_uniqueness_ratio
Uniqueness ratio support for cuda::StereoBM * Naive implementation of uniqueness ratio option for cuda::StereoBM. * Optimized memory consumption in cuda::stereoBM with uniqueness check. * Got rid of line_disps array. * Reduced line_ssds. * Apply streams for all parts of cuda::stereoBM::compute. * Added perf test for CUDA stereoBM with uniqueness check. * Optimized global memory transactions. * Restored sync data transfers as they use stack variables. * Do not use constant memory in stereoBM to exclude stream races. * Code review fixes.
1 parent 80ff29a commit ab006c9

File tree

4 files changed

+254
-65
lines changed

4 files changed

+254
-65
lines changed

modules/cudastereo/perf/perf_stereo.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,45 @@ PERF_TEST_P(ImagePair, StereoBM,
8787
}
8888
}
8989

90+
PERF_TEST_P(ImagePair, StereoBMwithUniqueness,
91+
Values(pair_string("gpu/perf/aloe.png", "gpu/perf/aloeR.png")))
92+
{
93+
declare.time(300.0);
94+
95+
const cv::Mat imgLeft = readImage(GET_PARAM(0), cv::IMREAD_GRAYSCALE);
96+
ASSERT_FALSE(imgLeft.empty());
97+
98+
const cv::Mat imgRight = readImage(GET_PARAM(1), cv::IMREAD_GRAYSCALE);
99+
ASSERT_FALSE(imgRight.empty());
100+
101+
const int ndisp = 256;
102+
103+
if (PERF_RUN_CUDA())
104+
{
105+
cv::Ptr<cv::StereoBM> d_bm = cv::cuda::createStereoBM(ndisp);
106+
d_bm->setUniquenessRatio(10);
107+
108+
const cv::cuda::GpuMat d_imgLeft(imgLeft);
109+
const cv::cuda::GpuMat d_imgRight(imgRight);
110+
cv::cuda::GpuMat dst;
111+
112+
TEST_CYCLE() d_bm->compute(d_imgLeft, d_imgRight, dst);
113+
114+
CUDA_SANITY_CHECK(dst);
115+
}
116+
else
117+
{
118+
cv::Ptr<cv::StereoBM> bm = cv::StereoBM::create(ndisp);
119+
bm->setUniquenessRatio(10);
120+
121+
cv::Mat dst;
122+
123+
TEST_CYCLE() bm->compute(imgLeft, imgRight, dst);
124+
125+
CPU_SANITY_CHECK(dst);
126+
}
127+
}
128+
90129
//////////////////////////////////////////////////////////////////////
91130
// StereoBeliefPropagation
92131

0 commit comments

Comments
 (0)