diff --git a/modules/gpu/src/filtering_npp.cpp b/modules/gpu/src/filtering_npp.cpp index 8ceb44e8bd..ae97244f2a 100644 --- a/modules/gpu/src/filtering_npp.cpp +++ b/modules/gpu/src/filtering_npp.cpp @@ -64,8 +64,19 @@ namespace CV_Assert(src.type() == CV_8U || src.type() == CV_8UC4); CV_Assert(kernel.type() == CV_8U && (kernel.cols & 1) != 0 && (kernel.rows & 1) != 0); + if (anchor.x == -1) + anchor.x = 0; + if (anchor.y == -1) + anchor.y = 0; + // in NPP for Cuda 3.1 only such anchor is supported. - CV_Assert(anchor.x == kernel.cols/2 && anchor.y == kernel.rows/2); + CV_Assert(anchor.x == 0 && anchor.y == 0); + + if (iterations == 0) + { + src.copyTo(dst); + return; + } const Mat& cont_krnl = (kernel.isContinuous() ? kernel : kernel.clone()).reshape(1, 1); GpuMat gpu_krnl(cont_krnl); @@ -84,8 +95,9 @@ namespace dst.create(src.size(), src.type()); - for(int i = 0; i < iterations; ++i) - nppSafeCall( func(src.ptr(), src.step, dst.ptr(), dst.step, sz, gpu_krnl.ptr(), mask_sz, anc) ); + nppSafeCall( func(src.ptr(), src.step, dst.ptr(), dst.step, sz, gpu_krnl.ptr(), mask_sz, anc) ); + for(int i = 1; i < iterations; ++i) + nppSafeCall( func(dst.ptr(), dst.step, dst.ptr(), dst.step, sz, gpu_krnl.ptr(), mask_sz, anc) ); } } diff --git a/tests/gpu/src/gputest_main.cpp b/tests/gpu/src/gputest_main.cpp index 463b2b7509..d4b9b3f5eb 100644 --- a/tests/gpu/src/gputest_main.cpp +++ b/tests/gpu/src/gputest_main.cpp @@ -47,9 +47,9 @@ const char* blacklist[] = { "GPU-NppImageSum", // crash "GPU-MatOperatorAsyncCall", // crash - "GPU-NppErode", // npp func returns error code (CUDA_KERNEL_LAUNCH_ERROR or TEXTURE_BIND_ERROR) - "GPU-NppDilate", // npp func returns error code (CUDA_KERNEL_LAUNCH_ERROR or TEXTURE_BIND_ERROR) - "GPU-NppMorphologyEx", // npp func returns error code (CUDA_KERNEL_LAUNCH_ERROR or TEXTURE_BIND_ERROR) + //"GPU-NppErode", // npp func returns error code (CUDA_KERNEL_LAUNCH_ERROR or TEXTURE_BIND_ERROR) + //"GPU-NppDilate", // npp func returns error code (CUDA_KERNEL_LAUNCH_ERROR or TEXTURE_BIND_ERROR) + //"GPU-NppMorphologyEx", // npp func returns error code (CUDA_KERNEL_LAUNCH_ERROR or TEXTURE_BIND_ERROR) //"GPU-NppImageDivide", // different round mode //"GPU-NppImageMeanStdDev", // different precision //"GPU-NppImageMinNax", // npp bug diff --git a/tests/gpu/src/morf_filters.cpp b/tests/gpu/src/morf_filters.cpp index 1f5c5a7144..f90a33fa08 100644 --- a/tests/gpu/src/morf_filters.cpp +++ b/tests/gpu/src/morf_filters.cpp @@ -134,7 +134,7 @@ protected: virtual int test(const Mat& img) { GpuMat kernel(Mat::ones(3, 3, CV_8U)); - Point anchor(1,1); + Point anchor(-1, -1); int iters = 3; cv::Mat cpuRes; @@ -158,7 +158,7 @@ protected: virtual int test(const Mat& img) { GpuMat kernel(Mat::ones(3, 3, CV_8U)); - Point anchor(1,1); + Point anchor(-1, -1); int iters = 3; cv::Mat cpuRes; @@ -186,7 +186,7 @@ protected: int num = sizeof(ops)/sizeof(ops[0]); GpuMat kernel(Mat::ones(3, 3, CV_8U)); - Point anchor(1,1); + Point anchor(-1, -1); int iters = 3; for(int i = 0; i < num; ++i)