mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Update for IPP for OpenCV 2017u2 integration;
Updated integrations for: cv::split cv::merge cv::insertChannel cv::extractChannel cv::Mat::convertTo - now with scaled conversions support cv::LUT - disabled due to performance issues Mat::copyTo Mat::setTo cv::flip cv::copyMakeBorder - currently disabled cv::polarToCart cv::pow - ipp pow function was removed due to performance issues cv::hal::magnitude32f/64f - disabled for <= SSE42, poor performance cv::countNonZero cv::minMaxIdx cv::norm cv::canny - new integration. Disabled for threaded; cv::cornerHarris cv::boxFilter cv::bilateralFilter cv::integral
This commit is contained in:
+376
-328
@@ -1309,30 +1309,51 @@ static bool ipp_countNonZero( Mat &src, int &res )
|
||||
{
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
Ipp32s count = 0;
|
||||
IppStatus status = ippStsNoErr;
|
||||
Ipp32s count = 0;
|
||||
int depth = src.depth();
|
||||
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type);
|
||||
IppiSize roiSize = { src.cols, src.rows };
|
||||
Ipp32s srcstep = (Ipp32s)src.step;
|
||||
if (src.isContinuous())
|
||||
if(src.dims <= 2)
|
||||
{
|
||||
roiSize.width = (Ipp32s)src.total();
|
||||
roiSize.height = 1;
|
||||
srcstep = (Ipp32s)src.total() * CV_ELEM_SIZE(type);
|
||||
IppStatus status;
|
||||
IppiSize size = {src.cols*src.channels(), src.rows};
|
||||
|
||||
if(depth == CV_8U)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_8u_C1R, (const Ipp8u *)src.ptr(), (int)src.step, size, &count, 0, 0);
|
||||
else if(depth == CV_32F)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_32f_C1R, (const Ipp32f *)src.ptr(), (int)src.step, size, &count, 0, 0);
|
||||
else
|
||||
return false;
|
||||
|
||||
if(status < 0)
|
||||
return false;
|
||||
|
||||
res = size.width*size.height - count;
|
||||
}
|
||||
else
|
||||
{
|
||||
IppStatus status;
|
||||
const Mat *arrays[] = {&src, NULL};
|
||||
uchar *ptrs[1] = {NULL};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
IppiSize size = {(int)it.size*src.channels(), 1};
|
||||
|
||||
for (size_t i = 0; i < it.nplanes; i++, ++it)
|
||||
{
|
||||
if(depth == CV_8U)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_8u_C1R, (const Ipp8u *)src.ptr(), (int)src.step, size, &count, 0, 0);
|
||||
else if(depth == CV_32F)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_32f_C1R, (const Ipp32f *)src.ptr(), (int)src.step, size, &count, 0, 0);
|
||||
else
|
||||
return false;
|
||||
|
||||
if(status < 0)
|
||||
return false;
|
||||
|
||||
res += (size.width*size.height - count);
|
||||
}
|
||||
}
|
||||
|
||||
if (depth == CV_8U)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_8u_C1R, (const Ipp8u *)src.data, srcstep, roiSize, &count, 0, 0);
|
||||
else if (depth == CV_32F)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_32f_C1R, (const Ipp32f *)src.data, srcstep, roiSize, &count, 0, 0);
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
res = ((Ipp32s)src.total() - count);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1356,7 +1377,7 @@ int cv::countNonZero( InputArray _src )
|
||||
#endif
|
||||
|
||||
Mat src = _src.getMat();
|
||||
CV_IPP_RUN(0 && (_src.dims() <= 2 || _src.isContinuous()), ipp_countNonZero(src, res), res);
|
||||
CV_IPP_RUN_FAST(ipp_countNonZero(src, res), res);
|
||||
|
||||
CountNonZeroFunc func = getCountNonZeroTab(src.depth());
|
||||
CV_Assert( func != 0 );
|
||||
@@ -2373,109 +2394,273 @@ static bool openvx_minMaxIdx(Mat &src, double* minVal, double* maxVal, int* minI
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, Mat &mask)
|
||||
static IppStatus ipp_minMaxIndex_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
|
||||
float* pMinVal, float* pMaxVal, IppiPoint* pMinIndex, IppiPoint* pMaxIndex, const Ipp8u*, int)
|
||||
{
|
||||
switch(dataType)
|
||||
{
|
||||
case ipp8u: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_8u_C1R, (const Ipp8u*)pSrc, srcStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
|
||||
case ipp16u: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_16u_C1R, (const Ipp16u*)pSrc, srcStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
|
||||
case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_32f_C1R, (const Ipp32f*)pSrc, srcStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
|
||||
default: return ippStsDataTypeErr;
|
||||
}
|
||||
}
|
||||
|
||||
static IppStatus ipp_minMaxIndexMask_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
|
||||
float* pMinVal, float* pMaxVal, IppiPoint* pMinIndex, IppiPoint* pMaxIndex, const Ipp8u* pMask, int maskStep)
|
||||
{
|
||||
switch(dataType)
|
||||
{
|
||||
case ipp8u: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_8u_C1MR, (const Ipp8u*)pSrc, srcStep, pMask, maskStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
|
||||
case ipp16u: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_16u_C1MR, (const Ipp16u*)pSrc, srcStep, pMask, maskStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
|
||||
case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_32f_C1MR, (const Ipp32f*)pSrc, srcStep, pMask, maskStep, size, pMinVal, pMaxVal, pMinIndex, pMaxIndex);
|
||||
default: return ippStsDataTypeErr;
|
||||
}
|
||||
}
|
||||
|
||||
static IppStatus ipp_minMax_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
|
||||
float* pMinVal, float* pMaxVal, IppiPoint*, IppiPoint*, const Ipp8u*, int)
|
||||
{
|
||||
IppStatus status;
|
||||
|
||||
switch(dataType)
|
||||
{
|
||||
#if IPP_VERSION_X100 > 201701 // wrong min values
|
||||
case ipp8u:
|
||||
{
|
||||
Ipp8u val[2];
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMinMax_8u_C1R, (const Ipp8u*)pSrc, srcStep, size, &val[0], &val[1]);
|
||||
*pMinVal = val[0];
|
||||
*pMaxVal = val[1];
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
case ipp16u:
|
||||
{
|
||||
Ipp16u val[2];
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMinMax_16u_C1R, (const Ipp16u*)pSrc, srcStep, size, &val[0], &val[1]);
|
||||
*pMinVal = val[0];
|
||||
*pMaxVal = val[1];
|
||||
return status;
|
||||
}
|
||||
case ipp16s:
|
||||
{
|
||||
Ipp16s val[2];
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMinMax_16s_C1R, (const Ipp16s*)pSrc, srcStep, size, &val[0], &val[1]);
|
||||
*pMinVal = val[0];
|
||||
*pMaxVal = val[1];
|
||||
return status;
|
||||
}
|
||||
case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMinMax_32f_C1R, (const Ipp32f*)pSrc, srcStep, size, pMinVal, pMaxVal);
|
||||
default: return ipp_minMaxIndex_wrap(pSrc, srcStep, size, dataType, pMinVal, pMaxVal, NULL, NULL, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static IppStatus ipp_minIdx_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
|
||||
float* pMinVal, float*, IppiPoint* pMinIndex, IppiPoint*, const Ipp8u*, int)
|
||||
{
|
||||
IppStatus status;
|
||||
|
||||
switch(dataType)
|
||||
{
|
||||
case ipp8u:
|
||||
{
|
||||
Ipp8u val;
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMinIndx_8u_C1R, (const Ipp8u*)pSrc, srcStep, size, &val, &pMinIndex->x, &pMinIndex->y);
|
||||
*pMinVal = val;
|
||||
return status;
|
||||
}
|
||||
case ipp16u:
|
||||
{
|
||||
Ipp16u val;
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMinIndx_16u_C1R, (const Ipp16u*)pSrc, srcStep, size, &val, &pMinIndex->x, &pMinIndex->y);
|
||||
*pMinVal = val;
|
||||
return status;
|
||||
}
|
||||
case ipp16s:
|
||||
{
|
||||
Ipp16s val;
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMinIndx_16s_C1R, (const Ipp16s*)pSrc, srcStep, size, &val, &pMinIndex->x, &pMinIndex->y);
|
||||
*pMinVal = val;
|
||||
return status;
|
||||
}
|
||||
case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMinIndx_32f_C1R, (const Ipp32f*)pSrc, srcStep, size, pMinVal, &pMinIndex->x, &pMinIndex->y);
|
||||
default: return ipp_minMaxIndex_wrap(pSrc, srcStep, size, dataType, pMinVal, NULL, pMinIndex, NULL, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static IppStatus ipp_maxIdx_wrap(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
|
||||
float*, float* pMaxVal, IppiPoint*, IppiPoint* pMaxIndex, const Ipp8u*, int)
|
||||
{
|
||||
IppStatus status;
|
||||
|
||||
switch(dataType)
|
||||
{
|
||||
case ipp8u:
|
||||
{
|
||||
Ipp8u val;
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMaxIndx_8u_C1R, (const Ipp8u*)pSrc, srcStep, size, &val, &pMaxIndex->x, &pMaxIndex->y);
|
||||
*pMaxVal = val;
|
||||
return status;
|
||||
}
|
||||
case ipp16u:
|
||||
{
|
||||
Ipp16u val;
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMaxIndx_16u_C1R, (const Ipp16u*)pSrc, srcStep, size, &val, &pMaxIndex->x, &pMaxIndex->y);
|
||||
*pMaxVal = val;
|
||||
return status;
|
||||
}
|
||||
case ipp16s:
|
||||
{
|
||||
Ipp16s val;
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMaxIndx_16s_C1R, (const Ipp16s*)pSrc, srcStep, size, &val, &pMaxIndex->x, &pMaxIndex->y);
|
||||
*pMaxVal = val;
|
||||
return status;
|
||||
}
|
||||
case ipp32f: return CV_INSTRUMENT_FUN_IPP(ippiMaxIndx_32f_C1R, (const Ipp32f*)pSrc, srcStep, size, pMaxVal, &pMaxIndex->x, &pMaxIndex->y);
|
||||
default: return ipp_minMaxIndex_wrap(pSrc, srcStep, size, dataType, NULL, pMaxVal, NULL, pMaxIndex, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
typedef IppStatus (*IppMinMaxSelector)(const void* pSrc, int srcStep, IppiSize size, IppDataType dataType,
|
||||
float* pMinVal, float* pMaxVal, IppiPoint* pMinIndex, IppiPoint* pMaxIndex, const Ipp8u* pMask, int maskStep);
|
||||
|
||||
static bool ipp_minMaxIdx(Mat &src, double* _minVal, double* _maxVal, int* _minIdx, int* _maxIdx, Mat &mask)
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||
IppStatus status;
|
||||
IppDataType dataType = ippiGetDataType(src.depth());
|
||||
float minVal = 0;
|
||||
float maxVal = 0;
|
||||
IppiPoint minIdx = {-1, -1};
|
||||
IppiPoint maxIdx = {-1, -1};
|
||||
|
||||
float *pMinVal = (_minVal)?&minVal:NULL;
|
||||
float *pMaxVal = (_maxVal)?&maxVal:NULL;
|
||||
IppiPoint *pMinIdx = (_minIdx)?&minIdx:NULL;
|
||||
IppiPoint *pMaxIdx = (_maxIdx)?&maxIdx:NULL;
|
||||
|
||||
IppMinMaxSelector ippMinMaxFun = ipp_minMaxIndexMask_wrap;
|
||||
if(mask.empty())
|
||||
{
|
||||
IppiSize sz = { cols * cn, rows };
|
||||
if(_maxVal && _maxIdx && !_minVal && !_minIdx)
|
||||
ippMinMaxFun = ipp_maxIdx_wrap;
|
||||
else if(!_maxVal && !_maxIdx && _minVal && _minIdx)
|
||||
ippMinMaxFun = ipp_minIdx_wrap;
|
||||
else if(_maxVal && !_maxIdx && _minVal && !_minIdx)
|
||||
ippMinMaxFun = ipp_minMax_wrap;
|
||||
else
|
||||
ippMinMaxFun = ipp_minMaxIndex_wrap;
|
||||
}
|
||||
|
||||
if( !mask.empty() )
|
||||
if(src.dims <= 2)
|
||||
{
|
||||
IppiSize size = ippiSize(src.size());
|
||||
size.width *= src.channels();
|
||||
|
||||
status = ippMinMaxFun(src.ptr(), (int)src.step, size, dataType, pMinVal, pMaxVal, pMinIdx, pMaxIdx, (Ipp8u*)mask.ptr(), (int)mask.step);
|
||||
if(status < 0 || status == ippStsNoOperation)
|
||||
return false;
|
||||
if(_minVal)
|
||||
*_minVal = minVal;
|
||||
if(_maxVal)
|
||||
*_maxVal = maxVal;
|
||||
if(_minIdx)
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMinMaxIndxFuncC1)(const void *, int, const void *, int,
|
||||
IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *);
|
||||
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippiMaskMinMaxIndxFuncC1 ippiMinMaxIndx_C1MR =
|
||||
type == CV_8UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1MR : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if( ippiMinMaxIndx_C1MR )
|
||||
if(!mask.empty() && !minIdx.y && !minIdx.x)
|
||||
{
|
||||
Ipp32f min, max;
|
||||
IppiPoint minp, maxp;
|
||||
if( CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_C1MR, src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &min, &max, &minp, &maxp) >= 0 )
|
||||
{
|
||||
if( minVal )
|
||||
*minVal = (double)min;
|
||||
if( maxVal )
|
||||
*maxVal = (double)max;
|
||||
if( !minp.x && !minp.y && !maxp.x && !maxp.y && !mask.ptr()[0] )
|
||||
minp.x = maxp.x = -1;
|
||||
if( minIdx )
|
||||
{
|
||||
size_t minidx = minp.y * cols + minp.x + 1;
|
||||
ofs2idx(src, minidx, minIdx);
|
||||
}
|
||||
if( maxIdx )
|
||||
{
|
||||
size_t maxidx = maxp.y * cols + maxp.x + 1;
|
||||
ofs2idx(src, maxidx, maxIdx);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
_minIdx[0] = -1;
|
||||
_minIdx[1] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_minIdx[0] = minIdx.y;
|
||||
_minIdx[1] = minIdx.x;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(_maxIdx)
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMinMaxIndxFuncC1)(const void *, int, IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *);
|
||||
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippiMinMaxIndxFuncC1 ippiMinMaxIndx_C1R =
|
||||
#if IPP_VERSION_X100 != 900 // bug in 9.0.0 avx2 optimization
|
||||
depth == CV_8U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R :
|
||||
#endif
|
||||
#if IPP_VERSION_X100 < 900
|
||||
depth == CV_8S ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1R :
|
||||
#endif
|
||||
depth == CV_16U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1R :
|
||||
#if IPP_DISABLE_BLOCK && !((defined _MSC_VER && defined _M_IX86) || defined __i386__)
|
||||
// See bug #4955: the function fails with SEGFAULT when the source matrix contains NANs
|
||||
// IPPICV version is 9.0.1.
|
||||
depth == CV_32F ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1R :
|
||||
#endif
|
||||
0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if( ippiMinMaxIndx_C1R )
|
||||
if(!mask.empty() && !maxIdx.y && !maxIdx.x)
|
||||
{
|
||||
Ipp32f min, max;
|
||||
IppiPoint minp, maxp;
|
||||
if( CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_C1R, src.ptr(), (int)src.step[0], sz, &min, &max, &minp, &maxp) >= 0 )
|
||||
{
|
||||
if( minVal )
|
||||
*minVal = (double)min;
|
||||
if( maxVal )
|
||||
*maxVal = (double)max;
|
||||
if( minIdx )
|
||||
{
|
||||
size_t minidx = minp.y * cols + minp.x + 1;
|
||||
ofs2idx(src, minidx, minIdx);
|
||||
}
|
||||
if( maxIdx )
|
||||
{
|
||||
size_t maxidx = maxp.y * cols + maxp.x + 1;
|
||||
ofs2idx(src, maxidx, maxIdx);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
_maxIdx[0] = -1;
|
||||
_maxIdx[1] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_maxIdx[0] = maxIdx.y;
|
||||
_maxIdx[1] = maxIdx.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat *arrays[] = {&src, mask.empty()?NULL:&mask, NULL};
|
||||
uchar *ptrs[3] = {NULL};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
IppiSize size = ippiSize(it.size*src.channels(), 1);
|
||||
int srcStep = (int)(size.width*src.elemSize1());
|
||||
int maskStep = size.width;
|
||||
size_t idxPos = 1;
|
||||
size_t minIdxAll = 0;
|
||||
size_t maxIdxAll = 0;
|
||||
float minValAll = IPP_MAXABS_32F;
|
||||
float maxValAll = -IPP_MAXABS_32F;
|
||||
|
||||
for(size_t i = 0; i < it.nplanes; i++, ++it, idxPos += size.width)
|
||||
{
|
||||
status = ippMinMaxFun(ptrs[0], srcStep, size, dataType, pMinVal, pMaxVal, pMinIdx, pMaxIdx, ptrs[1], maskStep);
|
||||
if(status < 0)
|
||||
return false;
|
||||
#if IPP_VERSION_X100 > 201701
|
||||
// Zero-mask check, function should return ippStsNoOperation warning
|
||||
if(status == ippStsNoOperation)
|
||||
continue;
|
||||
#else
|
||||
// Crude zero-mask check, waiting for fix in IPP function
|
||||
if(ptrs[1])
|
||||
{
|
||||
Mat localMask(Size(size.width, 1), CV_8U, ptrs[1], maskStep);
|
||||
if(!cv::countNonZero(localMask))
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(_minVal && minVal < minValAll)
|
||||
{
|
||||
minValAll = minVal;
|
||||
minIdxAll = idxPos+minIdx.x;
|
||||
}
|
||||
if(_maxVal && maxVal > maxValAll)
|
||||
{
|
||||
maxValAll = maxVal;
|
||||
maxIdxAll = idxPos+maxIdx.x;
|
||||
}
|
||||
}
|
||||
if(!src.empty() && mask.empty())
|
||||
{
|
||||
if(minIdxAll == 0)
|
||||
minIdxAll = 1;
|
||||
if(maxValAll == 0)
|
||||
maxValAll = 1;
|
||||
}
|
||||
|
||||
if(_minVal)
|
||||
*_minVal = minValAll;
|
||||
if(_maxVal)
|
||||
*_maxVal = maxValAll;
|
||||
if(_minIdx)
|
||||
ofs2idx(src, minIdxAll, _minIdx);
|
||||
if(_maxIdx)
|
||||
ofs2idx(src, maxIdxAll, _maxIdx);
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
CV_UNUSED(src); CV_UNUSED(minVal); CV_UNUSED(maxVal); CV_UNUSED(minIdx); CV_UNUSED(maxIdx); CV_UNUSED(mask);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2499,7 +2684,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
||||
CV_OVX_RUN(true,
|
||||
openvx_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
|
||||
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
|
||||
CV_IPP_RUN_FAST(ipp_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
|
||||
|
||||
MinMaxIdxFunc func = getMinmaxTab(depth);
|
||||
CV_Assert( func != 0 );
|
||||
@@ -2837,42 +3022,31 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
int cn = src.channels();
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
|
||||
if( (src.dims == 2 || (src.isContinuous() && mask.isContinuous()))
|
||||
&& cols > 0 && (size_t)rows*cols == total_size
|
||||
&& (normType == NORM_INF || normType == NORM_L1 ||
|
||||
normType == NORM_L2 || normType == NORM_L2SQR) )
|
||||
&& cols > 0 && (size_t)rows*cols == total_size )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
if( !mask.empty() )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskNormFuncC1 ippiNorm_C1MR =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8s_C1MR :
|
||||
#endif
|
||||
// type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_16u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_32f_C1MR :
|
||||
0) : 0;
|
||||
@@ -2885,39 +3059,29 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#if IPP_DISABLE_BLOCK
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
|
||||
ippiMaskNormFuncC3 ippiNorm_C3CMR =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_8u_C3CMR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_8s_C3CMR :
|
||||
#endif
|
||||
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_32f_C3CMR :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_8u_C3CMR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_8s_C3CMR :
|
||||
#endif
|
||||
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_32f_C3CMR :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_8u_C3CMR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_8s_C3CMR :
|
||||
#endif
|
||||
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_32f_C3CMR :
|
||||
0) : 0;
|
||||
if( ippiNorm_C3CMR )
|
||||
{
|
||||
Ipp64f norm1, norm2, norm3;
|
||||
if( CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, (src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1)) >= 0 &&
|
||||
CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, (src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 2, &norm2)) >= 0 &&
|
||||
CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, (src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3)) >= 0)
|
||||
if( CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1) >= 0 &&
|
||||
CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 2, &norm2) >= 0 &&
|
||||
CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3) >= 0)
|
||||
{
|
||||
Ipp64f norm =
|
||||
normType == NORM_INF ? std::max(std::max(norm1, norm2), norm3) :
|
||||
@@ -2928,81 +3092,46 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
IppiSize sz = { cols*src.channels(), rows };
|
||||
int type = src.depth();
|
||||
|
||||
typedef IppStatus (CV_STDCALL* ippiNormFuncHint)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
|
||||
typedef IppStatus (CV_STDCALL* ippiNormFuncNoHint)(const void *, int, IppiSize, Ipp64f *);
|
||||
ippiNormFuncHint ippiNormHint =
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiNormFuncHint)ippiNorm_L1_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiNormFuncHint)ippiNorm_L1_32f_C4R :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L2_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiNormFuncHint)ippiNorm_L2_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiNormFuncHint)ippiNorm_L2_32f_C4R :
|
||||
0) : 0;
|
||||
ippiNormFuncNoHint ippiNorm =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C1R :
|
||||
#if (IPP_VERSION_X100 >= 810)
|
||||
type == CV_16SC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C3R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
|
||||
type == CV_16SC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_16s_C4R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
|
||||
#endif
|
||||
type == CV_32FC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiNormFuncNoHint)ippiNorm_Inf_32f_C4R :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiNormFuncNoHint)ippiNorm_L1_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiNormFuncNoHint)ippiNorm_L1_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiNormFuncNoHint)ippiNorm_L1_16s_C4R :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiNormFuncNoHint)ippiNorm_L2_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiNormFuncNoHint)ippiNorm_L2_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C4R :
|
||||
0) : 0;
|
||||
// Make sure only zero or one version of the function pointer is valid
|
||||
CV_Assert(!ippiNormHint || !ippiNorm);
|
||||
if( ippiNormHint || ippiNorm )
|
||||
{
|
||||
Ipp64f norm_array[4];
|
||||
IppStatus ret = ippiNormHint ? CV_INSTRUMENT_FUN_IPP(ippiNormHint, src.ptr(), (int)src.step[0], sz, norm_array, ippAlgHintAccurate) :
|
||||
CV_INSTRUMENT_FUN_IPP(ippiNorm, src.ptr(), (int)src.step[0], sz, norm_array);
|
||||
Ipp64f norm;
|
||||
IppStatus ret = ippiNormHint ? CV_INSTRUMENT_FUN_IPP(ippiNormHint, src.ptr(), (int)src.step[0], sz, &norm, ippAlgHintAccurate) :
|
||||
CV_INSTRUMENT_FUN_IPP(ippiNorm, src.ptr(), (int)src.step[0], sz, &norm);
|
||||
if( ret >= 0 )
|
||||
{
|
||||
Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0];
|
||||
for( int i = 1; i < cn; i++ )
|
||||
{
|
||||
norm =
|
||||
normType == NORM_INF ? std::max(norm, norm_array[i]) :
|
||||
normType == NORM_L1 ? norm + norm_array[i] :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
|
||||
0;
|
||||
}
|
||||
result = (normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm);
|
||||
result = (normType == NORM_L2SQR) ? norm * norm : norm;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3248,53 +3377,38 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
if( normType & CV_RELATIVE )
|
||||
{
|
||||
normType &= NORM_TYPE_MASK;
|
||||
CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR ||
|
||||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
|
||||
|
||||
size_t total_size = src1.total();
|
||||
int rows = src1.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
if( (src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous()))
|
||||
&& cols > 0 && (size_t)rows*cols == total_size
|
||||
&& (normType == NORM_INF || normType == NORM_L1 ||
|
||||
normType == NORM_L2 || normType == NORM_L2SQR) )
|
||||
&& cols > 0 && (size_t)rows*cols == total_size )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src1.type();
|
||||
if( !mask.empty() )
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskNormRelFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskNormRelFuncC1 ippiNormDiff_C1MR =
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src1.type();
|
||||
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskNormDiffFuncC1 ippiNormRel_C1MR =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
#ifndef __APPLE__
|
||||
type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8s_C1MR :
|
||||
#endif
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_32f_C1MR :
|
||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_Inf_8u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_Inf_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_Inf_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
#ifndef __APPLE__
|
||||
type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_8s_C1MR :
|
||||
#endif
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_32f_C1MR :
|
||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L1_8u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L1_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L1_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_32f_C1MR :
|
||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L2_8u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L2_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormRel_L2_32f_C1MR :
|
||||
0) : 0;
|
||||
if( ippiNormDiff_C1MR )
|
||||
if( ippiNormRel_C1MR )
|
||||
{
|
||||
Ipp64f norm;
|
||||
if( CV_INSTRUMENT_FUN_IPP(ippiNormDiff_C1MR, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], mask.ptr(), (int)mask.step[0], sz, &norm) >= 0 )
|
||||
if( CV_INSTRUMENT_FUN_IPP(ippiNormRel_C1MR, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], mask.ptr(), (int)mask.step[0], sz, &norm) >= 0 )
|
||||
{
|
||||
result = (normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm);
|
||||
return true;
|
||||
@@ -3303,47 +3417,43 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
IppiSize sz = { cols*src1.channels(), rows };
|
||||
int type = src1.depth();
|
||||
|
||||
typedef IppStatus (CV_STDCALL* ippiNormRelFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
|
||||
ippiNormRelFuncNoHint ippiNormDiff =
|
||||
typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiNormRelFuncHint ippiNormRelHint =
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_32F ? (ippiNormRelFuncHint)ippiNormRel_L1_32f_C1R :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_32F ? (ippiNormRelFuncHint)ippiNormRel_L2_32f_C1R :
|
||||
0) : 0;
|
||||
ippiNormRelFuncNoHint ippiNormRel =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_8u_C1R :
|
||||
type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16u_C1R :
|
||||
type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16s_C1R :
|
||||
type == CV_32FC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_32f_C1R :
|
||||
(type == CV_8U ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_8u_C1R :
|
||||
type == CV_16U ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16u_C1R :
|
||||
type == CV_16S ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16s_C1R :
|
||||
type == CV_32F ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_32f_C1R :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L1_8u_C1R :
|
||||
type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16u_C1R :
|
||||
type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16s_C1R :
|
||||
(type == CV_8U ? (ippiNormRelFuncNoHint)ippiNormRel_L1_8u_C1R :
|
||||
type == CV_16U ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16u_C1R :
|
||||
type == CV_16S ? (ippiNormRelFuncNoHint)ippiNormRel_L1_16s_C1R :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_8u_C1R :
|
||||
type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16u_C1R :
|
||||
type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16s_C1R :
|
||||
(type == CV_8U ? (ippiNormRelFuncNoHint)ippiNormRel_L2_8u_C1R :
|
||||
type == CV_16U ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16u_C1R :
|
||||
type == CV_16S ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16s_C1R :
|
||||
0) : 0;
|
||||
ippiNormRelFuncHint ippiNormDiffHint =
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L1_32f_C1R :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L2_32f_C1R :
|
||||
0) : 0;
|
||||
if (ippiNormDiff)
|
||||
if( ippiNormRelHint || ippiNormRel )
|
||||
{
|
||||
Ipp64f norm;
|
||||
if( CV_INSTRUMENT_FUN_IPP(ippiNormDiff, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm) >= 0 )
|
||||
IppStatus ret = ippiNormRelHint ? CV_INSTRUMENT_FUN_IPP(ippiNormRelHint, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm, ippAlgHintAccurate) :
|
||||
CV_INSTRUMENT_FUN_IPP(ippiNormRel, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm);
|
||||
if( ret >= 0 )
|
||||
{
|
||||
result = (double)norm;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (ippiNormDiffHint)
|
||||
{
|
||||
Ipp64f norm;
|
||||
if( CV_INSTRUMENT_FUN_IPP(ippiNormDiffHint, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm, ippAlgHintAccurate) >= 0 )
|
||||
{
|
||||
result = (double)norm;
|
||||
result = (normType == NORM_L2SQR) ? norm * norm : norm;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3352,47 +3462,32 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
return false;
|
||||
}
|
||||
|
||||
normType &= 7;
|
||||
CV_Assert( normType == NORM_INF || normType == NORM_L1 ||
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ||
|
||||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
|
||||
normType &= NORM_TYPE_MASK;
|
||||
|
||||
size_t total_size = src1.total();
|
||||
int rows = src1.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
if( (src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous()))
|
||||
&& cols > 0 && (size_t)rows*cols == total_size
|
||||
&& (normType == NORM_INF || normType == NORM_L1 ||
|
||||
normType == NORM_L2 || normType == NORM_L2SQR) )
|
||||
&& cols > 0 && (size_t)rows*cols == total_size )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src1.type();
|
||||
if( !mask.empty() )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src1.type();
|
||||
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskNormDiffFuncC1 ippiNormDiff_C1MR =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
#ifndef __APPLE__
|
||||
type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_8s_C1MR :
|
||||
#endif
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_32f_C1MR :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_8u_C1MR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_8s_C1MR :
|
||||
#endif
|
||||
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_32f_C1MR :
|
||||
0) : 0;
|
||||
@@ -3405,30 +3500,20 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#ifndef __APPLE__
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC3)(const void *, int, const void *, int, const void *, int, IppiSize, int, Ipp64f *);
|
||||
ippiMaskNormDiffFuncC3 ippiNormDiff_C3CMR =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8u_C3CMR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8s_C3CMR :
|
||||
#endif
|
||||
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_32f_C3CMR :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_8u_C3CMR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_8s_C3CMR :
|
||||
#endif
|
||||
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_32f_C3CMR :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_8u_C3CMR :
|
||||
#if IPP_VERSION_X100 < 900
|
||||
type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_8s_C3CMR :
|
||||
#endif
|
||||
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_32f_C3CMR :
|
||||
0) : 0;
|
||||
@@ -3448,83 +3533,46 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
IppiSize sz = { cols*src1.channels(), rows };
|
||||
int type = src1.depth();
|
||||
|
||||
typedef IppStatus (CV_STDCALL* ippiNormDiffFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
|
||||
typedef IppStatus (CV_STDCALL* ippiNormDiffFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiNormDiffFuncHint ippiNormDiffHint =
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_32FC1 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C4R :
|
||||
(type == CV_32F ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C1R :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_32FC1 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C4R :
|
||||
(type == CV_32F ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C1R :
|
||||
0) : 0;
|
||||
ippiNormDiffFuncNoHint ippiNormDiff =
|
||||
normType == NORM_INF ?
|
||||
(type == CV_8UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C1R :
|
||||
#if (IPP_VERSION_X100 >= 810)
|
||||
type == CV_16SC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C3R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
|
||||
type == CV_16SC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C4R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
|
||||
#endif
|
||||
type == CV_32FC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_32f_C4R :
|
||||
(type == CV_8U ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C1R :
|
||||
type == CV_16U ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16u_C1R :
|
||||
type == CV_16S ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_16s_C1R :
|
||||
type == CV_32F ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_32f_C1R :
|
||||
0) :
|
||||
normType == NORM_L1 ?
|
||||
(type == CV_8UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C4R :
|
||||
#if !(IPP_VERSION_X100 == 820 || IPP_VERSION_X100 == 821) // Oct 2014: Accuracy issue with IPP 8.2 / 8.2.1
|
||||
type == CV_16SC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C1R :
|
||||
#endif
|
||||
type == CV_16SC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C4R :
|
||||
(type == CV_8U ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_8u_C1R :
|
||||
type == CV_16U ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16u_C1R :
|
||||
type == CV_16S ? (ippiNormDiffFuncNoHint)ippiNormDiff_L1_16s_C1R :
|
||||
0) :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ?
|
||||
(type == CV_8UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C4R :
|
||||
(type == CV_8U ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_8u_C1R :
|
||||
type == CV_16U ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16u_C1R :
|
||||
type == CV_16S ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C1R :
|
||||
0) : 0;
|
||||
// Make sure only zero or one version of the function pointer is valid
|
||||
CV_Assert(!ippiNormDiffHint || !ippiNormDiff);
|
||||
if( ippiNormDiffHint || ippiNormDiff )
|
||||
{
|
||||
Ipp64f norm_array[4];
|
||||
IppStatus ret = ippiNormDiffHint ? CV_INSTRUMENT_FUN_IPP(ippiNormDiffHint, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, norm_array, ippAlgHintAccurate) :
|
||||
CV_INSTRUMENT_FUN_IPP(ippiNormDiff, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, norm_array);
|
||||
Ipp64f norm;
|
||||
IppStatus ret = ippiNormDiffHint ? CV_INSTRUMENT_FUN_IPP(ippiNormDiffHint, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm, ippAlgHintAccurate) :
|
||||
CV_INSTRUMENT_FUN_IPP(ippiNormDiff, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm);
|
||||
if( ret >= 0 )
|
||||
{
|
||||
Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0];
|
||||
for( int i = 1; i < src1.channels(); i++ )
|
||||
{
|
||||
norm =
|
||||
normType == NORM_INF ? std::max(norm, norm_array[i]) :
|
||||
normType == NORM_L1 ? norm + norm_array[i] :
|
||||
normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
|
||||
0;
|
||||
}
|
||||
result = (normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm);
|
||||
result = (normType == NORM_L2SQR) ? norm * norm : norm;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user