|
|
@ -1137,6 +1137,8 @@ static bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask |
|
|
|
#ifdef HAVE_IPP |
|
|
|
#ifdef HAVE_IPP |
|
|
|
static bool ipp_sum(Mat &src, Scalar &_res) |
|
|
|
static bool ipp_sum(Mat &src, Scalar &_res) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION_IPP() |
|
|
|
|
|
|
|
|
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
int cn = src.channels(); |
|
|
|
int cn = src.channels(); |
|
|
|
size_t total_size = src.total(); |
|
|
|
size_t total_size = src.total(); |
|
|
@ -1147,12 +1149,12 @@ static bool ipp_sum(Mat &src, Scalar &_res) |
|
|
|
int type = src.type(); |
|
|
|
int type = src.type(); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiSumFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiSumFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiSumFuncNoHint)(const void*, int, IppiSize, double *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiSumFuncNoHint)(const void*, int, IppiSize, double *); |
|
|
|
ippiSumFuncHint ippFuncHint = |
|
|
|
ippiSumFuncHint ippiSumHint = |
|
|
|
type == CV_32FC1 ? (ippiSumFuncHint)ippiSum_32f_C1R : |
|
|
|
type == CV_32FC1 ? (ippiSumFuncHint)ippiSum_32f_C1R : |
|
|
|
type == CV_32FC3 ? (ippiSumFuncHint)ippiSum_32f_C3R : |
|
|
|
type == CV_32FC3 ? (ippiSumFuncHint)ippiSum_32f_C3R : |
|
|
|
type == CV_32FC4 ? (ippiSumFuncHint)ippiSum_32f_C4R : |
|
|
|
type == CV_32FC4 ? (ippiSumFuncHint)ippiSum_32f_C4R : |
|
|
|
0; |
|
|
|
0; |
|
|
|
ippiSumFuncNoHint ippFuncNoHint = |
|
|
|
ippiSumFuncNoHint ippiSum = |
|
|
|
type == CV_8UC1 ? (ippiSumFuncNoHint)ippiSum_8u_C1R : |
|
|
|
type == CV_8UC1 ? (ippiSumFuncNoHint)ippiSum_8u_C1R : |
|
|
|
type == CV_8UC3 ? (ippiSumFuncNoHint)ippiSum_8u_C3R : |
|
|
|
type == CV_8UC3 ? (ippiSumFuncNoHint)ippiSum_8u_C3R : |
|
|
|
type == CV_8UC4 ? (ippiSumFuncNoHint)ippiSum_8u_C4R : |
|
|
|
type == CV_8UC4 ? (ippiSumFuncNoHint)ippiSum_8u_C4R : |
|
|
@ -1163,12 +1165,13 @@ static bool ipp_sum(Mat &src, Scalar &_res) |
|
|
|
type == CV_16SC3 ? (ippiSumFuncNoHint)ippiSum_16s_C3R : |
|
|
|
type == CV_16SC3 ? (ippiSumFuncNoHint)ippiSum_16s_C3R : |
|
|
|
type == CV_16SC4 ? (ippiSumFuncNoHint)ippiSum_16s_C4R : |
|
|
|
type == CV_16SC4 ? (ippiSumFuncNoHint)ippiSum_16s_C4R : |
|
|
|
0; |
|
|
|
0; |
|
|
|
CV_Assert(!ippFuncHint || !ippFuncNoHint); |
|
|
|
CV_Assert(!ippiSumHint || !ippiSum); |
|
|
|
if( ippFuncHint || ippFuncNoHint ) |
|
|
|
if( ippiSumHint || ippiSum ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f res[4]; |
|
|
|
Ipp64f res[4]; |
|
|
|
IppStatus ret = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) : |
|
|
|
IppStatus ret = ippiSumHint ? |
|
|
|
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, res); |
|
|
|
CV_INSTRUMENT_FUN_IPP(ippiSumHint, src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) : |
|
|
|
|
|
|
|
CV_INSTRUMENT_FUN_IPP(ippiSum, src.ptr(), (int)src.step[0], sz, res); |
|
|
|
if( ret >= 0 ) |
|
|
|
if( ret >= 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for( int i = 0; i < cn; i++ ) |
|
|
|
for( int i = 0; i < cn; i++ ) |
|
|
@ -1188,6 +1191,8 @@ static bool ipp_sum(Mat &src, Scalar &_res) |
|
|
|
|
|
|
|
|
|
|
|
cv::Scalar cv::sum( InputArray _src ) |
|
|
|
cv::Scalar cv::sum( InputArray _src ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
#if defined HAVE_OPENCL || defined HAVE_IPP |
|
|
|
#if defined HAVE_OPENCL || defined HAVE_IPP |
|
|
|
Scalar _res; |
|
|
|
Scalar _res; |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -1299,6 +1304,8 @@ namespace cv { |
|
|
|
|
|
|
|
|
|
|
|
static bool ipp_countNonZero( Mat &src, int &res ) |
|
|
|
static bool ipp_countNonZero( Mat &src, int &res ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION_IPP() |
|
|
|
|
|
|
|
|
|
|
|
Ipp32s count = 0; |
|
|
|
Ipp32s count = 0; |
|
|
|
IppStatus status = ippStsNoErr; |
|
|
|
IppStatus status = ippStsNoErr; |
|
|
|
|
|
|
|
|
|
|
@ -1313,9 +1320,9 @@ static bool ipp_countNonZero( Mat &src, int &res ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (depth == CV_8U) |
|
|
|
if (depth == CV_8U) |
|
|
|
status = ippiCountInRange_8u_C1R((const Ipp8u *)src.data, srcstep, roiSize, &count, 0, 0); |
|
|
|
status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_8u_C1R, (const Ipp8u *)src.data, srcstep, roiSize, &count, 0, 0); |
|
|
|
else if (depth == CV_32F) |
|
|
|
else if (depth == CV_32F) |
|
|
|
status = ippiCountInRange_32f_C1R((const Ipp32f *)src.data, srcstep, roiSize, &count, 0, 0); |
|
|
|
status = CV_INSTRUMENT_FUN_IPP(ippiCountInRange_32f_C1R, (const Ipp32f *)src.data, srcstep, roiSize, &count, 0, 0); |
|
|
|
|
|
|
|
|
|
|
|
if (status >= 0) |
|
|
|
if (status >= 0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1330,6 +1337,8 @@ static bool ipp_countNonZero( Mat &src, int &res ) |
|
|
|
|
|
|
|
|
|
|
|
int cv::countNonZero( InputArray _src ) |
|
|
|
int cv::countNonZero( InputArray _src ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
int type = _src.type(), cn = CV_MAT_CN(type); |
|
|
|
int type = _src.type(), cn = CV_MAT_CN(type); |
|
|
|
CV_Assert( cn == 1 ); |
|
|
|
CV_Assert( cn == 1 ); |
|
|
|
|
|
|
|
|
|
|
@ -1365,6 +1374,8 @@ namespace cv |
|
|
|
{ |
|
|
|
{ |
|
|
|
static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret ) |
|
|
|
static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION_IPP() |
|
|
|
|
|
|
|
|
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
size_t total_size = src.total(); |
|
|
|
size_t total_size = src.total(); |
|
|
|
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0; |
|
|
|
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0; |
|
|
@ -1375,32 +1386,32 @@ static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret ) |
|
|
|
if( !mask.empty() ) |
|
|
|
if( !mask.empty() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
ippiMaskMeanFuncC1 ippFuncC1 = |
|
|
|
ippiMaskMeanFuncC1 ippiMean_C1MR = |
|
|
|
type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR : |
|
|
|
type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR : |
|
|
|
type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR : |
|
|
|
type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR : |
|
|
|
type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR : |
|
|
|
type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR : |
|
|
|
0; |
|
|
|
0; |
|
|
|
if( ippFuncC1 ) |
|
|
|
if( ippiMean_C1MR ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f res; |
|
|
|
Ipp64f res; |
|
|
|
if( ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &res) >= 0 ) |
|
|
|
if( CV_INSTRUMENT_FUN_IPP(ippiMean_C1MR, src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &res) >= 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ret = Scalar(res); |
|
|
|
ret = Scalar(res); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *); |
|
|
|
ippiMaskMeanFuncC3 ippFuncC3 = |
|
|
|
ippiMaskMeanFuncC3 ippiMean_C3MR = |
|
|
|
type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR : |
|
|
|
type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR : |
|
|
|
type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR : |
|
|
|
type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR : |
|
|
|
type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR : |
|
|
|
type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR : |
|
|
|
0; |
|
|
|
0; |
|
|
|
if( ippFuncC3 ) |
|
|
|
if( ippiMean_C3MR ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f res1, res2, res3; |
|
|
|
Ipp64f res1, res2, res3; |
|
|
|
if( ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 1, &res1) >= 0 && |
|
|
|
if( CV_INSTRUMENT_FUN_IPP(ippiMean_C3MR, src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 1, &res1) >= 0 && |
|
|
|
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 2, &res2) >= 0 && |
|
|
|
CV_INSTRUMENT_FUN_IPP(ippiMean_C3MR, src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 2, &res2) >= 0 && |
|
|
|
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 3, &res3) >= 0 ) |
|
|
|
CV_INSTRUMENT_FUN_IPP(ippiMean_C3MR, src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 3, &res3) >= 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ret = Scalar(res1, res2, res3); |
|
|
|
ret = Scalar(res1, res2, res3); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -1411,12 +1422,12 @@ static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMeanFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMeanFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMeanFuncNoHint)(const void*, int, IppiSize, double *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMeanFuncNoHint)(const void*, int, IppiSize, double *); |
|
|
|
ippiMeanFuncHint ippFuncHint = |
|
|
|
ippiMeanFuncHint ippiMeanHint = |
|
|
|
type == CV_32FC1 ? (ippiMeanFuncHint)ippiMean_32f_C1R : |
|
|
|
type == CV_32FC1 ? (ippiMeanFuncHint)ippiMean_32f_C1R : |
|
|
|
type == CV_32FC3 ? (ippiMeanFuncHint)ippiMean_32f_C3R : |
|
|
|
type == CV_32FC3 ? (ippiMeanFuncHint)ippiMean_32f_C3R : |
|
|
|
type == CV_32FC4 ? (ippiMeanFuncHint)ippiMean_32f_C4R : |
|
|
|
type == CV_32FC4 ? (ippiMeanFuncHint)ippiMean_32f_C4R : |
|
|
|
0; |
|
|
|
0; |
|
|
|
ippiMeanFuncNoHint ippFuncNoHint = |
|
|
|
ippiMeanFuncNoHint ippiMean = |
|
|
|
type == CV_8UC1 ? (ippiMeanFuncNoHint)ippiMean_8u_C1R : |
|
|
|
type == CV_8UC1 ? (ippiMeanFuncNoHint)ippiMean_8u_C1R : |
|
|
|
type == CV_8UC3 ? (ippiMeanFuncNoHint)ippiMean_8u_C3R : |
|
|
|
type == CV_8UC3 ? (ippiMeanFuncNoHint)ippiMean_8u_C3R : |
|
|
|
type == CV_8UC4 ? (ippiMeanFuncNoHint)ippiMean_8u_C4R : |
|
|
|
type == CV_8UC4 ? (ippiMeanFuncNoHint)ippiMean_8u_C4R : |
|
|
@ -1428,12 +1439,12 @@ static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret ) |
|
|
|
type == CV_16SC4 ? (ippiMeanFuncNoHint)ippiMean_16s_C4R : |
|
|
|
type == CV_16SC4 ? (ippiMeanFuncNoHint)ippiMean_16s_C4R : |
|
|
|
0; |
|
|
|
0; |
|
|
|
// Make sure only zero or one version of the function pointer is valid
|
|
|
|
// Make sure only zero or one version of the function pointer is valid
|
|
|
|
CV_Assert(!ippFuncHint || !ippFuncNoHint); |
|
|
|
CV_Assert(!ippiMeanHint || !ippiMean); |
|
|
|
if( ippFuncHint || ippFuncNoHint ) |
|
|
|
if( ippiMeanHint || ippiMean ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f res[4]; |
|
|
|
Ipp64f res[4]; |
|
|
|
IppStatus status = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) : |
|
|
|
IppStatus status = ippiMeanHint ? CV_INSTRUMENT_FUN_IPP(ippiMeanHint, src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) : |
|
|
|
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, res); |
|
|
|
CV_INSTRUMENT_FUN_IPP(ippiMean, src.ptr(), (int)src.step[0], sz, res); |
|
|
|
if( status >= 0 ) |
|
|
|
if( status >= 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for( int i = 0; i < src.channels(); i++ ) |
|
|
|
for( int i = 0; i < src.channels(); i++ ) |
|
|
@ -1453,6 +1464,8 @@ static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret ) |
|
|
|
|
|
|
|
|
|
|
|
cv::Scalar cv::mean( InputArray _src, InputArray _mask ) |
|
|
|
cv::Scalar cv::mean( InputArray _src, InputArray _mask ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(), mask = _mask.getMat(); |
|
|
|
Mat src = _src.getMat(), mask = _mask.getMat(); |
|
|
|
CV_Assert( mask.empty() || mask.type() == CV_8U ); |
|
|
|
CV_Assert( mask.empty() || mask.type() == CV_8U ); |
|
|
|
|
|
|
|
|
|
|
@ -2216,6 +2229,8 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* |
|
|
|
#ifdef HAVE_IPP |
|
|
|
#ifdef HAVE_IPP |
|
|
|
static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, Mat &mask) |
|
|
|
static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, Mat &mask) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION_IPP() |
|
|
|
|
|
|
|
|
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); |
|
|
|
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); |
|
|
|
size_t total_size = src.total(); |
|
|
|
size_t total_size = src.total(); |
|
|
@ -2230,7 +2245,7 @@ static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx |
|
|
|
IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *); |
|
|
|
IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *); |
|
|
|
|
|
|
|
|
|
|
|
CV_SUPPRESS_DEPRECATED_START |
|
|
|
CV_SUPPRESS_DEPRECATED_START |
|
|
|
ippiMaskMinMaxIndxFuncC1 ippFuncC1 = |
|
|
|
ippiMaskMinMaxIndxFuncC1 ippiMinMaxIndx_C1MR = |
|
|
|
type == CV_8UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1MR : |
|
|
|
type == CV_8UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1MR : |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
|
type == CV_8SC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1MR : |
|
|
|
type == CV_8SC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1MR : |
|
|
@ -2239,11 +2254,11 @@ static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx |
|
|
|
type == CV_32FC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1MR : 0; |
|
|
|
type == CV_32FC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1MR : 0; |
|
|
|
CV_SUPPRESS_DEPRECATED_END |
|
|
|
CV_SUPPRESS_DEPRECATED_END |
|
|
|
|
|
|
|
|
|
|
|
if( ippFuncC1 ) |
|
|
|
if( ippiMinMaxIndx_C1MR ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp32f min, max; |
|
|
|
Ipp32f min, max; |
|
|
|
IppiPoint minp, maxp; |
|
|
|
IppiPoint minp, maxp; |
|
|
|
if( ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &min, &max, &minp, &maxp) >= 0 ) |
|
|
|
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 ) |
|
|
|
if( minVal ) |
|
|
|
*minVal = (double)min; |
|
|
|
*minVal = (double)min; |
|
|
@ -2270,7 +2285,7 @@ static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMinMaxIndxFuncC1)(const void *, int, IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMinMaxIndxFuncC1)(const void *, int, IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *); |
|
|
|
|
|
|
|
|
|
|
|
CV_SUPPRESS_DEPRECATED_START |
|
|
|
CV_SUPPRESS_DEPRECATED_START |
|
|
|
ippiMinMaxIndxFuncC1 ippFuncC1 = |
|
|
|
ippiMinMaxIndxFuncC1 ippiMinMaxIndx_C1R = |
|
|
|
#if IPP_VERSION_X100 != 900 // bug in 9.0.0 avx2 optimization
|
|
|
|
#if IPP_VERSION_X100 != 900 // bug in 9.0.0 avx2 optimization
|
|
|
|
depth == CV_8U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R : |
|
|
|
depth == CV_8U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R : |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -2286,11 +2301,11 @@ static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx |
|
|
|
0; |
|
|
|
0; |
|
|
|
CV_SUPPRESS_DEPRECATED_END |
|
|
|
CV_SUPPRESS_DEPRECATED_END |
|
|
|
|
|
|
|
|
|
|
|
if( ippFuncC1 ) |
|
|
|
if( ippiMinMaxIndx_C1R ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp32f min, max; |
|
|
|
Ipp32f min, max; |
|
|
|
IppiPoint minp, maxp; |
|
|
|
IppiPoint minp, maxp; |
|
|
|
if( ippFuncC1(src.ptr(), (int)src.step[0], sz, &min, &max, &minp, &maxp) >= 0 ) |
|
|
|
if( CV_INSTRUMENT_FUN_IPP(ippiMinMaxIndx_C1R, src.ptr(), (int)src.step[0], sz, &min, &max, &minp, &maxp) >= 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( minVal ) |
|
|
|
if( minVal ) |
|
|
|
*minVal = (double)min; |
|
|
|
*minVal = (double)min; |
|
|
@ -2324,6 +2339,8 @@ void cv::minMaxIdx(InputArray _src, double* minVal, |
|
|
|
double* maxVal, int* minIdx, int* maxIdx, |
|
|
|
double* maxVal, int* minIdx, int* maxIdx, |
|
|
|
InputArray _mask) |
|
|
|
InputArray _mask) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); |
|
|
|
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); |
|
|
|
CV_Assert( (cn == 1 && (_mask.empty() || _mask.type() == CV_8U)) || |
|
|
|
CV_Assert( (cn == 1 && (_mask.empty() || _mask.type() == CV_8U)) || |
|
|
|
(cn > 1 && _mask.empty() && !minIdx && !maxIdx) ); |
|
|
|
(cn > 1 && _mask.empty() && !minIdx && !maxIdx) ); |
|
|
@ -2386,6 +2403,8 @@ void cv::minMaxIdx(InputArray _src, double* minVal, |
|
|
|
void cv::minMaxLoc( InputArray _img, double* minVal, double* maxVal, |
|
|
|
void cv::minMaxLoc( InputArray _img, double* minVal, double* maxVal, |
|
|
|
Point* minLoc, Point* maxLoc, InputArray mask ) |
|
|
|
Point* minLoc, Point* maxLoc, InputArray mask ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
CV_Assert(_img.dims() <= 2); |
|
|
|
CV_Assert(_img.dims() <= 2); |
|
|
|
|
|
|
|
|
|
|
|
minMaxIdx(_img, minVal, maxVal, (int*)minLoc, (int*)maxLoc, mask); |
|
|
|
minMaxIdx(_img, minVal, maxVal, (int*)minLoc, (int*)maxLoc, mask); |
|
|
@ -2665,6 +2684,8 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double & |
|
|
|
#ifdef HAVE_IPP |
|
|
|
#ifdef HAVE_IPP |
|
|
|
static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION_IPP() |
|
|
|
|
|
|
|
|
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
int cn = src.channels(); |
|
|
|
int cn = src.channels(); |
|
|
|
size_t total_size = src.total(); |
|
|
|
size_t total_size = src.total(); |
|
|
@ -2680,7 +2701,7 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
if( !mask.empty() ) |
|
|
|
if( !mask.empty() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
ippiMaskNormFuncC1 ippFuncC1 = |
|
|
|
ippiMaskNormFuncC1 ippiNorm_C1MR = |
|
|
|
normType == NORM_INF ? |
|
|
|
normType == NORM_INF ? |
|
|
|
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8u_C1MR : |
|
|
|
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8u_C1MR : |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
@ -2705,10 +2726,10 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_16u_C1MR : |
|
|
|
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_16u_C1MR : |
|
|
|
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_32f_C1MR : |
|
|
|
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_32f_C1MR : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
if( ippFuncC1 ) |
|
|
|
if( ippiNorm_C1MR ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm; |
|
|
|
Ipp64f norm; |
|
|
|
if( ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &norm) >= 0 ) |
|
|
|
if( CV_INSTRUMENT_FUN_IPP(ippiNorm_C1MR, src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &norm) >= 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
result = (normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm); |
|
|
|
result = (normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -2716,7 +2737,7 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
} |
|
|
|
} |
|
|
|
#if IPP_DISABLE_BLOCK |
|
|
|
#if IPP_DISABLE_BLOCK |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *); |
|
|
|
ippiMaskNormFuncC3 ippFuncC3 = |
|
|
|
ippiMaskNormFuncC3 ippiNorm_C3CMR = |
|
|
|
normType == NORM_INF ? |
|
|
|
normType == NORM_INF ? |
|
|
|
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_8u_C3CMR : |
|
|
|
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_8u_C3CMR : |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
@ -2741,12 +2762,12 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_16u_C3CMR : |
|
|
|
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_16u_C3CMR : |
|
|
|
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_32f_C3CMR : |
|
|
|
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_32f_C3CMR : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
if( ippFuncC3 ) |
|
|
|
if( ippiNorm_C3CMR ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm1, norm2, norm3; |
|
|
|
Ipp64f norm1, norm2, norm3; |
|
|
|
if( ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1) >= 0 && |
|
|
|
if( CV_INSTRUMENT_FUN_IPP(ippiNorm_C3CMR, (src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1)) >= 0 && |
|
|
|
ippFuncC3(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, 2, &norm2)) >= 0 && |
|
|
|
ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3) >= 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 = |
|
|
|
Ipp64f norm = |
|
|
|
normType == NORM_INF ? std::max(std::max(norm1, norm2), norm3) : |
|
|
|
normType == NORM_INF ? std::max(std::max(norm1, norm2), norm3) : |
|
|
@ -2763,7 +2784,7 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
{ |
|
|
|
{ |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormFuncHint)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormFuncHint)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormFuncNoHint)(const void *, int, IppiSize, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormFuncNoHint)(const void *, int, IppiSize, Ipp64f *); |
|
|
|
ippiNormFuncHint ippFuncHint = |
|
|
|
ippiNormFuncHint ippiNormHint = |
|
|
|
normType == NORM_L1 ? |
|
|
|
normType == NORM_L1 ? |
|
|
|
(type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R : |
|
|
|
(type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R : |
|
|
|
type == CV_32FC3 ? (ippiNormFuncHint)ippiNorm_L1_32f_C3R : |
|
|
|
type == CV_32FC3 ? (ippiNormFuncHint)ippiNorm_L1_32f_C3R : |
|
|
@ -2774,7 +2795,7 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
type == CV_32FC3 ? (ippiNormFuncHint)ippiNorm_L2_32f_C3R : |
|
|
|
type == CV_32FC3 ? (ippiNormFuncHint)ippiNorm_L2_32f_C3R : |
|
|
|
type == CV_32FC4 ? (ippiNormFuncHint)ippiNorm_L2_32f_C4R : |
|
|
|
type == CV_32FC4 ? (ippiNormFuncHint)ippiNorm_L2_32f_C4R : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
ippiNormFuncNoHint ippFuncNoHint = |
|
|
|
ippiNormFuncNoHint ippiNorm = |
|
|
|
normType == NORM_INF ? |
|
|
|
normType == NORM_INF ? |
|
|
|
(type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C1R : |
|
|
|
(type == CV_8UC1 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C1R : |
|
|
|
type == CV_8UC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C3R : |
|
|
|
type == CV_8UC3 ? (ippiNormFuncNoHint)ippiNorm_Inf_8u_C3R : |
|
|
@ -2814,12 +2835,12 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
type == CV_16SC4 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C4R : |
|
|
|
type == CV_16SC4 ? (ippiNormFuncNoHint)ippiNorm_L2_16s_C4R : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
// Make sure only zero or one version of the function pointer is valid
|
|
|
|
// Make sure only zero or one version of the function pointer is valid
|
|
|
|
CV_Assert(!ippFuncHint || !ippFuncNoHint); |
|
|
|
CV_Assert(!ippiNormHint || !ippiNorm); |
|
|
|
if( ippFuncHint || ippFuncNoHint ) |
|
|
|
if( ippiNormHint || ippiNorm ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm_array[4]; |
|
|
|
Ipp64f norm_array[4]; |
|
|
|
IppStatus ret = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, norm_array, ippAlgHintAccurate) : |
|
|
|
IppStatus ret = ippiNormHint ? CV_INSTRUMENT_FUN_IPP(ippiNormHint, src.ptr(), (int)src.step[0], sz, norm_array, ippAlgHintAccurate) : |
|
|
|
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, norm_array); |
|
|
|
CV_INSTRUMENT_FUN_IPP(ippiNorm, src.ptr(), (int)src.step[0], sz, norm_array); |
|
|
|
if( ret >= 0 ) |
|
|
|
if( ret >= 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0]; |
|
|
|
Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0]; |
|
|
@ -2847,6 +2868,8 @@ static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result) |
|
|
|
|
|
|
|
|
|
|
|
double cv::norm( InputArray _src, int normType, InputArray _mask ) |
|
|
|
double cv::norm( InputArray _src, int normType, InputArray _mask ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
normType &= NORM_TYPE_MASK; |
|
|
|
normType &= NORM_TYPE_MASK; |
|
|
|
CV_Assert( normType == NORM_INF || normType == NORM_L1 || |
|
|
|
CV_Assert( normType == NORM_INF || normType == NORM_L1 || |
|
|
|
normType == NORM_L2 || normType == NORM_L2SQR || |
|
|
|
normType == NORM_L2 || normType == NORM_L2SQR || |
|
|
@ -3067,6 +3090,8 @@ namespace cv |
|
|
|
{ |
|
|
|
{ |
|
|
|
static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask, double &result) |
|
|
|
static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask, double &result) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION_IPP() |
|
|
|
|
|
|
|
|
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
#if IPP_VERSION_X100 >= 700 |
|
|
|
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); |
|
|
|
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
|
@ -3087,7 +3112,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
if( !mask.empty() ) |
|
|
|
if( !mask.empty() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormRelFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormRelFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
ippiMaskNormRelFuncC1 ippFuncC1 = |
|
|
|
ippiMaskNormRelFuncC1 ippiNormDiff_C1MR = |
|
|
|
normType == NORM_INF ? |
|
|
|
normType == NORM_INF ? |
|
|
|
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8u_C1MR : |
|
|
|
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8u_C1MR : |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
@ -3116,10 +3141,10 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_16u_C1MR : |
|
|
|
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_16u_C1MR : |
|
|
|
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_32f_C1MR : |
|
|
|
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_32f_C1MR : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
if( ippFuncC1 ) |
|
|
|
if( ippiNormDiff_C1MR ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm; |
|
|
|
Ipp64f norm; |
|
|
|
if( ippFuncC1(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(ippiNormDiff_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); |
|
|
|
result = (normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -3130,7 +3155,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
{ |
|
|
|
{ |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormRelFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormRelFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormRelFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); |
|
|
|
ippiNormRelFuncNoHint ippFuncNoHint = |
|
|
|
ippiNormRelFuncNoHint ippiNormDiff = |
|
|
|
normType == NORM_INF ? |
|
|
|
normType == NORM_INF ? |
|
|
|
(type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_8u_C1R : |
|
|
|
(type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_8u_C1R : |
|
|
|
type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16u_C1R : |
|
|
|
type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_16u_C1R : |
|
|
@ -3147,26 +3172,26 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16u_C1R : |
|
|
|
type == CV_16UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16u_C1R : |
|
|
|
type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16s_C1R : |
|
|
|
type == CV_16SC1 ? (ippiNormRelFuncNoHint)ippiNormRel_L2_16s_C1R : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
ippiNormRelFuncHint ippFuncHint = |
|
|
|
ippiNormRelFuncHint ippiNormDiffHint = |
|
|
|
normType == NORM_L1 ? |
|
|
|
normType == NORM_L1 ? |
|
|
|
(type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L1_32f_C1R : |
|
|
|
(type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L1_32f_C1R : |
|
|
|
0) : |
|
|
|
0) : |
|
|
|
normType == NORM_L2 || normType == NORM_L2SQR ? |
|
|
|
normType == NORM_L2 || normType == NORM_L2SQR ? |
|
|
|
(type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L2_32f_C1R : |
|
|
|
(type == CV_32FC1 ? (ippiNormRelFuncHint)ippiNormRel_L2_32f_C1R : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
if (ippFuncNoHint) |
|
|
|
if (ippiNormDiff) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm; |
|
|
|
Ipp64f norm; |
|
|
|
if( ippFuncNoHint(src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm) >= 0 ) |
|
|
|
if( CV_INSTRUMENT_FUN_IPP(ippiNormDiff, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm) >= 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
result = (double)norm; |
|
|
|
result = (double)norm; |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (ippFuncHint) |
|
|
|
if (ippiNormDiffHint) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm; |
|
|
|
Ipp64f norm; |
|
|
|
if( ippFuncHint(src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm, ippAlgHintAccurate) >= 0 ) |
|
|
|
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 = (double)norm; |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -3194,7 +3219,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
if( !mask.empty() ) |
|
|
|
if( !mask.empty() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
ippiMaskNormDiffFuncC1 ippFuncC1 = |
|
|
|
ippiMaskNormDiffFuncC1 ippiNormDiff_C1MR = |
|
|
|
normType == NORM_INF ? |
|
|
|
normType == NORM_INF ? |
|
|
|
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8u_C1MR : |
|
|
|
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8u_C1MR : |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
@ -3221,10 +3246,10 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_16u_C1MR : |
|
|
|
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_16u_C1MR : |
|
|
|
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_32f_C1MR : |
|
|
|
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_32f_C1MR : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
if( ippFuncC1 ) |
|
|
|
if( ippiNormDiff_C1MR ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm; |
|
|
|
Ipp64f norm; |
|
|
|
if( ippFuncC1(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(ippiNormDiff_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); |
|
|
|
result = (normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm); |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -3232,7 +3257,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
} |
|
|
|
} |
|
|
|
#ifndef __APPLE__ |
|
|
|
#ifndef __APPLE__ |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC3)(const void *, int, const void *, int, const void *, int, IppiSize, int, Ipp64f *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC3)(const void *, int, const void *, int, const void *, int, IppiSize, int, Ipp64f *); |
|
|
|
ippiMaskNormDiffFuncC3 ippFuncC3 = |
|
|
|
ippiMaskNormDiffFuncC3 ippiNormDiff_C3CMR = |
|
|
|
normType == NORM_INF ? |
|
|
|
normType == NORM_INF ? |
|
|
|
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8u_C3CMR : |
|
|
|
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8u_C3CMR : |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
|
#if IPP_VERSION_X100 < 900 |
|
|
@ -3257,12 +3282,12 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_16u_C3CMR : |
|
|
|
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_16u_C3CMR : |
|
|
|
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_32f_C3CMR : |
|
|
|
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_32f_C3CMR : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
if( ippFuncC3 ) |
|
|
|
if( ippiNormDiff_C3CMR ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm1, norm2, norm3; |
|
|
|
Ipp64f norm1, norm2, norm3; |
|
|
|
if( ippFuncC3(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1) >= 0 && |
|
|
|
if( CV_INSTRUMENT_FUN_IPP(ippiNormDiff_C3CMR, src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1) >= 0 && |
|
|
|
ippFuncC3(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 2, &norm2) >= 0 && |
|
|
|
CV_INSTRUMENT_FUN_IPP(ippiNormDiff_C3CMR, src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 2, &norm2) >= 0 && |
|
|
|
ippFuncC3(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3) >= 0) |
|
|
|
CV_INSTRUMENT_FUN_IPP(ippiNormDiff_C3CMR, src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3) >= 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm = |
|
|
|
Ipp64f norm = |
|
|
|
normType == NORM_INF ? std::max(std::max(norm1, norm2), norm3) : |
|
|
|
normType == NORM_INF ? std::max(std::max(norm1, norm2), norm3) : |
|
|
@ -3279,7 +3304,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
{ |
|
|
|
{ |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormDiffFuncHint)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint); |
|
|
|
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 *); |
|
|
|
typedef IppStatus (CV_STDCALL* ippiNormDiffFuncNoHint)(const void *, int, const void *, int, IppiSize, Ipp64f *); |
|
|
|
ippiNormDiffFuncHint ippFuncHint = |
|
|
|
ippiNormDiffFuncHint ippiNormDiffHint = |
|
|
|
normType == NORM_L1 ? |
|
|
|
normType == NORM_L1 ? |
|
|
|
(type == CV_32FC1 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C1R : |
|
|
|
(type == CV_32FC1 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C1R : |
|
|
|
type == CV_32FC3 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C3R : |
|
|
|
type == CV_32FC3 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C3R : |
|
|
@ -3290,7 +3315,7 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
type == CV_32FC3 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C3R : |
|
|
|
type == CV_32FC3 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C3R : |
|
|
|
type == CV_32FC4 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C4R : |
|
|
|
type == CV_32FC4 ? (ippiNormDiffFuncHint)ippiNormDiff_L2_32f_C4R : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
ippiNormDiffFuncNoHint ippFuncNoHint = |
|
|
|
ippiNormDiffFuncNoHint ippiNormDiff = |
|
|
|
normType == NORM_INF ? |
|
|
|
normType == NORM_INF ? |
|
|
|
(type == CV_8UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C1R : |
|
|
|
(type == CV_8UC1 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C1R : |
|
|
|
type == CV_8UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C3R : |
|
|
|
type == CV_8UC3 ? (ippiNormDiffFuncNoHint)ippiNormDiff_Inf_8u_C3R : |
|
|
@ -3332,12 +3357,12 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
type == CV_16SC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C4R : |
|
|
|
type == CV_16SC4 ? (ippiNormDiffFuncNoHint)ippiNormDiff_L2_16s_C4R : |
|
|
|
0) : 0; |
|
|
|
0) : 0; |
|
|
|
// Make sure only zero or one version of the function pointer is valid
|
|
|
|
// Make sure only zero or one version of the function pointer is valid
|
|
|
|
CV_Assert(!ippFuncHint || !ippFuncNoHint); |
|
|
|
CV_Assert(!ippiNormDiffHint || !ippiNormDiff); |
|
|
|
if( ippFuncHint || ippFuncNoHint ) |
|
|
|
if( ippiNormDiffHint || ippiNormDiff ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm_array[4]; |
|
|
|
Ipp64f norm_array[4]; |
|
|
|
IppStatus ret = ippFuncHint ? ippFuncHint(src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, norm_array, ippAlgHintAccurate) : |
|
|
|
IppStatus ret = ippiNormDiffHint ? CV_INSTRUMENT_FUN_IPP(ippiNormDiffHint, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, norm_array, ippAlgHintAccurate) : |
|
|
|
ippFuncNoHint(src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, norm_array); |
|
|
|
CV_INSTRUMENT_FUN_IPP(ippiNormDiff, src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, norm_array); |
|
|
|
if( ret >= 0 ) |
|
|
|
if( ret >= 0 ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0]; |
|
|
|
Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0]; |
|
|
@ -3366,6 +3391,8 @@ static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArra |
|
|
|
|
|
|
|
|
|
|
|
double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask ) |
|
|
|
double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
CV_Assert( _src1.sameSize(_src2) && _src1.type() == _src2.type() ); |
|
|
|
CV_Assert( _src1.sameSize(_src2) && _src1.type() == _src2.type() ); |
|
|
|
|
|
|
|
|
|
|
|
#if defined HAVE_OPENCL || defined HAVE_IPP |
|
|
|
#if defined HAVE_OPENCL || defined HAVE_IPP |
|
|
@ -3750,6 +3777,8 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, |
|
|
|
int normType, int K, InputArray _mask, |
|
|
|
int normType, int K, InputArray _mask, |
|
|
|
int update, bool crosscheck ) |
|
|
|
int update, bool crosscheck ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); |
|
|
|
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); |
|
|
|
int type = src1.type(); |
|
|
|
int type = src1.type(); |
|
|
|
CV_Assert( type == src2.type() && src1.cols == src2.cols && |
|
|
|
CV_Assert( type == src2.type() && src1.cols == src2.cols && |
|
|
@ -3859,6 +3888,8 @@ void cv::batchDistance( InputArray _src1, InputArray _src2, |
|
|
|
|
|
|
|
|
|
|
|
void cv::findNonZero( InputArray _src, OutputArray _idx ) |
|
|
|
void cv::findNonZero( InputArray _src, OutputArray _idx ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(); |
|
|
|
Mat src = _src.getMat(); |
|
|
|
CV_Assert( src.type() == CV_8UC1 ); |
|
|
|
CV_Assert( src.type() == CV_8UC1 ); |
|
|
|
int n = countNonZero(src); |
|
|
|
int n = countNonZero(src); |
|
|
@ -3885,6 +3916,8 @@ void cv::findNonZero( InputArray _src, OutputArray _idx ) |
|
|
|
|
|
|
|
|
|
|
|
double cv::PSNR(InputArray _src1, InputArray _src2) |
|
|
|
double cv::PSNR(InputArray _src1, InputArray _src2) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
CV_INSTRUMENT_REGION() |
|
|
|
|
|
|
|
|
|
|
|
CV_Assert( _src1.depth() == CV_8U ); |
|
|
|
CV_Assert( _src1.depth() == CV_8U ); |
|
|
|
double diff = std::sqrt(norm(_src1, _src2, NORM_L2SQR)/(_src1.total()*_src1.channels())); |
|
|
|
double diff = std::sqrt(norm(_src1, _src2, NORM_L2SQR)/(_src1.total()*_src1.channels())); |
|
|
|
return 20*log10(255./(diff+DBL_EPSILON)); |
|
|
|
return 20*log10(255./(diff+DBL_EPSILON)); |
|
|
|