From 0319120adc3c8301212e36c998650bdf0c6ce70e Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Wed, 17 Sep 2014 13:26:39 +0400 Subject: [PATCH] fix: ippiFilterMedianBorder sometimes crash when doing in-place filtering --- modules/imgproc/src/smooth.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index a53d8fe5d..0872c44c6 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -2163,7 +2163,7 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize ) ippDataType, CV_MAT_CN(type), &bufSize) >= 0) \ { \ Ipp8u * buffer = ippsMalloc_8u(bufSize); \ - IppStatus status = ippiFilterMedianBorder_##flavor(src0.ptr(), (int)src0.step, \ + IppStatus status = ippiFilterMedianBorder_##flavor(src.ptr(), (int)src.step, \ dst.ptr(), (int)dst.step, dstRoiSize, maskSize, \ ippBorderRepl, (ippType)0, buffer); \ ippsFree(buffer); \ @@ -2178,6 +2178,11 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize ) { Ipp32s bufSize; IppiSize dstRoiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize, ksize); + Mat src; + if( dst.data != src0.data ) + src = src0; + else + src0.copyTo(src); int type = src0.type(); if (type == CV_8UC1)