From 5ddff235bbcbb5c41e8a2111e0d0b33cc308f25b Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 3 Apr 2014 23:45:41 +0400 Subject: [PATCH] cv::polarToCart --- modules/core/src/mathfuncs.cpp | 16 +++++++ modules/imgproc/src/imgwarp.cpp | 82 ++++++++++++++++----------------- 2 files changed, 57 insertions(+), 41 deletions(-) diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index 12ba4fa5b1..7f967112d9 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -729,6 +729,22 @@ void polarToCart( InputArray src1, InputArray src2, dst2.create( Angle.dims, Angle.size, type ); Mat X = dst1.getMat(), Y = dst2.getMat(); +#ifdef HAVE_IPP + if (Mag.isContinuous() && Angle.isContinuous() && X.isContinuous() && Y.isContinuous() && !angleInDegrees) + { + typedef IppStatus (CV_STDCALL * ippsPolarToCart)(const void * pSrcMagn, const void * pSrcPhase, + void * pDstRe, void * pDstIm, int len); + ippsPolarToCart ippFunc = + depth == CV_32F ? (ippsPolarToCart)ippsPolarToCart_32f : + depth == CV_64F ? (ippsPolarToCart)ippsPolarToCart_64f : 0; + CV_Assert(ippFunc != 0); + + IppStatus status = ippFunc(Mag.data, Angle.data, X.data, Y.data, static_cast(cn * X.total())); + if (status == ippStsNoErr) + return; + } +#endif + const Mat* arrays[] = {&Mag, &Angle, &X, &Y, 0}; uchar* ptrs[4]; NAryMatIterator it(arrays, ptrs); diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 7dca25c856..ec9a9b595c 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -4016,54 +4016,54 @@ private: /* #if defined (HAVE_IPP) && IPP_VERSION_MAJOR >= 8 IPP_VERSION_MINOR >= 1 class IPPWarpAffineInvoker : - public ParallelLoopBody + public ParallelLoopBody { public: - IPPWarpAffineInvoker(Mat &_src, Mat &_dst, double (&_coeffs)[2][3], int &_interpolation, int _borderType, - const Scalar &_borderValue, ippiWarpAffineBackFunc _func, bool *_ok) : - ParallelLoopBody(), src(_src), dst(_dst), mode(_interpolation), coeffs(_coeffs), - borderType(_borderType), borderValue(_borderValue), func(_func), ok(_ok) - { - *ok = true; - } + IPPWarpAffineInvoker(Mat &_src, Mat &_dst, double (&_coeffs)[2][3], int &_interpolation, int _borderType, + const Scalar &_borderValue, ippiWarpAffineBackFunc _func, bool *_ok) : + ParallelLoopBody(), src(_src), dst(_dst), mode(_interpolation), coeffs(_coeffs), + borderType(_borderType), borderValue(_borderValue), func(_func), ok(_ok) + { + *ok = true; + } - virtual void operator() (const Range& range) const - { - IppiSize srcsize = { src.cols, src.rows }; - IppiRect srcroi = { 0, 0, src.cols, src.rows }; - IppiRect dstroi = { 0, range.start, dst.cols, range.end - range.start }; - int cnn = src.channels(); - if( borderType == BORDER_CONSTANT ) - { - IppiSize setSize = { dst.cols, range.end - range.start }; - void *dataPointer = dst.data + dst.step[0] * range.start; - if( !IPPSet( borderValue, dataPointer, (int)dst.step[0], setSize, cnn, src.depth() ) ) - { - *ok = false; - return; - } - } + virtual void operator() (const Range& range) const + { + IppiSize srcsize = { src.cols, src.rows }; + IppiRect srcroi = { 0, 0, src.cols, src.rows }; + IppiRect dstroi = { 0, range.start, dst.cols, range.end - range.start }; + int cnn = src.channels(); + if( borderType == BORDER_CONSTANT ) + { + IppiSize setSize = { dst.cols, range.end - range.start }; + void *dataPointer = dst.data + dst.step[0] * range.start; + if( !IPPSet( borderValue, dataPointer, (int)dst.step[0], setSize, cnn, src.depth() ) ) + { + *ok = false; + return; + } + } - ////Aug 2013: problem in IPP 7.1, 8.0 : sometimes function return ippStsCoeffErr - IppStatus status = func( src.data, srcsize, (int)src.step[0], srcroi, dst.data, - (int)dst.step[0], dstroi, coeffs, mode ); - printf("%d\n", status); - if( status != ippStsNoErr) - *ok = false; - } + ////Aug 2013: problem in IPP 7.1, 8.0 : sometimes function return ippStsCoeffErr + IppStatus status = func( src.data, srcsize, (int)src.step[0], srcroi, dst.data, + (int)dst.step[0], dstroi, coeffs, mode ); + printf("%d\n", status); + if( status != ippStsNoErr) + *ok = false; + } private: - Mat &src; - Mat &dst; - int mode; - double (&coeffs)[2][3]; - int borderType; - Scalar borderValue; - ippiWarpAffineBackFunc func; - bool *ok; - const IPPWarpAffineInvoker& operator= (const IPPWarpAffineInvoker&); + Mat &src; + Mat &dst; + int mode; + double (&coeffs)[2][3]; + int borderType; + Scalar borderValue; + ippiWarpAffineBackFunc func; + bool *ok; + const IPPWarpAffineInvoker& operator= (const IPPWarpAffineInvoker&); }; #endif - */ + */ #ifdef HAVE_OPENCL