Commit 1d58e1a1 authored by Vladislav Vinogradov's avatar Vladislav Vinogradov Committed by Alexander Smorkalov

fix potential out-of-border access in gpu StereoBeliefPropagation

parent d122510c
...@@ -213,8 +213,8 @@ namespace ...@@ -213,8 +213,8 @@ namespace
if (rthis.levels > 1) if (rthis.levels > 1)
{ {
int less_rows = (rows + 1) / 2; int less_rows = rows / 2;
int less_cols = (cols + 1) / 2; int less_cols = cols / 2;
u2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type); u2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type);
d2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type); d2.create(less_rows * rthis.ndisp, less_cols, rthis.msg_type);
...@@ -283,8 +283,8 @@ namespace ...@@ -283,8 +283,8 @@ namespace
for (int i = 1; i < rthis.levels; ++i) for (int i = 1; i < rthis.levels; ++i)
{ {
cols_all[i] = (cols_all[i-1] + 1) / 2; cols_all[i] = cols_all[i-1] / 2;
rows_all[i] = (rows_all[i-1] + 1) / 2; rows_all[i] = rows_all[i-1] / 2;
datas[i].create(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type); datas[i].create(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type);
......
...@@ -114,7 +114,9 @@ GPU_TEST_P(StereoBeliefPropagation, Regression) ...@@ -114,7 +114,9 @@ GPU_TEST_P(StereoBeliefPropagation, Regression)
cv::Mat h_disp(disp); cv::Mat h_disp(disp);
h_disp.convertTo(h_disp, disp_gold.depth()); h_disp.convertTo(h_disp, disp_gold.depth());
EXPECT_MAT_NEAR(disp_gold, h_disp, 0.0); cv::Rect roi(0, 0, disp_gold.cols - 20, disp_gold.rows - 20);
EXPECT_MAT_NEAR(disp_gold(roi), h_disp(roi), 0.0);
} }
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoBeliefPropagation, ALL_DEVICES); INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoBeliefPropagation, ALL_DEVICES);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment