GPU resize became same as CPU implementation

pull/2/head
Marina Kolpakova 13 years ago
parent 60b73e7471
commit e6f7e4d83e
  1. 2
      modules/gpu/src/opencv2/gpu/device/filters.hpp
  2. 2
      modules/gpu/test/interpolation.hpp
  3. 24
      modules/gpu/test/test_resize.cpp

@ -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;

@ -54,7 +54,7 @@ template <typename T> 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<T>(src, cvRound(y), cvRound(x), c, border_type, borderVal);
return readVal<T>(src, int(y), int(x), c, border_type, borderVal);
}
};

@ -160,7 +160,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;
@ -182,6 +182,28 @@ PARAM_TEST_CASE(ResizeArea, cv::gpu::DeviceInfo, cv::Size, MatType, double, Inte
}
};
// 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<int>(src.cols * coeff), cv::saturate_cast<int>(src.rows * coeff)), type, useRoi);
cv::gpu::resize(loadMat(src, useRoi), dst, cv::Size(), coeff, coeff, interpolation);
cv::Mat dst_gold;
cv::resize(src, dst_gold, cv::Size(), coeff, coeff, interpolation);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-2 : 1.0);
}
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), Interpolation(cv::INTER_NEAREST)), //, Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)
WHOLE_SUBMAT));
///////////////////////////////////////////////////////////////////
// Test NPP

Loading…
Cancel
Save