From 02f226a9816bad6cced4c43d40e889b54acd08d0 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Wed, 7 Mar 2012 13:14:50 +0000 Subject: [PATCH] fixed bug in gpu::pyrDown --- modules/gpu/src/cuda/pyr_down.cu | 4 ++-- modules/gpu/test/test_imgproc.cpp | 21 +++++---------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/modules/gpu/src/cuda/pyr_down.cu b/modules/gpu/src/cuda/pyr_down.cu index 34716c2..4c13388 100644 --- a/modules/gpu/src/cuda/pyr_down.cu +++ b/modules/gpu/src/cuda/pyr_down.cu @@ -75,7 +75,7 @@ namespace cv { namespace gpu { namespace device if (threadIdx.x < 2) { - const int left_x = x - 2 + threadIdx.x; + const int left_x = x - 2; sum = VecTraits::all(0); @@ -90,7 +90,7 @@ namespace cv { namespace gpu { namespace device if (threadIdx.x > 253) { - const int right_x = x + threadIdx.x + 2; + const int right_x = x + 2; sum = VecTraits::all(0); diff --git a/modules/gpu/test/test_imgproc.cpp b/modules/gpu/test/test_imgproc.cpp index 018a3e6..19552e7 100644 --- a/modules/gpu/test/test_imgproc.cpp +++ b/modules/gpu/test/test_imgproc.cpp @@ -3484,10 +3484,9 @@ PARAM_TEST_CASE(PyrDown, cv::gpu::DeviceInfo, MatType, UseRoi) cv::gpu::DeviceInfo devInfo; int type; bool useRoi; - - cv::Size size; + cv::Mat src; - + cv::Mat dst_gold; virtual void SetUp() @@ -3500,7 +3499,7 @@ PARAM_TEST_CASE(PyrDown, cv::gpu::DeviceInfo, MatType, UseRoi) cv::RNG& rng = TS::ptr()->get_rng(); - size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200)); + cv::Size size(rng.uniform(100, 200), rng.uniform(100, 200)); src = randomMat(rng, size, type, 0.0, 255.0, false); @@ -3518,12 +3517,7 @@ TEST_P(PyrDown, Accuracy) d_dst.download(dst); - ASSERT_EQ(dst_gold.cols, dst.cols); - ASSERT_EQ(dst_gold.rows, dst.rows); - ASSERT_EQ(dst_gold.type(), dst.type()); - - double err = crossCorr(dst_gold, dst) / (cv::norm(dst_gold, cv::NORM_L2) * cv::norm(dst, cv::NORM_L2)); - ASSERT_NEAR(err, 1., 1e-2); + EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0); } INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, Combine( @@ -3573,12 +3567,7 @@ TEST_P(PyrUp, Accuracy) d_dst.download(dst); - ASSERT_EQ(dst_gold.cols, dst.cols); - ASSERT_EQ(dst_gold.rows, dst.rows); - ASSERT_EQ(dst_gold.type(), dst.type()); - - double err = cvtest::crossCorr(dst_gold, dst) / (cv::norm(dst_gold, cv::NORM_L2) * cv::norm(dst, cv::NORM_L2)); - ASSERT_NEAR(err, 1., 1e-2); + EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0); } INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, Combine( -- 2.7.4