From cdbda45125ac1b5b5afb724c76469ed7df8f2637 Mon Sep 17 00:00:00 2001 From: Marina Kolpakova Date: Tue, 3 Jul 2012 16:16:24 +0000 Subject: [PATCH] merged GPU resize became same as CPU implementation --- modules/gpu/src/opencv2/gpu/device/filters.hpp | 2 +- modules/gpu/test/interpolation.hpp | 2 +- modules/gpu/test/test_resize.cpp | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/gpu/src/opencv2/gpu/device/filters.hpp b/modules/gpu/src/opencv2/gpu/device/filters.hpp index c33a088cd892..73e3788ef3ad 100644 --- a/modules/gpu/src/opencv2/gpu/device/filters.hpp +++ b/modules/gpu/src/opencv2/gpu/device/filters.hpp @@ -64,7 +64,7 @@ namespace cv { namespace gpu { namespace device __device__ __forceinline__ elem_type operator ()(float y, float x) const { - return src(__float2int_rn(y), __float2int_rn(x)); + return src(__float2int_rz(y), __float2int_rz(x)); } const Ptr2D src; diff --git a/modules/gpu/test/interpolation.hpp b/modules/gpu/test/interpolation.hpp index e38dc4c9690b..858f6bee929b 100644 --- a/modules/gpu/test/interpolation.hpp +++ b/modules/gpu/test/interpolation.hpp @@ -54,7 +54,7 @@ template struct NearestInterpolator { static T getValue(const cv::Mat& src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar()) { - return readVal(src, cvRound(y), cvRound(x), c, border_type, borderVal); + return readVal(src, int(y), int(x), c, border_type, borderVal); } }; diff --git a/modules/gpu/test/test_resize.cpp b/modules/gpu/test/test_resize.cpp index 22d7ba3fd78d..19dd1c8c372a 100644 --- a/modules/gpu/test/test_resize.cpp +++ b/modules/gpu/test/test_resize.cpp @@ -159,7 +159,7 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Resize, testing::Combine( ///////////////// -PARAM_TEST_CASE(ResizeArea, cv::gpu::DeviceInfo, cv::Size, MatType, double, Interpolation, UseRoi) +PARAM_TEST_CASE(ResizeSameAsHost, cv::gpu::DeviceInfo, cv::Size, MatType, double, Interpolation, UseRoi) { cv::gpu::DeviceInfo devInfo; cv::Size size; @@ -181,25 +181,26 @@ PARAM_TEST_CASE(ResizeArea, cv::gpu::DeviceInfo, cv::Size, MatType, double, Inte } }; -TEST_P(ResizeArea, Accuracy) +// downscaling only: used for classifiers +TEST_P(ResizeSameAsHost, Accuracy) { cv::Mat src = randomMat(size, type); cv::gpu::GpuMat dst = createMat(cv::Size(cv::saturate_cast(src.cols * coeff), cv::saturate_cast(src.rows * coeff)), type, useRoi); cv::gpu::resize(loadMat(src, useRoi), dst, cv::Size(), coeff, coeff, interpolation); - cv::Mat dst_cpu; - cv::resize(src, dst_cpu, cv::Size(), coeff, coeff, interpolation); + cv::Mat dst_gold; + cv::resize(src, dst_gold, cv::Size(), coeff, coeff, interpolation); - EXPECT_MAT_NEAR(dst_cpu, dst, src.depth() == CV_32F ? 1e-2 : 1.0); + EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-2 : 1.0); } -INSTANTIATE_TEST_CASE_P(GPU_ImgProc, ResizeArea, testing::Combine( +INSTANTIATE_TEST_CASE_P(GPU_ImgProc, ResizeSameAsHost, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, testing::Values(MatType(CV_8UC3), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)), testing::Values(0.3, 0.5), - testing::Values(Interpolation(cv::INTER_AREA)), + testing::Values(Interpolation(cv::INTER_AREA), Interpolation(cv::INTER_NEAREST)), //, Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC) WHOLE_SUBMAT)); ///////////////////////////////////////////////////////////////////