From 3e173b701e90aa0cc0878f808d642b7a240c0478 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sat, 12 Apr 2014 15:40:26 +0400 Subject: [PATCH 01/14] cv::Laplacian --- modules/imgproc/src/deriv.cpp | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index c6885d4629..b11bce4b68 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -483,6 +483,67 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int dtype = CV_MAKETYPE(ddepth, cn); _dst.create( _src.size(), dtype ); +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if ((ksize == 3 || ksize == 5) && ((borderType & BORDER_ISOLATED) == 0 || !_src.isSubmatrix()) && + ((stype == CV_8UC1 && ddepth == CV_16S) || (ddepth == CV_32F && stype == CV_32FC1))) + { + int iscale = saturate_cast(scale), idelta = saturate_cast(delta); + bool floatScale = std::fabs(scale - iscale) > DBL_EPSILON, needScale = iscale != 1; + bool floatDelta = std::fabs(delta - idelta) > DBL_EPSILON, needDelta = delta != 0; + int borderTypeNI = borderType & ~BORDER_ISOLATED; + Mat src = _src.getMat(), dst = _dst.getMat(); + + if (src.data != dst.data) + { + Ipp32s bufsize; + IppStatus status = (IppStatus)-1; + IppiSize roisize = { src.cols, src.rows }; + IppiMaskSize masksize = ksize == 3 ? ippMskSize3x3 : ippMskSize5x5; + IppiBorderType borderTypeIpp = + borderTypeNI == BORDER_CONSTANT ? ippBorderConst : + borderTypeNI == BORDER_WRAP ? ippBorderWrap : + borderTypeNI == BORDER_REPLICATE ? ippBorderRepl : + borderTypeNI == BORDER_REFLECT_101 ? ippBorderMirror : + borderTypeNI == BORDER_REFLECT ? ippBorderMirrorR : (IppiBorderType)-1; + +#define IPP_FILTER_LAPLACIAN(ippsrctype, ippdsttype, ippfavor) \ +do \ +{ \ + if (borderTypeIpp >= 0 && ippiFilterLaplacianGetBufferSize_##ippfavor##_C1R(roisize, masksize, &bufsize) >= 0) \ + { \ + Ipp8u * buffer = ippsMalloc_8u(bufsize); \ + status = ippiFilterLaplacianBorder_##ippfavor##_C1R((const ippsrctype *)src.data, (int)src.step, (ippdsttype *)dst.data, \ + (int)dst.step, roisize, masksize, borderTypeIpp, 0, buffer); \ + ippsFree(buffer); \ + } \ +} while ((void)0, 0) + + if (sdepth == CV_8U && ddepth == CV_16S && !floatScale && !floatDelta) + { + IPP_FILTER_LAPLACIAN(Ipp8u, Ipp16s, 8u16s); + + if (needScale) + status = ippiMulC_16s_C1IRSfs((Ipp16s)iscale, (Ipp16s *)dst.data, (int)dst.step, roisize, 0); + if (needDelta) + status = ippiAddC_16s_C1IRSfs((Ipp16s)idelta, (Ipp16s *)dst.data, (int)dst.step, roisize, 0); + } + else if (sdepth == CV_32F && ddepth == CV_32F) + { + IPP_FILTER_LAPLACIAN(Ipp32f, Ipp32f, 32f); + + if (needScale) + status = ippiMulC_32f_C1IR((Ipp32f)scale, (Ipp32f *)dst.data, (int)dst.step, roisize); + if (needDelta) + status = ippiAddC_32f_C1IR((Ipp32f)delta, (Ipp32f *)dst.data, (int)dst.step, roisize); + } + + if (status >= 0) + return; + } + } +#undef IPP_FILTER_LAPLACIAN +#endif + #ifdef HAVE_TEGRA_OPTIMIZATION if (scale == 1.0 && delta == 0) { From d453a598f86be055745024c54f1d2d0b31cff62e Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 13 Apr 2014 15:59:32 +0400 Subject: [PATCH 02/14] cv::min/cv::max CV_64F --- modules/core/src/arithm.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 966db7106b..d9e1eadf5e 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -705,6 +705,23 @@ static void max64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, Size sz, void* ) { +#if ARITHM_USE_IPP == 1 + double* s1 = (double*)src1; + double* s2 = (double*)src2; + double* d = dst; + fixSteps(sz, sizeof(dst[0]), step1, step2, step); + int i = 0; + for(; i < sz.height; i++) + { + if (0 > ippsMaxEvery_64f(s1, s2, d, sz.width)) + break; + s1 = (double*)((uchar*)s1 + step1); + s2 = (double*)((uchar*)s2 + step2); + d = (double*)((uchar*)d + step); + } + if (i == sz.height) + return; +#endif vBinOp64, IF_SIMD(VMax)>(src1, step1, src2, step2, dst, step, sz); } @@ -808,6 +825,23 @@ static void min64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, Size sz, void* ) { +#if ARITHM_USE_IPP == 1 + double* s1 = (double*)src1; + double* s2 = (double*)src2; + double* d = dst; + fixSteps(sz, sizeof(dst[0]), step1, step2, step); + int i = 0; + for(; i < sz.height; i++) + { + if (0 > ippsMinEvery_64f(s1, s2, d, sz.width)) + break; + s1 = (double*)((uchar*)s1 + step1); + s2 = (double*)((uchar*)s2 + step2); + d = (double*)((uchar*)d + step); + } + if (i == sz.height) + return; +#endif vBinOp64, IF_SIMD(VMin)>(src1, step1, src2, step2, dst, step, sz); } From 8da0e2b7072a8a097d650492429024239aacb9f2 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 13 Apr 2014 16:05:54 +0400 Subject: [PATCH 03/14] cv::accumulate --- modules/imgproc/src/accum.cpp | 56 +++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/modules/imgproc/src/accum.cpp b/modules/imgproc/src/accum.cpp index 0e99d74839..193c18cee7 100644 --- a/modules/imgproc/src/accum.cpp +++ b/modules/imgproc/src/accum.cpp @@ -431,6 +431,56 @@ void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask ) Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && (mask.empty() || mask.isContinuous()))) + { + typedef IppStatus (CV_STDCALL * ippiAdd)(const void * pSrc, int srcStep, Ipp32f * pSrcDst, int srcdstStep, IppiSize roiSize); + typedef IppStatus (CV_STDCALL * ippiAddMask)(const void * pSrc, int srcStep, const Ipp8u * pMask, int maskStep, Ipp32f * pSrcDst, + int srcDstStep, IppiSize roiSize); + ippiAdd ippFunc = 0; + ippiAddMask ippFuncMask = 0; + + if (mask.empty()) + { + ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAdd)ippiAdd_8u32f_C1IR : + sdepth == CV_16U && ddepth == CV_32F ? (ippiAdd)ippiAdd_16u32f_C1IR : + sdepth == CV_32F && ddepth == CV_32F ? (ippiAdd)ippiAdd_32f_C1IR : 0; + } + else if (scn == 1) + { + ippFuncMask = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddMask)ippiAdd_8u32f_C1IMR : + sdepth == CV_16U && ddepth == CV_32F ? (ippiAddMask)ippiAdd_16u32f_C1IMR : + sdepth == CV_32F && ddepth == CV_32F ? (ippiAddMask)ippiAdd_32f_C1IMR : 0; + } + + if (ippFunc || ippFuncMask) + { + IppStatus status = ippStsNoErr; + + Size size = src.size(); + int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step; + if (src.isContinuous() && dst.isContinuous() && mask.isContinuous()) + { + srcstep = static_cast(src.total() * src.elemSize()); + dststep = static_cast(dst.total() * dst.elemSize()); + maskstep = static_cast(mask.total() * mask.elemSize()); + size.width = static_cast(src.total()); + size.height = 1; + } + size.width *= scn; + + if (mask.empty()) + status = ippFunc(src.data, srcstep, (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height)); + else + status = ippFuncMask(src.data, srcstep, (const Ipp8u *)mask.data, maskstep, + (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height)); + + if (status >= 0) + return; + } + } +#endif + int fidx = getAccTabIdx(sdepth, ddepth); AccFunc func = fidx >= 0 ? accTab[fidx] : 0; CV_Assert( func != 0 ); @@ -498,7 +548,7 @@ void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _m if (mask.empty()) status = ippFunc(src.data, srcstep, (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height)); else - status = ippFuncMask(src.data, srcstep, (Ipp8u *)mask.data, maskstep, + status = ippFuncMask(src.data, srcstep, (const Ipp8u *)mask.data, maskstep, (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height)); if (status >= 0) @@ -580,7 +630,7 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2, status = ippFunc(src1.data, src1step, src2.data, src2step, (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height)); else - status = ippFuncMask(src1.data, src1step, src2.data, src2step, (Ipp8u *)mask.data, maskstep, + status = ippFuncMask(src1.data, src1step, src2.data, src2step, (const Ipp8u *)mask.data, maskstep, (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height)); if (status >= 0) @@ -660,7 +710,7 @@ void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst, if (mask.empty()) status = ippFunc(src.data, srcstep, (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height), (Ipp32f)alpha); else - status = ippFuncMask(src.data, srcstep, (Ipp8u *)mask.data, maskstep, + status = ippFuncMask(src.data, srcstep, (const Ipp8u *)mask.data, maskstep, (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height), (Ipp32f)alpha); if (status >= 0) From 5ca3d855a2639d2ca8d39e6fb804f1c10803d3c8 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 13 Apr 2014 16:14:04 +0400 Subject: [PATCH 04/14] cv::transpose inplace --- modules/core/src/matrix.cpp | 67 +++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 5b39a21c62..9b4d859e9f 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -3019,24 +3019,50 @@ void cv::transpose( InputArray _src, OutputArray _dst ) return; } -#if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY typedef IppStatus (CV_STDCALL * ippiTranspose)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize); - ippiTranspose ippFunc = - type == CV_8UC1 ? (ippiTranspose)ippiTranspose_8u_C1R : - type == CV_8UC3 ? (ippiTranspose)ippiTranspose_8u_C3R : - type == CV_8UC4 ? (ippiTranspose)ippiTranspose_8u_C4R : - type == CV_16UC1 ? (ippiTranspose)ippiTranspose_16u_C1R : - type == CV_16UC3 ? (ippiTranspose)ippiTranspose_16u_C3R : - type == CV_16UC4 ? (ippiTranspose)ippiTranspose_16u_C4R : - type == CV_16SC1 ? (ippiTranspose)ippiTranspose_16s_C1R : - type == CV_16SC3 ? (ippiTranspose)ippiTranspose_16s_C3R : - type == CV_16SC4 ? (ippiTranspose)ippiTranspose_16s_C4R : - type == CV_32SC1 ? (ippiTranspose)ippiTranspose_32s_C1R : - type == CV_32SC3 ? (ippiTranspose)ippiTranspose_32s_C3R : - type == CV_32SC4 ? (ippiTranspose)ippiTranspose_32s_C4R : - type == CV_32FC1 ? (ippiTranspose)ippiTranspose_32f_C1R : - type == CV_32FC3 ? (ippiTranspose)ippiTranspose_32f_C3R : - type == CV_32FC4 ? (ippiTranspose)ippiTranspose_32f_C4R : 0; + typedef IppStatus (CV_STDCALL * ippiTransposeI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize); + ippiTranspose ippFunc = 0; + ippiTransposeI ippFuncI = 0; + + if (dst.data == src.data && dst.cols == dst.rows) + { + ippFuncI = + type == CV_8UC1 ? (ippiTransposeI)ippiTranspose_8u_C1IR : + type == CV_8UC3 ? (ippiTransposeI)ippiTranspose_8u_C3IR : + type == CV_8UC4 ? (ippiTransposeI)ippiTranspose_8u_C4IR : + type == CV_16UC1 ? (ippiTransposeI)ippiTranspose_16u_C1IR : + type == CV_16UC3 ? (ippiTransposeI)ippiTranspose_16u_C3IR : + type == CV_16UC4 ? (ippiTransposeI)ippiTranspose_16u_C4IR : + type == CV_16SC1 ? (ippiTransposeI)ippiTranspose_16s_C1IR : + type == CV_16SC3 ? (ippiTransposeI)ippiTranspose_16s_C3IR : + type == CV_16SC4 ? (ippiTransposeI)ippiTranspose_16s_C4IR : + type == CV_32SC1 ? (ippiTransposeI)ippiTranspose_32s_C1IR : + type == CV_32SC3 ? (ippiTransposeI)ippiTranspose_32s_C3IR : + type == CV_32SC4 ? (ippiTransposeI)ippiTranspose_32s_C4IR : + type == CV_32FC1 ? (ippiTransposeI)ippiTranspose_32f_C1IR : + type == CV_32FC3 ? (ippiTransposeI)ippiTranspose_32f_C3IR : + type == CV_32FC4 ? (ippiTransposeI)ippiTranspose_32f_C4IR : 0; + } + else + { + ippFunc = + type == CV_8UC1 ? (ippiTranspose)ippiTranspose_8u_C1R : + type == CV_8UC3 ? (ippiTranspose)ippiTranspose_8u_C3R : + type == CV_8UC4 ? (ippiTranspose)ippiTranspose_8u_C4R : + type == CV_16UC1 ? (ippiTranspose)ippiTranspose_16u_C1R : + type == CV_16UC3 ? (ippiTranspose)ippiTranspose_16u_C3R : + type == CV_16UC4 ? (ippiTranspose)ippiTranspose_16u_C4R : + type == CV_16SC1 ? (ippiTranspose)ippiTranspose_16s_C1R : + type == CV_16SC3 ? (ippiTranspose)ippiTranspose_16s_C3R : + type == CV_16SC4 ? (ippiTranspose)ippiTranspose_16s_C4R : + type == CV_32SC1 ? (ippiTranspose)ippiTranspose_32s_C1R : + type == CV_32SC3 ? (ippiTranspose)ippiTranspose_32s_C3R : + type == CV_32SC4 ? (ippiTranspose)ippiTranspose_32s_C4R : + type == CV_32FC1 ? (ippiTranspose)ippiTranspose_32f_C1R : + type == CV_32FC3 ? (ippiTranspose)ippiTranspose_32f_C3R : + type == CV_32FC4 ? (ippiTranspose)ippiTranspose_32f_C4R : 0; + } IppiSize roiSize = { src.cols, src.rows }; if (ippFunc != 0) @@ -3045,7 +3071,12 @@ void cv::transpose( InputArray _src, OutputArray _dst ) return; setIppErrorStatus(); } -#endif + else if (ippFuncI != 0) + { + if (ippFuncI(dst.data, (int)dst.step, roiSize) >= 0) + return; + setIppErrorStatus(); + } if( dst.data == src.data ) { From 8d24a83c9c84bb780d4d16fabe8b9375b66266a2 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 13 Apr 2014 16:19:34 +0400 Subject: [PATCH 05/14] cv::flip inplace --- modules/core/src/copy.cpp | 71 ++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index d21a390345..f6d60f7339 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -548,35 +548,66 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode ) Mat dst = _dst.getMat(); size_t esz = CV_ELEM_SIZE(type); -#if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY typedef IppStatus (CV_STDCALL * ippiMirror)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize, IppiAxis flip); - ippiMirror ippFunc = - type == CV_8UC1 ? (ippiMirror)ippiMirror_8u_C1R : - type == CV_8UC3 ? (ippiMirror)ippiMirror_8u_C3R : - type == CV_8UC4 ? (ippiMirror)ippiMirror_8u_C4R : - type == CV_16UC1 ? (ippiMirror)ippiMirror_16u_C1R : - type == CV_16UC3 ? (ippiMirror)ippiMirror_16u_C3R : - type == CV_16UC4 ? (ippiMirror)ippiMirror_16u_C4R : - type == CV_16SC1 ? (ippiMirror)ippiMirror_16s_C1R : - type == CV_16SC3 ? (ippiMirror)ippiMirror_16s_C3R : - type == CV_16SC4 ? (ippiMirror)ippiMirror_16s_C4R : - type == CV_32SC1 ? (ippiMirror)ippiMirror_32s_C1R : - type == CV_32SC3 ? (ippiMirror)ippiMirror_32s_C3R : - type == CV_32SC4 ? (ippiMirror)ippiMirror_32s_C4R : - type == CV_32FC1 ? (ippiMirror)ippiMirror_32f_C1R : - type == CV_32FC3 ? (ippiMirror)ippiMirror_32f_C3R : - type == CV_32FC4 ? (ippiMirror)ippiMirror_32f_C4R : 0; + typedef IppStatus (CV_STDCALL * ippiMirrorI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize, IppiAxis flip); + ippiMirror ippFunc = 0; + ippiMirrorI ippFuncI = 0; + + if (src.data == dst.data) + { + ippFuncI = + type == CV_8UC1 ? (ippiMirrorI)ippiMirror_8u_C1IR : + type == CV_8UC3 ? (ippiMirrorI)ippiMirror_8u_C3IR : + type == CV_8UC4 ? (ippiMirrorI)ippiMirror_8u_C4IR : + type == CV_16UC1 ? (ippiMirrorI)ippiMirror_16u_C1IR : + type == CV_16UC3 ? (ippiMirrorI)ippiMirror_16u_C3IR : + type == CV_16UC4 ? (ippiMirrorI)ippiMirror_16u_C4IR : + type == CV_16SC1 ? (ippiMirrorI)ippiMirror_16s_C1IR : + type == CV_16SC3 ? (ippiMirrorI)ippiMirror_16s_C3IR : + type == CV_16SC4 ? (ippiMirrorI)ippiMirror_16s_C4IR : + type == CV_32SC1 ? (ippiMirrorI)ippiMirror_32s_C1IR : + type == CV_32SC3 ? (ippiMirrorI)ippiMirror_32s_C3IR : + type == CV_32SC4 ? (ippiMirrorI)ippiMirror_32s_C4IR : + type == CV_32FC1 ? (ippiMirrorI)ippiMirror_32f_C1IR : + type == CV_32FC3 ? (ippiMirrorI)ippiMirror_32f_C3IR : + type == CV_32FC4 ? (ippiMirrorI)ippiMirror_32f_C4IR : 0; + } + else + { + ippFunc = + type == CV_8UC1 ? (ippiMirror)ippiMirror_8u_C1R : + type == CV_8UC3 ? (ippiMirror)ippiMirror_8u_C3R : + type == CV_8UC4 ? (ippiMirror)ippiMirror_8u_C4R : + type == CV_16UC1 ? (ippiMirror)ippiMirror_16u_C1R : + type == CV_16UC3 ? (ippiMirror)ippiMirror_16u_C3R : + type == CV_16UC4 ? (ippiMirror)ippiMirror_16u_C4R : + type == CV_16SC1 ? (ippiMirror)ippiMirror_16s_C1R : + type == CV_16SC3 ? (ippiMirror)ippiMirror_16s_C3R : + type == CV_16SC4 ? (ippiMirror)ippiMirror_16s_C4R : + type == CV_32SC1 ? (ippiMirror)ippiMirror_32s_C1R : + type == CV_32SC3 ? (ippiMirror)ippiMirror_32s_C3R : + type == CV_32SC4 ? (ippiMirror)ippiMirror_32s_C4R : + type == CV_32FC1 ? (ippiMirror)ippiMirror_32f_C1R : + type == CV_32FC3 ? (ippiMirror)ippiMirror_32f_C3R : + type == CV_32FC4 ? (ippiMirror)ippiMirror_32f_C4R : 0; + } IppiAxis axis = flip_mode == 0 ? ippAxsHorizontal : flip_mode > 0 ? ippAxsVertical : ippAxsBoth; + IppiSize roisize = { dst.cols, dst.rows }; if (ippFunc != 0) { - IppStatus status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, ippiSize(src.cols, src.rows), axis); - if (status >= 0) + if (ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, ippiSize(src.cols, src.rows), axis) >= 0) + return; + setIppErrorStatus(); + } + else if (ippFuncI != 0) + { + if (ippFuncI(dst.data, (int)dst.step, roisize, axis) >= 0) return; setIppErrorStatus(); } -#endif if( flip_mode <= 0 ) flipVert( src.data, src.step, dst.data, dst.step, src.size(), esz ); From f7ec4a5c478633e1e55c76f13c2c4b1eebb61479 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 13 Apr 2014 16:44:37 +0400 Subject: [PATCH 06/14] Mat::copyTo with mask --- modules/core/src/copy.cpp | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index f6d60f7339..34fe97f8f8 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -81,6 +81,11 @@ copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mstep, ucha template<> void copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mstep, uchar* _dst, size_t dstep, Size size) { +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (ippiCopy_8u_C1MR(_src, (int)sstep, _dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0) + return; +#endif + for( ; size.height--; mask += mstep, _src += sstep, _dst += dstep ) { const uchar* src = (const uchar*)_src; @@ -111,6 +116,11 @@ copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mste template<> void copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mstep, uchar* _dst, size_t dstep, Size size) { +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (ippiCopy_16u_C1MR((const Ipp16u *)_src, (int)sstep, (Ipp16u *)_dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0) + return; +#endif + for( ; size.height--; mask += mstep, _src += sstep, _dst += dstep ) { const ushort* src = (const ushort*)_src; @@ -165,15 +175,33 @@ static void copyMask##suffix(const uchar* src, size_t sstep, const uchar* mask, copyMask_(src, sstep, mask, mstep, dst, dstep, size); \ } +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY +#define DEF_COPY_MASK_F(suffix, type, ippfavor, ipptype) \ +static void copyMask##suffix(const uchar* src, size_t sstep, const uchar* mask, size_t mstep, \ + uchar* dst, size_t dstep, Size size, void*) \ +{ \ + if (ippiCopy_##ippfavor((const ipptype *)src, (int)sstep, (ipptype *)dst, (int)dstep, ippiSize(size), (const Ipp8u *)mask, (int)mstep) >= 0) \ + return; \ + copyMask_(src, sstep, mask, mstep, dst, dstep, size); \ +} +#else +#define DEF_COPY_MASK_F(suffix, type, ippfavor, ipptype) \ +static void copyMask##suffix(const uchar* src, size_t sstep, const uchar* mask, size_t mstep, \ + uchar* dst, size_t dstep, Size size, void*) \ +{ \ + copyMask_(src, sstep, mask, mstep, dst, dstep, size); \ +} +#endif + DEF_COPY_MASK(8u, uchar) DEF_COPY_MASK(16u, ushort) -DEF_COPY_MASK(8uC3, Vec3b) -DEF_COPY_MASK(32s, int) -DEF_COPY_MASK(16uC3, Vec3s) +DEF_COPY_MASK_F(8uC3, Vec3b, 8u_C3MR, Ipp8u) +DEF_COPY_MASK_F(32s, int, 32s_C1MR, Ipp32s) +DEF_COPY_MASK_F(16uC3, Vec3s, 16u_C3MR, Ipp16u) DEF_COPY_MASK(32sC2, Vec2i) -DEF_COPY_MASK(32sC3, Vec3i) -DEF_COPY_MASK(32sC4, Vec4i) +DEF_COPY_MASK_F(32sC3, Vec3i, 32s_C3MR, Ipp32s) +DEF_COPY_MASK_F(32sC4, Vec4i, 32s_C4MR, Ipp32s) DEF_COPY_MASK(32sC6, Vec6i) DEF_COPY_MASK(32sC8, Vec8i) From 3bd8211a72e95bc6076eeb461ec10772e2893a45 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 13 Apr 2014 16:50:38 +0400 Subject: [PATCH 07/14] Mat::copyTo --- modules/core/src/copy.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 34fe97f8f8..fc0454b1ca 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -278,6 +278,11 @@ void Mat::copyTo( OutputArray _dst ) const Size sz = getContinuousSize(*this, dst); size_t len = sz.width*elemSize(); +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (ippiCopy_8u_C1R(sptr, (int)step, dptr, (int)dst.step, ippiSize((int)len, sz.height)) >= 0) + return; +#endif + for( ; sz.height--; sptr += step, dptr += dst.step ) memcpy( dptr, sptr, len ); } From 0b678c245140c789233686f95aa57bddced8ca0a Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 13 Apr 2014 17:00:00 +0400 Subject: [PATCH 08/14] Mat::setTo(Scalar::all(0)) --- modules/core/src/copy.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index fc0454b1ca..3cf1edaa8c 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -356,6 +356,25 @@ Mat& Mat::operator = (const Scalar& s) if( is[0] == 0 && is[1] == 0 && is[2] == 0 && is[3] == 0 ) { +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (dims <= 2 || isContinuous()) + { + IppiSize roisize = { cols, rows }; + if (isContinuous()) + { + roisize.width = (int)total(); + roisize.height = 1; + + if (ippsZero_8u(data, roisize.width * elemSize()) >= 0) + return *this; + } + roisize.width *= elemSize(); + + if (ippiSet_8u_C1R(0, data, (int)step, roisize) >= 0) + return *this; + } +#endif + for( size_t i = 0; i < it.nplanes; i++, ++it ) memset( dptr, 0, elsize ); } From 8603c58f37e95ed2bba20e8176a0c6f166f11883 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 13 Apr 2014 18:15:41 +0400 Subject: [PATCH 09/14] Mat::setTo(with mask) --- modules/core/src/copy.cpp | 72 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 3cf1edaa8c..40e5b51b93 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -411,7 +411,77 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask) Mat value = _value.getMat(), mask = _mask.getMat(); CV_Assert( checkScalar(value, type(), _value.kind(), _InputArray::MAT )); - CV_Assert( mask.empty() || mask.type() == CV_8U ); + CV_Assert( mask.empty() || (mask.type() == CV_8U && size == mask.size) ); + +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous()))) + { + uchar buf[32]; + convertAndUnrollScalar( value, type(), buf, 1 ); + + int cn = channels(), depth0 = depth(); + IppStatus status = (IppStatus)-1; + IppiSize roisize = { cols, rows }; + int mstep = (int)mask.step, dstep = (int)step; + + if (isContinuous() && mask.isContinuous()) + { + roisize.width = (int)total(); + roisize.height = 1; + } + + if (cn == 1) + { + if (depth0 == CV_8U) + status = ippiSet_8u_C1MR(*(Ipp8u *)buf, (Ipp8u *)data, dstep, roisize, mask.data, mstep); + else if (depth0 == CV_16U) + status = ippiSet_16u_C1MR(*(Ipp16u *)buf, (Ipp16u *)data, dstep, roisize, mask.data, mstep); + else if (depth0 == CV_16S) + status = ippiSet_16s_C1MR(*(Ipp16s *)buf, (Ipp16s *)data, dstep, roisize, mask.data, mstep); + else if (depth0 == CV_32S) + status = ippiSet_32s_C1MR(*(Ipp32s *)buf, (Ipp32s *)data, dstep, roisize, mask.data, mstep); + else if (depth0 == CV_32F) + status = ippiSet_32f_C1MR(*(Ipp32f *)buf, (Ipp32f *)data, dstep, roisize, mask.data, mstep); + } + else if (cn == 3 || cn == 3) + { +#define IPP_SET(ippfavor, ippcn) \ + do \ + { \ + typedef Ipp##ippfavor ipptype; \ + ipptype ippvalue[4] = { ((ipptype *)buf)[0], ((ipptype *)buf)[1], ((ipptype *)buf)[2], ((ipptype *)buf)[4] }; \ + status = ippiSet_##ippfavor##_C##ippcn##MR(ippvalue, (ipptype *)data, dstep, roisize, mask.data, mstep); \ + } while ((void)0, 0) + +#define IPP_SET_CN(ippcn) \ + do \ + { \ + if (cn == ippcn) \ + { \ + if (depth0 == CV_8U) \ + IPP_SET(8u, ippcn); \ + else if (depth0 == CV_16U) \ + IPP_SET(16u, ippcn); \ + else if (depth0 == CV_16S) \ + IPP_SET(16s, ippcn); \ + else if (depth0 == CV_32S) \ + IPP_SET(32s, ippcn); \ + else if (depth0 == CV_32F) \ + IPP_SET(32f, ippcn); \ + } \ + } while ((void)0, 0) + + IPP_SET_CN(3); + IPP_SET_CN(4); + +#undef IPP_SET_CN +#undef IPP_SET + } + + if (status >= 0) + return *this; + } +#endif size_t esz = elemSize(); BinaryFunc copymask = getCopyMaskFunc(esz); From 04abffeb165d1b0f6461b89e99123e6c6b7a9024 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Sun, 13 Apr 2014 19:49:15 +0400 Subject: [PATCH 10/14] cv::cornerHarris --- modules/imgproc/src/corner.cpp | 58 +++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index cc35ff2de5..621f7f80f0 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -251,10 +251,10 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size, int depth = src.depth(); double scale = (double)(1 << ((aperture_size > 0 ? aperture_size : 3) - 1)) * block_size; if( aperture_size < 0 ) - scale *= 2.; + scale *= 2.0; if( depth == CV_8U ) - scale *= 255.; - scale = 1./scale; + scale *= 255.0; + scale = 1.0/scale; CV_Assert( src.type() == CV_8UC1 || src.type() == CV_32FC1 ); @@ -381,15 +381,15 @@ static bool ocl_cornerMinEigenValVecs(InputArray _src, OutputArray _dst, int blo const char * const cornerType[] = { "CORNER_MINEIGENVAL", "CORNER_HARRIS", 0 }; - float scale = (float)(1 << ((aperture_size > 0 ? aperture_size : 3) - 1)) * block_size; + double scale = (double)(1 << ((aperture_size > 0 ? aperture_size : 3) - 1)) * block_size; if (aperture_size < 0) - scale *= 2.0f; + scale *= 2.0; if (depth == CV_8U) - scale *= 255.0f; - scale = 1.0f / scale; + scale *= 255.0; + scale = 1.0 / scale; UMat Dx, Dy; - if (!extractCovData(_src, Dx, Dy, depth, scale, aperture_size, borderType)) + if (!extractCovData(_src, Dx, Dy, depth, (double)scale, aperture_size, borderType)) return false; ocl::Kernel cornelKernel("corner", ocl::imgproc::corner_oclsrc, @@ -472,6 +472,48 @@ void cv::cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksi Mat src = _src.getMat(); _dst.create( src.size(), CV_32FC1 ); Mat dst = _dst.getMat(); + +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + int borderTypeNI = borderType & ~BORDER_ISOLATED; + bool isolated = (borderType & BORDER_ISOLATED) != 0; + + if ( (ksize == 3 || ksize == 5) && (type == CV_8UC1 || type == CV_32FC1) && + (borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE) && cn == 1 && (!src.isSubmatrix() || isolated) ) + { + IppiSize roisize = { src.cols, src.rows }; + IppiMaskSize masksize = ksize == 5 ? ippMskSize5x5 : ippMskSize3x3; + IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp32f; + Ipp32s bufsize = 0; + + double scale = (double)(1 << ((ksize > 0 ? ksize : 3) - 1)) * blockSize; + if (ksize < 0) + scale *= 2.0; + if (depth == CV_8U) + scale *= 255.0; + scale = std::pow(scale, -4.0f); + + if (ippiHarrisCornerGetBufferSize(roisize, masksize, blockSize, datatype, cn, &bufsize) >= 0) + { + Ipp8u * buffer = ippsMalloc_8u(bufsize); + IppiDifferentialKernel filterType = ksize > 0 ? ippFilterSobel : ippFilterScharr; + IppiBorderType borderTypeIpp = borderTypeNI == BORDER_CONSTANT ? ippBorderConst : ippBorderRepl; + IppStatus status = (IppStatus)-1; + + if (depth == CV_8U) + status = ippiHarrisCorner_8u32f_C1R((const Ipp8u *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize, + filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer); + else if (depth == CV_32F) + status = ippiHarrisCorner_32f_C1R((const Ipp32f *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize, + filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer); + ippsFree(buffer); + + if (status >= 0) + return; + } + } +#endif + cornerEigenValsVecs( src, dst, blockSize, ksize, HARRIS, k, borderType ); } From 76c415ff49e43bbf4c3eabb8cffb0b089b633c0f Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 14 Apr 2014 01:09:15 +0400 Subject: [PATCH 11/14] cv::filterSpeckles --- modules/calib3d/src/stereosgbm.cpp | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/modules/calib3d/src/stereosgbm.cpp b/modules/calib3d/src/stereosgbm.cpp index 6c5fd1c5e2..5e9a49de76 100644 --- a/modules/calib3d/src/stereosgbm.cpp +++ b/modules/calib3d/src/stereosgbm.cpp @@ -1078,13 +1078,36 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi double _maxDiff, InputOutputArray __buf ) { Mat img = _img.getMat(); + int type = img.type(), cn = CV_MAT_CN(type); Mat temp, &_buf = __buf.needed() ? __buf.getMatRef() : temp; - CV_Assert( img.type() == CV_8UC1 || img.type() == CV_16SC1 ); + CV_Assert( type == CV_8UC1 || type == CV_16SC1 ); - int newVal = cvRound(_newval); - int maxDiff = cvRound(_maxDiff); + int newVal = cvRound(_newval), maxDiff = cvRound(_maxDiff); - if (img.type() == CV_8UC1) +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + Ipp32s bufsize = 0; + IppiSize roisize = { img.cols, img.rows }; + IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s; + + if (!__buf.needed() && ippiMarkSpecklesGetBufferSize(roisize, datatype, cn, &bufsize)) + { + Ipp8u * buffer = ippsMalloc_8u(bufsize); + IppStatus status = (IppStatus)-1; + + if (type == CV_8UC1) + status = ippiMarkSpeckles_8u_C1IR((Ipp8u *)img.data, (int)img.step, roisize, + (Ipp8u)newVal, maxSpeckleSize, maxDiff, ippiNormL1, buffer); + else if (type == CV_16SC1) + status = ippiMarkSpeckles_16s_C1IR((Ipp16s *)img.data, (int)img.step, roisize, + (Ipp16s)newVal, maxSpeckleSize, maxDiff, ippiNormL1, buffer); + + printf("%s\n", ippGetStatusString(status)); + if (status >= 0) + return; + } +#endif + + if (type == CV_8UC1) filterSpecklesImpl(img, newVal, maxSpeckleSize, maxDiff, _buf); else filterSpecklesImpl(img, newVal, maxSpeckleSize, maxDiff, _buf); From 9cc80a68db5e7d585d4f6ae3b4365de6ec0599cb Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 14 Apr 2014 14:49:43 +0400 Subject: [PATCH 12/14] fixed warnings --- modules/calib3d/src/stereosgbm.cpp | 5 ++- modules/core/perf/opencl/perf_matop.cpp | 43 +++++++++++++++++++++++++ modules/core/src/arithm.cpp | 3 +- modules/imgproc/src/accum.cpp | 2 ++ modules/imgproc/src/corner.cpp | 2 +- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/modules/calib3d/src/stereosgbm.cpp b/modules/calib3d/src/stereosgbm.cpp index 5e9a49de76..ba0d24fe42 100644 --- a/modules/calib3d/src/stereosgbm.cpp +++ b/modules/calib3d/src/stereosgbm.cpp @@ -1078,7 +1078,7 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi double _maxDiff, InputOutputArray __buf ) { Mat img = _img.getMat(); - int type = img.type(), cn = CV_MAT_CN(type); + int type = img.type(); Mat temp, &_buf = __buf.needed() ? __buf.getMatRef() : temp; CV_Assert( type == CV_8UC1 || type == CV_16SC1 ); @@ -1089,7 +1089,7 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi IppiSize roisize = { img.cols, img.rows }; IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s; - if (!__buf.needed() && ippiMarkSpecklesGetBufferSize(roisize, datatype, cn, &bufsize)) + if (!__buf.needed() && ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize)) { Ipp8u * buffer = ippsMalloc_8u(bufsize); IppStatus status = (IppStatus)-1; @@ -1101,7 +1101,6 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi status = ippiMarkSpeckles_16s_C1IR((Ipp16s *)img.data, (int)img.step, roisize, (Ipp16s)newVal, maxSpeckleSize, maxDiff, ippiNormL1, buffer); - printf("%s\n", ippGetStatusString(status)); if (status >= 0) return; } diff --git a/modules/core/perf/opencl/perf_matop.cpp b/modules/core/perf/opencl/perf_matop.cpp index a3b2674146..51605b9d35 100644 --- a/modules/core/perf/opencl/perf_matop.cpp +++ b/modules/core/perf/opencl/perf_matop.cpp @@ -35,6 +35,28 @@ OCL_PERF_TEST_P(SetToFixture, SetTo, SANITY_CHECK(src); } +///////////// SetTo with mask //////////////////////// + +typedef Size_MatType SetToFixture; + +OCL_PERF_TEST_P(SetToFixture, SetToWithMask, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + const Scalar s = Scalar::all(17); + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + UMat src(srcSize, type), mask(srcSize, CV_8UC1); + declare.in(src, mask, WARMUP_RNG).out(src); + + OCL_TEST_CYCLE() src.setTo(s, mask); + + SANITY_CHECK(src); +} + ///////////// ConvertTo //////////////////////// typedef Size_MatType ConvertToFixture; @@ -79,6 +101,27 @@ OCL_PERF_TEST_P(CopyToFixture, CopyTo, SANITY_CHECK(dst); } +///////////// CopyTo with mask //////////////////////// + +typedef Size_MatType CopyToFixture; + +OCL_PERF_TEST_P(CopyToFixture, CopyToWithMask, + ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES)) +{ + const Size_MatType_t params = GetParam(); + const Size srcSize = get<0>(params); + const int type = get<1>(params); + + checkDeviceMaxMemoryAllocSize(srcSize, type); + + UMat src(srcSize, type), dst(srcSize, type), mask(srcSize, CV_8UC1); + declare.in(src, mask, WARMUP_RNG).out(dst); + + OCL_TEST_CYCLE() src.copyTo(dst, mask); + + SANITY_CHECK(dst); +} + } } // namespace cvtest::ocl #endif // HAVE_OPENCL diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index d9e1eadf5e..1c6c4beec2 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -2011,7 +2011,8 @@ recip_( const T*, size_t, const T* src2, size_t step2, static void mul8u( const uchar* src1, size_t step1, const uchar* src2, size_t step2, uchar* dst, size_t step, Size sz, void* scale) { - mul_(src1, step1, src2, step2, dst, step, sz, (float)*(const double*)scale); + float fscale = (float)*(const double*)scale; + mul_(src1, step1, src2, step2, dst, step, sz, fscale); } static void mul8s( const schar* src1, size_t step1, const schar* src2, size_t step2, diff --git a/modules/imgproc/src/accum.cpp b/modules/imgproc/src/accum.cpp index 193c18cee7..e218fc6936 100644 --- a/modules/imgproc/src/accum.cpp +++ b/modules/imgproc/src/accum.cpp @@ -442,9 +442,11 @@ void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask ) if (mask.empty()) { + CV_SUPPRESS_DEPRECATED_START ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAdd)ippiAdd_8u32f_C1IR : sdepth == CV_16U && ddepth == CV_32F ? (ippiAdd)ippiAdd_16u32f_C1IR : sdepth == CV_32F && ddepth == CV_32F ? (ippiAdd)ippiAdd_32f_C1IR : 0; + CV_SUPPRESS_DEPRECATED_END } else if (scn == 1) { diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index 621f7f80f0..424866d1c2 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -473,7 +473,7 @@ void cv::cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksi _dst.create( src.size(), CV_32FC1 ); Mat dst = _dst.getMat(); -#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY +#if IPP_VERSION_X100 >= 801 && !defined HAVE_IPP_ICV_ONLY int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); int borderTypeNI = borderType & ~BORDER_ISOLATED; bool isolated = (borderType & BORDER_ISOLATED) != 0; From fe644ede19bd0640dc33ce11934d10aa7876cc80 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 14 Apr 2014 18:42:21 +0400 Subject: [PATCH 13/14] cv::multiply --- modules/calib3d/src/stereosgbm.cpp | 4 +- modules/core/src/arithm.cpp | 33 +++++++++++++--- modules/core/src/copy.cpp | 13 ++++--- modules/core/src/matrix.cpp | 2 + modules/imgproc/src/corner.cpp | 2 +- modules/imgproc/src/deriv.cpp | 61 ------------------------------ 6 files changed, 41 insertions(+), 74 deletions(-) diff --git a/modules/calib3d/src/stereosgbm.cpp b/modules/calib3d/src/stereosgbm.cpp index ba0d24fe42..e8916f52a9 100644 --- a/modules/calib3d/src/stereosgbm.cpp +++ b/modules/calib3d/src/stereosgbm.cpp @@ -1096,10 +1096,10 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi if (type == CV_8UC1) status = ippiMarkSpeckles_8u_C1IR((Ipp8u *)img.data, (int)img.step, roisize, - (Ipp8u)newVal, maxSpeckleSize, maxDiff, ippiNormL1, buffer); + (Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer); else if (type == CV_16SC1) status = ippiMarkSpeckles_16s_C1IR((Ipp16s *)img.data, (int)img.step, roisize, - (Ipp16s)newVal, maxSpeckleSize, maxDiff, ippiNormL1, buffer); + (Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer); if (status >= 0) return; diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 1c6c4beec2..7ba9f098ff 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -705,7 +705,7 @@ static void max64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, Size sz, void* ) { -#if ARITHM_USE_IPP == 1 +#if ARITHM_USE_IPP == 1 && !defined HAVE_IPP_ICV_ONLY double* s1 = (double*)src1; double* s2 = (double*)src2; double* d = dst; @@ -825,7 +825,7 @@ static void min64f( const double* src1, size_t step1, const double* src2, size_t step2, double* dst, size_t step, Size sz, void* ) { -#if ARITHM_USE_IPP == 1 +#if ARITHM_USE_IPP == 1 && !defined HAVE_IPP_ICV_ONLY double* s1 = (double*)src1; double* s2 = (double*)src2; double* d = dst; @@ -2012,6 +2012,11 @@ static void mul8u( const uchar* src1, size_t step1, const uchar* src2, size_t st uchar* dst, size_t step, Size sz, void* scale) { float fscale = (float)*(const double*)scale; +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (std::fabs(fscale - 1) <= FLT_EPSILON && + ippiMul_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) + return; +#endif mul_(src1, step1, src2, step2, dst, step, sz, fscale); } @@ -2024,13 +2029,25 @@ static void mul8s( const schar* src1, size_t step1, const schar* src2, size_t st static void mul16u( const ushort* src1, size_t step1, const ushort* src2, size_t step2, ushort* dst, size_t step, Size sz, void* scale) { - mul_(src1, step1, src2, step2, dst, step, sz, (float)*(const double*)scale); + float fscale = (float)*(const double*)scale; +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (std::fabs(fscale - 1) <= FLT_EPSILON && + ippiMul_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) + return; +#endif + mul_(src1, step1, src2, step2, dst, step, sz, fscale); } static void mul16s( const short* src1, size_t step1, const short* src2, size_t step2, short* dst, size_t step, Size sz, void* scale) { - mul_(src1, step1, src2, step2, dst, step, sz, (float)*(const double*)scale); + float fscale = (float)*(const double*)scale; +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (std::fabs(fscale - 1) <= FLT_EPSILON && + ippiMul_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) + return; +#endif + mul_(src1, step1, src2, step2, dst, step, sz, fscale); } static void mul32s( const int* src1, size_t step1, const int* src2, size_t step2, @@ -2042,7 +2059,13 @@ static void mul32s( const int* src1, size_t step1, const int* src2, size_t step2 static void mul32f( const float* src1, size_t step1, const float* src2, size_t step2, float* dst, size_t step, Size sz, void* scale) { - mul_(src1, step1, src2, step2, dst, step, sz, (float)*(const double*)scale); + float fscale = (float)*(const double*)scale; +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY + if (std::fabs(fscale - 1) <= FLT_EPSILON && + ippiMul_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)) >= 0) + return; +#endif + mul_(src1, step1, src2, step2, dst, step, sz, fscale); } static void mul64f( const double* src1, size_t step1, const double* src2, size_t step2, diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 40e5b51b93..86223f6564 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -356,7 +356,7 @@ Mat& Mat::operator = (const Scalar& s) if( is[0] == 0 && is[1] == 0 && is[2] == 0 && is[3] == 0 ) { -#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY +#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY && 0 if (dims <= 2 || isContinuous()) { IppiSize roisize = { cols, rows }; @@ -365,10 +365,10 @@ Mat& Mat::operator = (const Scalar& s) roisize.width = (int)total(); roisize.height = 1; - if (ippsZero_8u(data, roisize.width * elemSize()) >= 0) + if (ippsZero_8u(data, static_cast(roisize.width * elemSize())) >= 0) return *this; } - roisize.width *= elemSize(); + roisize.width *= (int)elemSize(); if (ippiSet_8u_C1R(0, data, (int)step, roisize) >= 0) return *this; @@ -416,8 +416,9 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask) #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous()))) { - uchar buf[32]; - convertAndUnrollScalar( value, type(), buf, 1 ); + uchar _buf[32]; + void * buf = _buf; + convertAndUnrollScalar( value, type(), _buf, 1 ); int cn = channels(), depth0 = depth(); IppStatus status = (IppStatus)-1; @@ -678,6 +679,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode ) if (src.data == dst.data) { + CV_SUPPRESS_DEPRECATED_START ippFuncI = type == CV_8UC1 ? (ippiMirrorI)ippiMirror_8u_C1IR : type == CV_8UC3 ? (ippiMirrorI)ippiMirror_8u_C3IR : @@ -694,6 +696,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode ) type == CV_32FC1 ? (ippiMirrorI)ippiMirror_32f_C1IR : type == CV_32FC3 ? (ippiMirrorI)ippiMirror_32f_C3IR : type == CV_32FC4 ? (ippiMirrorI)ippiMirror_32f_C4IR : 0; + CV_SUPPRESS_DEPRECATED_END } else { diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 9b4d859e9f..aa935b36f6 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -3027,6 +3027,7 @@ void cv::transpose( InputArray _src, OutputArray _dst ) if (dst.data == src.data && dst.cols == dst.rows) { + CV_SUPPRESS_DEPRECATED_START ippFuncI = type == CV_8UC1 ? (ippiTransposeI)ippiTranspose_8u_C1IR : type == CV_8UC3 ? (ippiTransposeI)ippiTranspose_8u_C3IR : @@ -3043,6 +3044,7 @@ void cv::transpose( InputArray _src, OutputArray _dst ) type == CV_32FC1 ? (ippiTransposeI)ippiTranspose_32f_C1IR : type == CV_32FC3 ? (ippiTransposeI)ippiTranspose_32f_C3IR : type == CV_32FC4 ? (ippiTransposeI)ippiTranspose_32f_C4IR : 0; + CV_SUPPRESS_DEPRECATED_END } else { diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index 424866d1c2..b2adea4962 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -389,7 +389,7 @@ static bool ocl_cornerMinEigenValVecs(InputArray _src, OutputArray _dst, int blo scale = 1.0 / scale; UMat Dx, Dy; - if (!extractCovData(_src, Dx, Dy, depth, (double)scale, aperture_size, borderType)) + if (!extractCovData(_src, Dx, Dy, depth, (float)scale, aperture_size, borderType)) return false; ocl::Kernel cornelKernel("corner", ocl::imgproc::corner_oclsrc, diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index b11bce4b68..c6885d4629 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -483,67 +483,6 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int dtype = CV_MAKETYPE(ddepth, cn); _dst.create( _src.size(), dtype ); -#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if ((ksize == 3 || ksize == 5) && ((borderType & BORDER_ISOLATED) == 0 || !_src.isSubmatrix()) && - ((stype == CV_8UC1 && ddepth == CV_16S) || (ddepth == CV_32F && stype == CV_32FC1))) - { - int iscale = saturate_cast(scale), idelta = saturate_cast(delta); - bool floatScale = std::fabs(scale - iscale) > DBL_EPSILON, needScale = iscale != 1; - bool floatDelta = std::fabs(delta - idelta) > DBL_EPSILON, needDelta = delta != 0; - int borderTypeNI = borderType & ~BORDER_ISOLATED; - Mat src = _src.getMat(), dst = _dst.getMat(); - - if (src.data != dst.data) - { - Ipp32s bufsize; - IppStatus status = (IppStatus)-1; - IppiSize roisize = { src.cols, src.rows }; - IppiMaskSize masksize = ksize == 3 ? ippMskSize3x3 : ippMskSize5x5; - IppiBorderType borderTypeIpp = - borderTypeNI == BORDER_CONSTANT ? ippBorderConst : - borderTypeNI == BORDER_WRAP ? ippBorderWrap : - borderTypeNI == BORDER_REPLICATE ? ippBorderRepl : - borderTypeNI == BORDER_REFLECT_101 ? ippBorderMirror : - borderTypeNI == BORDER_REFLECT ? ippBorderMirrorR : (IppiBorderType)-1; - -#define IPP_FILTER_LAPLACIAN(ippsrctype, ippdsttype, ippfavor) \ -do \ -{ \ - if (borderTypeIpp >= 0 && ippiFilterLaplacianGetBufferSize_##ippfavor##_C1R(roisize, masksize, &bufsize) >= 0) \ - { \ - Ipp8u * buffer = ippsMalloc_8u(bufsize); \ - status = ippiFilterLaplacianBorder_##ippfavor##_C1R((const ippsrctype *)src.data, (int)src.step, (ippdsttype *)dst.data, \ - (int)dst.step, roisize, masksize, borderTypeIpp, 0, buffer); \ - ippsFree(buffer); \ - } \ -} while ((void)0, 0) - - if (sdepth == CV_8U && ddepth == CV_16S && !floatScale && !floatDelta) - { - IPP_FILTER_LAPLACIAN(Ipp8u, Ipp16s, 8u16s); - - if (needScale) - status = ippiMulC_16s_C1IRSfs((Ipp16s)iscale, (Ipp16s *)dst.data, (int)dst.step, roisize, 0); - if (needDelta) - status = ippiAddC_16s_C1IRSfs((Ipp16s)idelta, (Ipp16s *)dst.data, (int)dst.step, roisize, 0); - } - else if (sdepth == CV_32F && ddepth == CV_32F) - { - IPP_FILTER_LAPLACIAN(Ipp32f, Ipp32f, 32f); - - if (needScale) - status = ippiMulC_32f_C1IR((Ipp32f)scale, (Ipp32f *)dst.data, (int)dst.step, roisize); - if (needDelta) - status = ippiAddC_32f_C1IR((Ipp32f)delta, (Ipp32f *)dst.data, (int)dst.step, roisize); - } - - if (status >= 0) - return; - } - } -#undef IPP_FILTER_LAPLACIAN -#endif - #ifdef HAVE_TEGRA_OPTIMIZATION if (scale == 1.0 && delta == 0) { From 51e2a8ec968b319de5c024a1600d8bcd58c41386 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 18 Apr 2014 14:25:38 +0400 Subject: [PATCH 14/14] fixes --- modules/calib3d/src/stereosgbm.cpp | 20 +++++++++------- modules/core/src/arithm.cpp | 38 ++++++++++++++++++++---------- modules/core/src/copy.cpp | 19 +++++++++++---- modules/core/src/matrix.cpp | 1 + modules/imgproc/src/accum.cpp | 1 + modules/imgproc/src/corner.cpp | 3 +++ 6 files changed, 58 insertions(+), 24 deletions(-) diff --git a/modules/calib3d/src/stereosgbm.cpp b/modules/calib3d/src/stereosgbm.cpp index e8916f52a9..a1db5c4ffc 100644 --- a/modules/calib3d/src/stereosgbm.cpp +++ b/modules/calib3d/src/stereosgbm.cpp @@ -1089,20 +1089,24 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi IppiSize roisize = { img.cols, img.rows }; IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s; - if (!__buf.needed() && ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize)) + if (!__buf.needed() && (type == CV_8UC1 || type == CV_16SC1)) { + IppStatus status = ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize); Ipp8u * buffer = ippsMalloc_8u(bufsize); - IppStatus status = (IppStatus)-1; - if (type == CV_8UC1) - status = ippiMarkSpeckles_8u_C1IR((Ipp8u *)img.data, (int)img.step, roisize, - (Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer); - else if (type == CV_16SC1) - status = ippiMarkSpeckles_16s_C1IR((Ipp16s *)img.data, (int)img.step, roisize, - (Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer); + if ((int)status >= 0) + { + if (type == CV_8UC1) + status = ippiMarkSpeckles_8u_C1IR((Ipp8u *)img.data, (int)img.step, roisize, + (Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer); + else + status = ippiMarkSpeckles_16s_C1IR((Ipp16s *)img.data, (int)img.step, roisize, + (Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer); + } if (status >= 0) return; + setIppErrorStatus(); } #endif diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 7ba9f098ff..009b4e4219 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -721,6 +721,7 @@ static void max64f( const double* src1, size_t step1, } if (i == sz.height) return; + setIppErrorStatus(); #endif vBinOp64, IF_SIMD(VMax)>(src1, step1, src2, step2, dst, step, sz); } @@ -841,6 +842,7 @@ static void min64f( const double* src1, size_t step1, } if (i == sz.height) return; + setIppErrorStatus(); #endif vBinOp64, IF_SIMD(VMin)>(src1, step1, src2, step2, dst, step, sz); } @@ -2013,9 +2015,12 @@ static void mul8u( const uchar* src1, size_t step1, const uchar* src2, size_t st { float fscale = (float)*(const double*)scale; #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (std::fabs(fscale - 1) <= FLT_EPSILON && - ippiMul_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) - return; + if (std::fabs(fscale - 1) <= FLT_EPSILON) + { + if (ippiMul_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) + return; + setIppErrorStatus(); + } #endif mul_(src1, step1, src2, step2, dst, step, sz, fscale); } @@ -2031,9 +2036,12 @@ static void mul16u( const ushort* src1, size_t step1, const ushort* src2, size_t { float fscale = (float)*(const double*)scale; #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (std::fabs(fscale - 1) <= FLT_EPSILON && - ippiMul_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) - return; + if (std::fabs(fscale - 1) <= FLT_EPSILON) + { + if (ippiMul_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) + return; + setIppErrorStatus(); + } #endif mul_(src1, step1, src2, step2, dst, step, sz, fscale); } @@ -2043,9 +2051,12 @@ static void mul16s( const short* src1, size_t step1, const short* src2, size_t s { float fscale = (float)*(const double*)scale; #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (std::fabs(fscale - 1) <= FLT_EPSILON && - ippiMul_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) - return; + if (std::fabs(fscale - 1) <= FLT_EPSILON) + { + if (ippiMul_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0) + return; + setIppErrorStatus(); + } #endif mul_(src1, step1, src2, step2, dst, step, sz, fscale); } @@ -2061,9 +2072,12 @@ static void mul32f( const float* src1, size_t step1, const float* src2, size_t s { float fscale = (float)*(const double*)scale; #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (std::fabs(fscale - 1) <= FLT_EPSILON && - ippiMul_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)) >= 0) - return; + if (std::fabs(fscale - 1) <= FLT_EPSILON) + { + if (ippiMul_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)) >= 0) + return; + setIppErrorStatus(); + } #endif mul_(src1, step1, src2, step2, dst, step, sz, fscale); } diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 86223f6564..713725ea42 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -84,6 +84,7 @@ copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mste #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY if (ippiCopy_8u_C1MR(_src, (int)sstep, _dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0) return; + setIppErrorStatus(); #endif for( ; size.height--; mask += mstep, _src += sstep, _dst += dstep ) @@ -119,6 +120,7 @@ copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mst #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY if (ippiCopy_16u_C1MR((const Ipp16u *)_src, (int)sstep, (Ipp16u *)_dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0) return; + setIppErrorStatus(); #endif for( ; size.height--; mask += mstep, _src += sstep, _dst += dstep ) @@ -182,6 +184,7 @@ static void copyMask##suffix(const uchar* src, size_t sstep, const uchar* mask, { \ if (ippiCopy_##ippfavor((const ipptype *)src, (int)sstep, (ipptype *)dst, (int)dstep, ippiSize(size), (const Ipp8u *)mask, (int)mstep) >= 0) \ return; \ + setIppErrorStatus(); \ copyMask_(src, sstep, mask, mstep, dst, dstep, size); \ } #else @@ -281,6 +284,7 @@ void Mat::copyTo( OutputArray _dst ) const #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY if (ippiCopy_8u_C1R(sptr, (int)step, dptr, (int)dst.step, ippiSize((int)len, sz.height)) >= 0) return; + setIppErrorStatus(); #endif for( ; sz.height--; sptr += step, dptr += dst.step ) @@ -367,11 +371,13 @@ Mat& Mat::operator = (const Scalar& s) if (ippsZero_8u(data, static_cast(roisize.width * elemSize())) >= 0) return *this; + setIppErrorStatus(); } roisize.width *= (int)elemSize(); if (ippiSet_8u_C1R(0, data, (int)step, roisize) >= 0) return *this; + setIppErrorStatus(); } #endif @@ -414,13 +420,16 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask) CV_Assert( mask.empty() || (mask.type() == CV_8U && size == mask.size) ); #if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous()))) + int cn = channels(), depth0 = depth(); + + if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous())) && + (depth0 == CV_8U || depth0 == CV_16U || depth0 == CV_16S || depth0 == CV_32S || depth0 == CV_32F) && + (cn == 1 || cn == 3 || cn == 4)) { uchar _buf[32]; void * buf = _buf; convertAndUnrollScalar( value, type(), _buf, 1 ); - int cn = channels(), depth0 = depth(); IppStatus status = (IppStatus)-1; IppiSize roisize = { cols, rows }; int mstep = (int)mask.step, dstep = (int)step; @@ -444,13 +453,13 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask) else if (depth0 == CV_32F) status = ippiSet_32f_C1MR(*(Ipp32f *)buf, (Ipp32f *)data, dstep, roisize, mask.data, mstep); } - else if (cn == 3 || cn == 3) + else if (cn == 3 || cn == 4) { #define IPP_SET(ippfavor, ippcn) \ do \ { \ typedef Ipp##ippfavor ipptype; \ - ipptype ippvalue[4] = { ((ipptype *)buf)[0], ((ipptype *)buf)[1], ((ipptype *)buf)[2], ((ipptype *)buf)[4] }; \ + ipptype ippvalue[4] = { ((ipptype *)buf)[0], ((ipptype *)buf)[1], ((ipptype *)buf)[2], ((ipptype *)buf)[3] }; \ status = ippiSet_##ippfavor##_C##ippcn##MR(ippvalue, (ipptype *)data, dstep, roisize, mask.data, mstep); \ } while ((void)0, 0) @@ -481,6 +490,7 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask) if (status >= 0) return *this; + setIppErrorStatus(); } #endif @@ -733,6 +743,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode ) return; setIppErrorStatus(); } +#endif if( flip_mode <= 0 ) flipVert( src.data, src.step, dst.data, dst.step, src.size(), esz ); diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index aa935b36f6..ff7abf16c6 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -3079,6 +3079,7 @@ void cv::transpose( InputArray _src, OutputArray _dst ) return; setIppErrorStatus(); } +#endif if( dst.data == src.data ) { diff --git a/modules/imgproc/src/accum.cpp b/modules/imgproc/src/accum.cpp index e218fc6936..e0cce1f594 100644 --- a/modules/imgproc/src/accum.cpp +++ b/modules/imgproc/src/accum.cpp @@ -479,6 +479,7 @@ void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask ) if (status >= 0) return; + setIppErrorStatus(); } } #endif diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index b2adea4962..edc3504fb1 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -510,7 +510,10 @@ void cv::cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksi if (status >= 0) return; + setIppErrorStatus(); } + else + setIppErrorStatus(); } #endif