diff --git a/modules/core/test/test_umat.cpp b/modules/core/test/test_umat.cpp index a4f32db712..d25916c18a 100644 --- a/modules/core/test/test_umat.cpp +++ b/modules/core/test/test_umat.cpp @@ -1383,4 +1383,16 @@ TEST(UMat, testTempObjects_Mat_issue_8693) EXPECT_EQ(0, cvtest::norm(srcUMat.getMat(ACCESS_READ), srcMat, NORM_INF)); } +TEST(UMat, resize_Mat_issue_13577) +{ + // save the current state + bool useOCL = cv::ocl::useOpenCL(); + + cv::ocl::setUseOpenCL(false); + UMat foo(10, 10, CV_32FC1); + cv::resize(foo, foo, cv::Size(), .5, .5); + + cv::ocl::setUseOpenCL(useOCL); // restore state +} + } } // namespace opencv_test::ocl diff --git a/modules/imgproc/src/resize.cpp b/modules/imgproc/src/resize.cpp index ab0d3fe89f..b0283e5ca4 100644 --- a/modules/imgproc/src/resize.cpp +++ b/modules/imgproc/src/resize.cpp @@ -3738,6 +3738,11 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize, CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat() && _src.cols() > 10 && _src.rows() > 10, ocl_resize(_src, _dst, dsize, inv_scale_x, inv_scale_y, interpolation)) + // Fake reference to source. Resolves issue 13577 in case of src == dst. + UMat srcUMat; + if (_src.isUMat()) + srcUMat = _src.getUMat(); + Mat src = _src.getMat(); _dst.create(dsize, src.type()); Mat dst = _dst.getMat();