Imgproc_Hist_MinMaxVal.accuracy fix;
Some code style corrections;
This commit is contained in:
parent
a5a21019b2
commit
101607a7d0
@ -5194,10 +5194,7 @@ dtype* dst, size_t dstep, Size size, double* scale) \
|
|||||||
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
|
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
|
||||||
dtype* dst, size_t dstep, Size size, double*) \
|
dtype* dst, size_t dstep, Size size, double*) \
|
||||||
{ \
|
{ \
|
||||||
if (src && dst)\
|
CV_IPP_RUN(src && dst, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0)\
|
||||||
{\
|
|
||||||
CV_IPP_RUN(true, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0)\
|
|
||||||
}\
|
|
||||||
cvt_(src, sstep, dst, dstep, size); \
|
cvt_(src, sstep, dst, dstep, size); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5205,10 +5202,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
|
|||||||
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
|
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
|
||||||
dtype* dst, size_t dstep, Size size, double*) \
|
dtype* dst, size_t dstep, Size size, double*) \
|
||||||
{ \
|
{ \
|
||||||
if (src && dst)\
|
CV_IPP_RUN(src && dst, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0)\
|
||||||
{\
|
|
||||||
CV_IPP_RUN(true, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0)\
|
|
||||||
}\
|
|
||||||
cvt_(src, sstep, dst, dstep, size); \
|
cvt_(src, sstep, dst, dstep, size); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -5844,6 +5838,46 @@ private:
|
|||||||
IppLUTParallelBody_LUTCN& operator=(const IppLUTParallelBody_LUTCN&);
|
IppLUTParallelBody_LUTCN& operator=(const IppLUTParallelBody_LUTCN&);
|
||||||
};
|
};
|
||||||
} // namespace ipp
|
} // namespace ipp
|
||||||
|
|
||||||
|
static bool ipp_lut(Mat &src, Mat &lut, Mat &dst)
|
||||||
|
{
|
||||||
|
int cn = src.channels();
|
||||||
|
int lutcn = lut.channels();
|
||||||
|
|
||||||
|
if(src.dims > 2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool ok = false;
|
||||||
|
Ptr<ParallelLoopBody> body;
|
||||||
|
|
||||||
|
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
|
||||||
|
#if 0 // there are no performance benefits (PR #2653)
|
||||||
|
if (lutcn == 1)
|
||||||
|
{
|
||||||
|
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
|
||||||
|
body.reset(p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
|
||||||
|
{
|
||||||
|
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
|
||||||
|
body.reset(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body != NULL && ok)
|
||||||
|
{
|
||||||
|
Range all(0, dst.rows);
|
||||||
|
if (dst.total()>>18)
|
||||||
|
parallel_for_(all, *body, (double)std::max((size_t)1, dst.total()>>16));
|
||||||
|
else
|
||||||
|
(*body)(all);
|
||||||
|
if (ok)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endif // IPP
|
#endif // IPP
|
||||||
|
|
||||||
class LUTParallelBody : public ParallelLoopBody
|
class LUTParallelBody : public ParallelLoopBody
|
||||||
@ -5891,55 +5925,6 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace cv
|
|
||||||
{
|
|
||||||
#if defined(HAVE_IPP)
|
|
||||||
static bool ipp_lut(InputArray _src, InputArray _lut, OutputArray _dst)
|
|
||||||
{
|
|
||||||
int cn = _src.channels();
|
|
||||||
int lutcn = _lut.channels();
|
|
||||||
|
|
||||||
Mat src = _src.getMat(), lut = _lut.getMat();
|
|
||||||
_dst.create(src.dims, src.size, CV_MAKETYPE(_lut.depth(), cn));
|
|
||||||
Mat dst = _dst.getMat();
|
|
||||||
|
|
||||||
if (_src.dims() <= 2)
|
|
||||||
{
|
|
||||||
bool ok = false;
|
|
||||||
Ptr<ParallelLoopBody> body;
|
|
||||||
|
|
||||||
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
|
|
||||||
#if 0 // there are no performance benefits (PR #2653)
|
|
||||||
if (lutcn == 1)
|
|
||||||
{
|
|
||||||
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
|
|
||||||
body.reset(p);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
|
|
||||||
{
|
|
||||||
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
|
|
||||||
body.reset(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (body != NULL && ok)
|
|
||||||
{
|
|
||||||
Range all(0, dst.rows);
|
|
||||||
if (dst.total()>>18)
|
|
||||||
parallel_for_(all, *body, (double)std::max((size_t)1, dst.total()>>16));
|
|
||||||
else
|
|
||||||
(*body)(all);
|
|
||||||
if (ok)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
|
void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
|
||||||
{
|
{
|
||||||
int cn = _src.channels(), depth = _src.depth();
|
int cn = _src.channels(), depth = _src.depth();
|
||||||
@ -5952,18 +5937,17 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
|
|||||||
CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2,
|
CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2,
|
||||||
ocl_LUT(_src, _lut, _dst))
|
ocl_LUT(_src, _lut, _dst))
|
||||||
|
|
||||||
CV_IPP_RUN((_src.dims() <= 2 && ((lutcn == 1 || lutcn == 3 || lutcn == 4) && CV_ELEM_SIZE1(_dst.depth()) == 1) && lutcn != 1), //lutcn == 1 ipp implementation switched off
|
|
||||||
ipp_lut(_src, _lut, _dst));
|
|
||||||
|
|
||||||
|
|
||||||
Mat src = _src.getMat(), lut = _lut.getMat();
|
Mat src = _src.getMat(), lut = _lut.getMat();
|
||||||
_dst.create(src.dims, src.size, CV_MAKETYPE(_lut.depth(), cn));
|
_dst.create(src.dims, src.size, CV_MAKETYPE(_lut.depth(), cn));
|
||||||
Mat dst = _dst.getMat();
|
Mat dst = _dst.getMat();
|
||||||
|
|
||||||
|
CV_IPP_RUN(_src.dims() <= 2, ipp_lut(src, lut, dst));
|
||||||
|
|
||||||
if (_src.dims() <= 2)
|
if (_src.dims() <= 2)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
Ptr<ParallelLoopBody> body;
|
Ptr<ParallelLoopBody> body;
|
||||||
|
|
||||||
if (body == NULL || ok == false)
|
if (body == NULL || ok == false)
|
||||||
{
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
|
@ -424,9 +424,8 @@ Mat& Mat::operator = (const Scalar& s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined HAVE_IPP
|
#if defined HAVE_IPP
|
||||||
static bool ipp_Mat_setTo(Mat *src, InputArray _value, InputArray _mask)
|
static bool ipp_Mat_setTo(Mat *src, Mat &value, Mat &mask)
|
||||||
{
|
{
|
||||||
Mat value = _value.getMat(), mask = _mask.getMat();
|
|
||||||
int cn = src->channels(), depth0 = src->depth();
|
int cn = src->channels(), depth0 = src->depth();
|
||||||
|
|
||||||
if (!mask.empty() && (src->dims <= 2 || (src->isContinuous() && mask.isContinuous())) &&
|
if (!mask.empty() && (src->dims <= 2 || (src->isContinuous() && mask.isContinuous())) &&
|
||||||
@ -515,8 +514,7 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
|
|||||||
CV_Assert( checkScalar(value, type(), _value.kind(), _InputArray::MAT ));
|
CV_Assert( checkScalar(value, type(), _value.kind(), _InputArray::MAT ));
|
||||||
CV_Assert( mask.empty() || (mask.type() == CV_8U && size == mask.size) );
|
CV_Assert( mask.empty() || (mask.type() == CV_8U && size == mask.size) );
|
||||||
|
|
||||||
CV_IPP_RUN(true, ipp_Mat_setTo((cv::Mat*)this, _value, _mask), *this)
|
CV_IPP_RUN(true, ipp_Mat_setTo((cv::Mat*)this, value, mask), *this)
|
||||||
|
|
||||||
|
|
||||||
size_t esz = elemSize();
|
size_t esz = elemSize();
|
||||||
BinaryFunc copymask = getCopyMaskFunc(esz);
|
BinaryFunc copymask = getCopyMaskFunc(esz);
|
||||||
@ -691,13 +689,10 @@ static bool ocl_flip(InputArray _src, OutputArray _dst, int flipCode )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined HAVE_IPP
|
#if defined HAVE_IPP
|
||||||
static bool ipp_flip( InputArray _src, OutputArray _dst, int flip_mode )
|
static bool ipp_flip( Mat &src, Mat &dst, int flip_mode )
|
||||||
{
|
{
|
||||||
Size size = _src.size();
|
Size size = src.size();
|
||||||
Mat src = _src.getMat();
|
|
||||||
int type = src.type();
|
int type = src.type();
|
||||||
_dst.create( size, type );
|
|
||||||
Mat dst = _dst.getMat();
|
|
||||||
|
|
||||||
typedef IppStatus (CV_STDCALL * ippiMirror)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize, IppiAxis flip);
|
typedef IppStatus (CV_STDCALL * ippiMirror)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize, IppiAxis flip);
|
||||||
typedef IppStatus (CV_STDCALL * ippiMirrorI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize, IppiAxis flip);
|
typedef IppStatus (CV_STDCALL * ippiMirrorI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize, IppiAxis flip);
|
||||||
@ -786,13 +781,13 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode )
|
|||||||
|
|
||||||
CV_OCL_RUN( _dst.isUMat(), ocl_flip(_src, _dst, flip_mode))
|
CV_OCL_RUN( _dst.isUMat(), ocl_flip(_src, _dst, flip_mode))
|
||||||
|
|
||||||
CV_IPP_RUN(true, ipp_flip(_src, _dst, flip_mode));
|
|
||||||
|
|
||||||
|
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
int type = src.type();
|
int type = src.type();
|
||||||
_dst.create( size, type );
|
_dst.create( size, type );
|
||||||
Mat dst = _dst.getMat();
|
Mat dst = _dst.getMat();
|
||||||
|
|
||||||
|
CV_IPP_RUN(true, ipp_flip(src, dst, flip_mode));
|
||||||
|
|
||||||
size_t esz = CV_ELEM_SIZE(type);
|
size_t esz = CV_ELEM_SIZE(type);
|
||||||
|
|
||||||
if( flip_mode <= 0 )
|
if( flip_mode <= 0 )
|
||||||
|
@ -3088,19 +3088,15 @@ static bool ocl_transpose( InputArray _src, OutputArray _dst )
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_IPP
|
#ifdef HAVE_IPP
|
||||||
static bool ipp_transpose( InputArray _src, OutputArray _dst )
|
static bool ipp_transpose( Mat &src, Mat &dst )
|
||||||
{
|
{
|
||||||
int type = _src.type();
|
int type = src.type();
|
||||||
typedef IppStatus (CV_STDCALL * ippiTranspose)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize);
|
typedef IppStatus (CV_STDCALL * ippiTranspose)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize);
|
||||||
typedef IppStatus (CV_STDCALL * ippiTransposeI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize);
|
typedef IppStatus (CV_STDCALL * ippiTransposeI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize);
|
||||||
ippiTranspose ippFunc = 0;
|
ippiTranspose ippFunc = 0;
|
||||||
ippiTransposeI ippFuncI = 0;
|
ippiTransposeI ippFuncI = 0;
|
||||||
|
|
||||||
Mat dst = _dst.getMat();
|
|
||||||
Mat src = _src.getMat();
|
|
||||||
|
|
||||||
if (dst.data == src.data && dst.cols == dst.rows)
|
if (dst.data == src.data && dst.cols == dst.rows)
|
||||||
{
|
{
|
||||||
CV_SUPPRESS_DEPRECATED_START
|
CV_SUPPRESS_DEPRECATED_START
|
||||||
@ -3186,8 +3182,7 @@ void cv::transpose( InputArray _src, OutputArray _dst )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IPP_RUN(true, ipp_transpose(_src, _dst))
|
CV_IPP_RUN(true, ipp_transpose(src, dst))
|
||||||
|
|
||||||
|
|
||||||
if( dst.data == src.data )
|
if( dst.data == src.data )
|
||||||
{
|
{
|
||||||
|
@ -72,7 +72,6 @@
|
|||||||
#define GET_OPTIMIZED(func) (func)
|
#define GET_OPTIMIZED(func) (func)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1138,23 +1138,19 @@ static bool ocl_sum( InputArray _src, Scalar & res, int sum_op, InputArray _mask
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
#ifdef HAVE_IPP
|
||||||
|
static bool ipp_sum(Mat &src, Scalar &_res)
|
||||||
#if defined (HAVE_IPP)
|
|
||||||
namespace cv
|
|
||||||
{
|
{
|
||||||
static bool ipp_sum(Mat src, Scalar & _res)
|
#if IPP_VERSION_MAJOR >= 7
|
||||||
{
|
|
||||||
#if (IPP_VERSION_MAJOR >= 7)
|
|
||||||
int cn = src.channels();
|
int cn = src.channels();
|
||||||
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;
|
||||||
if (src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size))
|
if( src.dims == 2 || (src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||||
{
|
{
|
||||||
IppiSize sz = { cols, rows };
|
IppiSize sz = { cols, rows };
|
||||||
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 ippFuncHint =
|
||||||
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 :
|
||||||
@ -1172,49 +1168,45 @@ namespace cv
|
|||||||
type == CV_16SC4 ? (ippiSumFuncNoHint)ippiSum_16s_C4R :
|
type == CV_16SC4 ? (ippiSumFuncNoHint)ippiSum_16s_C4R :
|
||||||
0;
|
0;
|
||||||
CV_Assert(!ippFuncHint || !ippFuncNoHint);
|
CV_Assert(!ippFuncHint || !ippFuncNoHint);
|
||||||
if (ippFuncHint || ippFuncNoHint)
|
if( ippFuncHint || ippFuncNoHint )
|
||||||
{
|
{
|
||||||
Ipp64f res[4];
|
Ipp64f res[4];
|
||||||
IppStatus ret = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) :
|
IppStatus ret = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) :
|
||||||
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, res);
|
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, res);
|
||||||
CV_Assert(cn <= 4);
|
if( ret >= 0 )
|
||||||
cn = min(cn, 4);
|
|
||||||
if (ret >= 0)
|
|
||||||
{
|
{
|
||||||
for( int i = 0; i < cn; i++ )
|
for( int i = 0; i < cn; i++ )
|
||||||
_res[i] = res[i];
|
_res[i] = res[i];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
CV_UNUSED(src); CV_UNUSED(_res);
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
cv::Scalar cv::sum( InputArray _src )
|
cv::Scalar cv::sum( InputArray _src )
|
||||||
{
|
{
|
||||||
|
#if defined HAVE_OPENCL || defined HAVE_IPP
|
||||||
Scalar _res;
|
Scalar _res;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_OPENCL
|
#ifdef HAVE_OPENCL
|
||||||
CV_OCL_RUN_(OCL_PERFORMANCE_CHECK(_src.isUMat()) && _src.dims() <= 2,
|
CV_OCL_RUN_(OCL_PERFORMANCE_CHECK(_src.isUMat()) && _src.dims() <= 2,
|
||||||
ocl_sum(_src, _res, OCL_OP_SUM),
|
ocl_sum(_src, _res, OCL_OP_SUM),
|
||||||
_res)
|
_res)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_IPP
|
|
||||||
size_t total_size = _src.total();
|
|
||||||
int rows = _src.rows();
|
|
||||||
int cols = rows ? (int)(total_size / rows) : 0;
|
|
||||||
#endif
|
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
CV_IPP_RUN((_src.dims() == 2 || (_src.isContinuous() && cols > 0 && (size_t)rows*cols == total_size)) && IPP_VERSION_MAJOR >= 7,
|
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_sum(src, _res), _res);
|
||||||
ipp_sum(src, _res), _res);
|
|
||||||
int k, cn = src.channels(), depth = src.depth();
|
int k, cn = src.channels(), depth = src.depth();
|
||||||
|
|
||||||
SumFunc func = getSumFunc(depth);
|
SumFunc func = getSumFunc(depth);
|
||||||
|
|
||||||
CV_Assert( cn <= 4 && func != 0 );
|
CV_Assert( cn <= 4 && func != 0 );
|
||||||
|
|
||||||
const Mat* arrays[] = {&src, 0};
|
const Mat* arrays[] = {&src, 0};
|
||||||
@ -1262,7 +1254,6 @@ cv::Scalar cv::sum( InputArray _src )
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCL
|
#ifdef HAVE_OPENCL
|
||||||
|
|
||||||
namespace cv {
|
namespace cv {
|
||||||
@ -1310,7 +1301,7 @@ static bool ocl_countNonZero( InputArray _src, int & res )
|
|||||||
#if defined HAVE_IPP
|
#if defined HAVE_IPP
|
||||||
namespace cv {
|
namespace cv {
|
||||||
|
|
||||||
static bool ipp_countNonZero( Mat src, int & res )
|
static bool ipp_countNonZero( Mat &src, int &res )
|
||||||
{
|
{
|
||||||
#if !defined HAVE_IPP_ICV_ONLY
|
#if !defined HAVE_IPP_ICV_ONLY
|
||||||
Ipp32s count = 0;
|
Ipp32s count = 0;
|
||||||
@ -1644,72 +1635,72 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (HAVE_IPP)
|
#ifdef HAVE_IPP
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& mask)
|
static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& mask)
|
||||||
{
|
{
|
||||||
#if (IPP_VERSION_MAJOR >= 7)
|
#if IPP_VERSION_MAJOR >= 7
|
||||||
int cn = src.channels();
|
int cn = src.channels();
|
||||||
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;
|
||||||
|
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||||
|
{
|
||||||
Ipp64f mean_temp[3];
|
Ipp64f mean_temp[3];
|
||||||
Ipp64f stddev_temp[3];
|
Ipp64f stddev_temp[3];
|
||||||
Ipp64f *pmean = &mean_temp[0];
|
Ipp64f *pmean = &mean_temp[0];
|
||||||
Ipp64f *pstddev = &stddev_temp[0];
|
Ipp64f *pstddev = &stddev_temp[0];
|
||||||
Mat mean, stddev;
|
Mat mean, stddev;
|
||||||
int dcn_mean = -1;
|
int dcn_mean = -1;
|
||||||
if (_mean.needed())
|
if( _mean.needed() )
|
||||||
{
|
{
|
||||||
if (!_mean.fixedSize())
|
if( !_mean.fixedSize() )
|
||||||
_mean.create(cn, 1, CV_64F, -1, true);
|
_mean.create(cn, 1, CV_64F, -1, true);
|
||||||
mean = _mean.getMat();
|
mean = _mean.getMat();
|
||||||
dcn_mean = (int)mean.total();
|
dcn_mean = (int)mean.total();
|
||||||
pmean = mean.ptr<Ipp64f>();
|
pmean = mean.ptr<Ipp64f>();
|
||||||
}
|
}
|
||||||
int dcn_stddev = -1;
|
int dcn_stddev = -1;
|
||||||
if (_sdv.needed())
|
if( _sdv.needed() )
|
||||||
{
|
{
|
||||||
if (!_sdv.fixedSize())
|
if( !_sdv.fixedSize() )
|
||||||
_sdv.create(cn, 1, CV_64F, -1, true);
|
_sdv.create(cn, 1, CV_64F, -1, true);
|
||||||
stddev = _sdv.getMat();
|
stddev = _sdv.getMat();
|
||||||
dcn_stddev = (int)stddev.total();
|
dcn_stddev = (int)stddev.total();
|
||||||
pstddev = stddev.ptr<Ipp64f>();
|
pstddev = stddev.ptr<Ipp64f>();
|
||||||
}
|
}
|
||||||
for (int c = cn; c < dcn_mean; c++)
|
for( int c = cn; c < dcn_mean; c++ )
|
||||||
pmean[c] = 0;
|
pmean[c] = 0;
|
||||||
for (int c = cn; c < dcn_stddev; c++)
|
for( int c = cn; c < dcn_stddev; c++ )
|
||||||
pstddev[c] = 0;
|
pstddev[c] = 0;
|
||||||
IppiSize sz = { cols, rows };
|
IppiSize sz = { cols, rows };
|
||||||
int type = src.type();
|
int type = src.type();
|
||||||
|
if( !mask.empty() )
|
||||||
if (!mask.empty())
|
|
||||||
{
|
{
|
||||||
typedef IppStatus(CV_STDCALL* ippiMaskMeanStdDevFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *, Ipp64f *);
|
typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *, Ipp64f *);
|
||||||
ippiMaskMeanStdDevFuncC1 ippFuncC1 =
|
ippiMaskMeanStdDevFuncC1 ippFuncC1 =
|
||||||
type == CV_8UC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_8u_C1MR :
|
type == CV_8UC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_8u_C1MR :
|
||||||
type == CV_16UC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_16u_C1MR :
|
type == CV_16UC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_16u_C1MR :
|
||||||
type == CV_32FC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_32f_C1MR :
|
type == CV_32FC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_32f_C1MR :
|
||||||
0;
|
0;
|
||||||
if (ippFuncC1)
|
if( ippFuncC1 )
|
||||||
{
|
{
|
||||||
if (ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, pmean, pstddev) >= 0)
|
if( ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, pmean, pstddev) >= 0 )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typedef IppStatus(CV_STDCALL* ippiMaskMeanStdDevFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *, Ipp64f *);
|
typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *, Ipp64f *);
|
||||||
ippiMaskMeanStdDevFuncC3 ippFuncC3 =
|
ippiMaskMeanStdDevFuncC3 ippFuncC3 =
|
||||||
type == CV_8UC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_8u_C3CMR :
|
type == CV_8UC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_8u_C3CMR :
|
||||||
type == CV_16UC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_16u_C3CMR :
|
type == CV_16UC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_16u_C3CMR :
|
||||||
type == CV_32FC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_32f_C3CMR :
|
type == CV_32FC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_32f_C3CMR :
|
||||||
0;
|
0;
|
||||||
if (ippFuncC3)
|
if( ippFuncC3 )
|
||||||
{
|
{
|
||||||
if (ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 1, &pmean[0], &pstddev[0]) >= 0 &&
|
if( ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 1, &pmean[0], &pstddev[0]) >= 0 &&
|
||||||
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 &&
|
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 &&
|
||||||
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0)
|
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0 )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1717,7 +1708,7 @@ static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& m
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
typedef IppStatus(CV_STDCALL* ippiMeanStdDevFuncC1)(const void *, int, IppiSize, Ipp64f *, Ipp64f *);
|
typedef IppStatus (CV_STDCALL* ippiMeanStdDevFuncC1)(const void *, int, IppiSize, Ipp64f *, Ipp64f *);
|
||||||
ippiMeanStdDevFuncC1 ippFuncC1 =
|
ippiMeanStdDevFuncC1 ippFuncC1 =
|
||||||
type == CV_8UC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_8u_C1R :
|
type == CV_8UC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_8u_C1R :
|
||||||
type == CV_16UC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_16u_C1R :
|
type == CV_16UC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_16u_C1R :
|
||||||
@ -1725,29 +1716,32 @@ static bool ipp_meanStdDev(Mat& src, OutputArray _mean, OutputArray _sdv, Mat& m
|
|||||||
type == CV_32FC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_32f_C1R ://Aug 2013: bug in IPP 7.1, 8.0
|
type == CV_32FC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_32f_C1R ://Aug 2013: bug in IPP 7.1, 8.0
|
||||||
#endif
|
#endif
|
||||||
0;
|
0;
|
||||||
if (ippFuncC1)
|
if( ippFuncC1 )
|
||||||
{
|
{
|
||||||
if (ippFuncC1(src.ptr(), (int)src.step[0], sz, pmean, pstddev) >= 0)
|
if( ippFuncC1(src.ptr(), (int)src.step[0], sz, pmean, pstddev) >= 0 )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typedef IppStatus(CV_STDCALL* ippiMeanStdDevFuncC3)(const void *, int, IppiSize, int, Ipp64f *, Ipp64f *);
|
typedef IppStatus (CV_STDCALL* ippiMeanStdDevFuncC3)(const void *, int, IppiSize, int, Ipp64f *, Ipp64f *);
|
||||||
ippiMeanStdDevFuncC3 ippFuncC3 =
|
ippiMeanStdDevFuncC3 ippFuncC3 =
|
||||||
type == CV_8UC3 ? (ippiMeanStdDevFuncC3)ippiMean_StdDev_8u_C3CR :
|
type == CV_8UC3 ? (ippiMeanStdDevFuncC3)ippiMean_StdDev_8u_C3CR :
|
||||||
type == CV_16UC3 ? (ippiMeanStdDevFuncC3)ippiMean_StdDev_16u_C3CR :
|
type == CV_16UC3 ? (ippiMeanStdDevFuncC3)ippiMean_StdDev_16u_C3CR :
|
||||||
type == CV_32FC3 ? (ippiMeanStdDevFuncC3)ippiMean_StdDev_32f_C3CR :
|
type == CV_32FC3 ? (ippiMeanStdDevFuncC3)ippiMean_StdDev_32f_C3CR :
|
||||||
0;
|
0;
|
||||||
if (ippFuncC3)
|
if( ippFuncC3 )
|
||||||
{
|
{
|
||||||
if (ippFuncC3(src.ptr(), (int)src.step[0], sz, 1, &pmean[0], &pstddev[0]) >= 0 &&
|
if( ippFuncC3(src.ptr(), (int)src.step[0], sz, 1, &pmean[0], &pstddev[0]) >= 0 &&
|
||||||
ippFuncC3(src.ptr(), (int)src.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 &&
|
ippFuncC3(src.ptr(), (int)src.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 &&
|
||||||
ippFuncC3(src.ptr(), (int)src.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0)
|
ippFuncC3(src.ptr(), (int)src.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0 )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
CV_UNUSED(src); CV_UNUSED(_mean); CV_UNUSED(_sdv); CV_UNUSED(mask);
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1761,20 +1755,11 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
|
|||||||
|
|
||||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||||
CV_Assert( mask.empty() || mask.type() == CV_8UC1 );
|
CV_Assert( mask.empty() || mask.type() == CV_8UC1 );
|
||||||
#ifdef HAVE_IPP
|
|
||||||
Size sz = _src.dims() <= 2 ? _src.size() : Size();
|
|
||||||
size_t total_size = _src.total();
|
|
||||||
int rows = sz.height;
|
|
||||||
int cols = rows ? (int)(total_size / rows) : 0;
|
|
||||||
#endif
|
|
||||||
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7 && (_src.dims() == 2 || (_src.isContinuous() && _mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size)),
|
|
||||||
ipp_meanStdDev(src, _mean, _sdv, mask));
|
|
||||||
|
|
||||||
|
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_meanStdDev(src, _mean, _sdv, mask));
|
||||||
|
|
||||||
int k, cn = src.channels(), depth = src.depth();
|
int k, cn = src.channels(), depth = src.depth();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SumSqrFunc func = getSumSqrTab(depth);
|
SumSqrFunc func = getSumSqrTab(depth);
|
||||||
|
|
||||||
CV_Assert( func != 0 );
|
CV_Assert( func != 0 );
|
||||||
@ -1864,7 +1849,6 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
/****************************************************************************************\
|
||||||
* minMaxLoc *
|
* minMaxLoc *
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
@ -2216,15 +2200,15 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (HAVE_IPP)
|
#ifdef HAVE_IPP
|
||||||
static bool ipp_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, InputArray _mask)
|
static bool ipp_minMaxIdx( Mat &src, double* minVal, double* maxVal, int* minIdx, int* maxIdx, Mat &mask)
|
||||||
{
|
{
|
||||||
#if (IPP_VERSION_MAJOR >= 7)
|
#if IPP_VERSION_MAJOR >= 7
|
||||||
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);
|
||||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
|
||||||
|
|
||||||
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;
|
||||||
|
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||||
|
{
|
||||||
IppiSize sz = { cols * cn, rows };
|
IppiSize sz = { cols * cn, rows };
|
||||||
|
|
||||||
if( !mask.empty() )
|
if( !mask.empty() )
|
||||||
@ -2275,7 +2259,10 @@ static bool ipp_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
|
|||||||
depth == CV_8U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R :
|
depth == CV_8U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R :
|
||||||
depth == CV_8S ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1R :
|
depth == CV_8S ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8s_C1R :
|
||||||
depth == CV_16U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1R :
|
depth == CV_16U ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1R :
|
||||||
depth == CV_32F ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1R : 0;
|
#if !((defined _MSC_VER && defined _M_IX86) || defined __i386__)
|
||||||
|
depth == CV_32F ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1R :
|
||||||
|
#endif
|
||||||
|
0;
|
||||||
CV_SUPPRESS_DEPRECATED_END
|
CV_SUPPRESS_DEPRECATED_END
|
||||||
|
|
||||||
if( ippFuncC1 )
|
if( ippFuncC1 )
|
||||||
@ -2302,7 +2289,10 @@ static bool ipp_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
#endif
|
#endif
|
||||||
|
CV_UNUSED(src); CV_UNUSED(minVal); CV_UNUSED(maxVal); CV_UNUSED(minIdx); CV_UNUSED(maxIdx); CV_UNUSED(mask);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2321,15 +2311,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
|||||||
ocl_minMaxIdx(_src, minVal, maxVal, minIdx, maxIdx, _mask))
|
ocl_minMaxIdx(_src, minVal, maxVal, minIdx, maxIdx, _mask))
|
||||||
|
|
||||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||||
#ifdef HAVE_IPP
|
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
|
||||||
Size sz = _src.dims() <= 2 ? _src.size() : Size();
|
|
||||||
size_t total_size = _src.total();
|
|
||||||
int rows = sz.height;
|
|
||||||
int cols = rows ? (int)(total_size/rows) : 0;
|
|
||||||
#endif
|
|
||||||
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7 && (_src.dims() == 2 || (_src.isContinuous() && _mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size)),
|
|
||||||
ipp_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))
|
|
||||||
|
|
||||||
|
|
||||||
MinMaxIdxFunc func = getMinmaxTab(depth);
|
MinMaxIdxFunc func = getMinmaxTab(depth);
|
||||||
CV_Assert( func != 0 );
|
CV_Assert( func != 0 );
|
||||||
@ -2372,7 +2354,6 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
|||||||
ofs2idx(src, maxidx, maxIdx);
|
ofs2idx(src, maxidx, maxIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 )
|
||||||
{
|
{
|
||||||
@ -2652,32 +2633,29 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double &
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
#ifdef HAVE_IPP
|
||||||
|
static bool ipp_norm(Mat &src, int normType, Mat &mask, double &result)
|
||||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
|
||||||
|
|
||||||
namespace cv {
|
|
||||||
static bool ipp_norm(InputArray _src, int normType, InputArray _mask, double & result)
|
|
||||||
{
|
{
|
||||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
#if IPP_VERSION_MAJOR >= 7
|
||||||
int cn = src.channels();
|
int cn = src.channels();
|
||||||
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;
|
||||||
if ((src.dims == 2 || (src.isContinuous() && mask.isContinuous()))
|
|
||||||
|
if( (src.dims == 2 || (src.isContinuous() && mask.isContinuous()))
|
||||||
&& cols > 0 && (size_t)rows*cols == total_size
|
&& cols > 0 && (size_t)rows*cols == total_size
|
||||||
&& (normType == NORM_INF || normType == NORM_L1 ||
|
&& (normType == NORM_INF || normType == NORM_L1 ||
|
||||||
normType == NORM_L2 || normType == NORM_L2SQR))
|
normType == NORM_L2 || normType == NORM_L2SQR) )
|
||||||
{
|
{
|
||||||
IppiSize sz = { cols, rows };
|
IppiSize sz = { cols, rows };
|
||||||
int type = src.type();
|
int type = src.type();
|
||||||
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 ippFuncC1 =
|
||||||
normType == NORM_INF ?
|
normType == NORM_INF ?
|
||||||
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8u_C1MR :
|
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8u_C1MR :
|
||||||
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8s_C1MR :
|
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8s_C1MR :
|
||||||
// type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_16u_C1MR :
|
// type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_16u_C1MR :
|
||||||
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_32f_C1MR :
|
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_32f_C1MR :
|
||||||
0) :
|
0) :
|
||||||
normType == NORM_L1 ?
|
normType == NORM_L1 ?
|
||||||
@ -2692,15 +2670,14 @@ static bool ipp_norm(InputArray _src, int normType, InputArray _mask, double & r
|
|||||||
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( ippFuncC1 )
|
||||||
{
|
{
|
||||||
Ipp64f norm;
|
Ipp64f norm;
|
||||||
if (ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &norm) >= 0)
|
if( ippFuncC1(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;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
/*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 ippFuncC3 =
|
||||||
@ -2734,16 +2711,15 @@ static bool ipp_norm(InputArray _src, int normType, InputArray _mask, double & r
|
|||||||
normType == NORM_L1 ? norm1 + norm2 + norm3 :
|
normType == NORM_L1 ? norm1 + norm2 + norm3 :
|
||||||
normType == NORM_L2 || normType == NORM_L2SQR ? std::sqrt(norm1 * norm1 + norm2 * norm2 + norm3 * norm3) :
|
normType == NORM_L2 || normType == NORM_L2SQR ? std::sqrt(norm1 * norm1 + norm2 * norm2 + norm3 * norm3) :
|
||||||
0;
|
0;
|
||||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
result = (normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm);
|
||||||
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
|
return true;
|
||||||
}
|
}
|
||||||
setIppErrorStatus();
|
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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 ippFuncHint =
|
||||||
normType == NORM_L1 ?
|
normType == NORM_L1 ?
|
||||||
(type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R :
|
(type == CV_32FC1 ? (ippiNormFuncHint)ippiNorm_L1_32f_C1R :
|
||||||
@ -2796,17 +2772,15 @@ static bool ipp_norm(InputArray _src, int normType, InputArray _mask, double & r
|
|||||||
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(!ippFuncHint || !ippFuncNoHint);
|
||||||
if (ippFuncHint || ippFuncNoHint)
|
if( ippFuncHint || ippFuncNoHint )
|
||||||
{
|
{
|
||||||
Ipp64f norm_array[4];
|
Ipp64f norm_array[4];
|
||||||
IppStatus ret = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, norm_array, ippAlgHintAccurate) :
|
IppStatus ret = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, norm_array, ippAlgHintAccurate) :
|
||||||
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, norm_array);
|
ippFuncNoHint(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];
|
||||||
CV_Assert(cn <= 4);
|
for( int i = 1; i < cn; i++ )
|
||||||
cn = min(cn, 4);
|
|
||||||
for (int i = 1; i < cn; i++)
|
|
||||||
{
|
{
|
||||||
norm =
|
norm =
|
||||||
normType == NORM_INF ? std::max(norm, norm_array[i]) :
|
normType == NORM_INF ? std::max(norm, norm_array[i]) :
|
||||||
@ -2814,18 +2788,19 @@ static bool ipp_norm(InputArray _src, int normType, InputArray _mask, double & r
|
|||||||
normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
|
normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
result = normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm;
|
result = (normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
CV_UNUSED(src); CV_UNUSED(normType); CV_UNUSED(mask); CV_UNUSED(result);
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
double cv::norm( InputArray _src, int normType, InputArray _mask )
|
double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||||
{
|
{
|
||||||
@ -2845,9 +2820,9 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||||
int depth = src.depth(), cn = src.channels();
|
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_norm(src, normType, mask, _result), _result);
|
||||||
CV_IPP_RUN(true, ipp_norm(_src, normType, _mask, _result), _result);
|
|
||||||
|
|
||||||
|
int depth = src.depth(), cn = src.channels();
|
||||||
if( src.isContinuous() && mask.empty() )
|
if( src.isContinuous() && mask.empty() )
|
||||||
{
|
{
|
||||||
size_t len = src.total()*cn;
|
size_t len = src.total()*cn;
|
||||||
@ -3044,28 +3019,31 @@ static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArr
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_IPP
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
static bool ipp_norm(InputArray _src1, InputArray _src2, int normType, InputArray _mask, double &result)
|
||||||
static bool ipp_norm_rel(InputArray _src1, InputArray _src2, int normType, InputArray _mask, double & result)
|
{
|
||||||
{
|
#if IPP_VERSION_MAJOR >= 7
|
||||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
|
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
|
||||||
|
|
||||||
|
if( normType & CV_RELATIVE )
|
||||||
|
{
|
||||||
normType &= NORM_TYPE_MASK;
|
normType &= NORM_TYPE_MASK;
|
||||||
CV_Assert(normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR ||
|
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_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
|
||||||
size_t total_size = src1.total();
|
size_t total_size = src1.total();
|
||||||
int rows = src1.size[0], cols = rows ? (int)(total_size / rows) : 0;
|
int rows = src1.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||||
if ((src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous()))
|
if( (src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous()))
|
||||||
&& cols > 0 && (size_t)rows*cols == total_size
|
&& cols > 0 && (size_t)rows*cols == total_size
|
||||||
&& (normType == NORM_INF || normType == NORM_L1 ||
|
&& (normType == NORM_INF || normType == NORM_L1 ||
|
||||||
normType == NORM_L2 || normType == NORM_L2SQR))
|
normType == NORM_L2 || normType == NORM_L2SQR) )
|
||||||
{
|
{
|
||||||
IppiSize sz = { cols, rows };
|
IppiSize sz = { cols, rows };
|
||||||
int type = src1.type();
|
int type = src1.type();
|
||||||
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 ippFuncC1 =
|
||||||
normType == NORM_INF ?
|
normType == NORM_INF ?
|
||||||
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8u_C1MR :
|
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8u_C1MR :
|
||||||
@ -3089,21 +3067,20 @@ namespace cv
|
|||||||
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( ippFuncC1 )
|
||||||
{
|
{
|
||||||
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( ippFuncC1(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;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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 ippFuncNoHint =
|
||||||
normType == NORM_INF ?
|
normType == NORM_INF ?
|
||||||
(type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_8u_C1R :
|
(type == CV_8UC1 ? (ippiNormRelFuncNoHint)ippiNormRel_Inf_8u_C1R :
|
||||||
@ -3131,42 +3108,43 @@ namespace cv
|
|||||||
if (ippFuncNoHint)
|
if (ippFuncNoHint)
|
||||||
{
|
{
|
||||||
Ipp64f norm;
|
Ipp64f norm;
|
||||||
if (ippFuncNoHint(src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm) >= 0)
|
if( ippFuncNoHint(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;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (ippFuncHint)
|
if (ippFuncHint)
|
||||||
{
|
{
|
||||||
Ipp64f norm;
|
Ipp64f norm;
|
||||||
if (ippFuncHint(src1.ptr(), (int)src1.step[0], src2.ptr(), (int)src2.step[0], sz, &norm, ippAlgHintAccurate) >= 0)
|
if( ippFuncHint(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;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
static bool ipp_norm_dif(InputArray _src1, InputArray _src2, int normType, InputArray _mask, double & result)
|
|
||||||
{
|
normType &= 7;
|
||||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
|
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();
|
size_t total_size = src1.total();
|
||||||
int rows = src1.size[0], cols = rows ? (int)(total_size / rows) : 0;
|
int rows = src1.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||||
if ((src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous()))
|
if( (src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous()))
|
||||||
&& cols > 0 && (size_t)rows*cols == total_size
|
&& cols > 0 && (size_t)rows*cols == total_size
|
||||||
&& (normType == NORM_INF || normType == NORM_L1 ||
|
&& (normType == NORM_INF || normType == NORM_L1 ||
|
||||||
normType == NORM_L2 || normType == NORM_L2SQR))
|
normType == NORM_L2 || normType == NORM_L2SQR) )
|
||||||
{
|
{
|
||||||
IppiSize sz = { cols, rows };
|
IppiSize sz = { cols, rows };
|
||||||
int type = src1.type();
|
int type = src1.type();
|
||||||
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 ippFuncC1 =
|
||||||
normType == NORM_INF ?
|
normType == NORM_INF ?
|
||||||
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8u_C1MR :
|
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8u_C1MR :
|
||||||
@ -3188,18 +3166,17 @@ namespace cv
|
|||||||
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( ippFuncC1 )
|
||||||
{
|
{
|
||||||
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( ippFuncC1(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;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
#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 ippFuncC3 =
|
||||||
normType == NORM_INF ?
|
normType == NORM_INF ?
|
||||||
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8u_C3CMR :
|
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8u_C3CMR :
|
||||||
@ -3219,10 +3196,10 @@ namespace cv
|
|||||||
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( ippFuncC3 )
|
||||||
{
|
{
|
||||||
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( ippFuncC3(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 &&
|
ippFuncC3(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)
|
ippFuncC3(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3) >= 0)
|
||||||
{
|
{
|
||||||
@ -3231,17 +3208,16 @@ namespace cv
|
|||||||
normType == NORM_L1 ? norm1 + norm2 + norm3 :
|
normType == NORM_L1 ? norm1 + norm2 + norm3 :
|
||||||
normType == NORM_L2 || normType == NORM_L2SQR ? std::sqrt(norm1 * norm1 + norm2 * norm2 + norm3 * norm3) :
|
normType == NORM_L2 || normType == NORM_L2SQR ? std::sqrt(norm1 * norm1 + norm2 * norm2 + norm3 * norm3) :
|
||||||
0;
|
0;
|
||||||
result = normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
|
result = (normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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 ippFuncHint =
|
||||||
normType == NORM_L1 ?
|
normType == NORM_L1 ?
|
||||||
(type == CV_32FC1 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C1R :
|
(type == CV_32FC1 ? (ippiNormDiffFuncHint)ippiNormDiff_L1_32f_C1R :
|
||||||
@ -3296,17 +3272,15 @@ namespace cv
|
|||||||
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(!ippFuncHint || !ippFuncNoHint);
|
||||||
if (ippFuncHint || ippFuncNoHint)
|
if( ippFuncHint || ippFuncNoHint )
|
||||||
{
|
{
|
||||||
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 = ippFuncHint ? ippFuncHint(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);
|
ippFuncNoHint(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];
|
||||||
CV_Assert(src1.channels() <= 4);
|
for( int i = 1; i < src1.channels(); i++ )
|
||||||
int cn = min(src1.channels(), 4);
|
|
||||||
for (int i = 1; i < cn; i++)
|
|
||||||
{
|
{
|
||||||
norm =
|
norm =
|
||||||
normType == NORM_INF ? std::max(norm, norm_array[i]) :
|
normType == NORM_INF ? std::max(norm, norm_array[i]) :
|
||||||
@ -3314,17 +3288,19 @@ namespace cv
|
|||||||
normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
|
normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
result = normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm;
|
result = (normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
#else
|
||||||
}
|
CV_UNUSED(_src1); CV_UNUSED(_src2); CV_UNUSED(normType); CV_UNUSED(_mask); CV_UNUSED(result);
|
||||||
#endif
|
#endif
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask )
|
double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask )
|
||||||
@ -3341,9 +3317,10 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
|||||||
_result)
|
_result)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CV_IPP_RUN(IPP_VERSION_MAJOR >= 7, ipp_norm(_src1, _src2, normType, _mask, _result), _result);
|
||||||
|
|
||||||
if( normType & CV_RELATIVE )
|
if( normType & CV_RELATIVE )
|
||||||
{
|
{
|
||||||
CV_IPP_RUN(true, ipp_norm_rel(_src1, _src2, normType, _mask, _result), _result);
|
|
||||||
return norm(_src1, _src2, normType & ~CV_RELATIVE, _mask)/(norm(_src2, normType, _mask) + DBL_EPSILON);
|
return norm(_src1, _src2, normType & ~CV_RELATIVE, _mask)/(norm(_src2, normType, _mask) + DBL_EPSILON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3354,7 +3331,6 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
|||||||
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 ||
|
||||||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
|
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
|
||||||
CV_IPP_RUN(true, ipp_norm_dif(_src1, _src2, normType, _mask, _result), _result);
|
|
||||||
|
|
||||||
if( src1.isContinuous() && src2.isContinuous() && mask.empty() )
|
if( src1.isContinuous() && src2.isContinuous() && mask.empty() )
|
||||||
{
|
{
|
||||||
|
@ -3120,6 +3120,7 @@ static bool ipp_resize_mt( Mat src, Mat dst,
|
|||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||||
double inv_scale_x, double inv_scale_y, int interpolation )
|
double inv_scale_x, double inv_scale_y, int interpolation )
|
||||||
{
|
{
|
||||||
@ -3482,7 +3483,6 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
/****************************************************************************************\
|
||||||
* General warping (affine, perspective, remap) *
|
* General warping (affine, perspective, remap) *
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
|
@ -1136,10 +1136,11 @@ private:
|
|||||||
Scalar borderValue;
|
Scalar borderValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if IPP_VERSION_X100 >= 801
|
#ifdef HAVE_IPP
|
||||||
static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kernel,
|
static bool ipp_MorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kernel,
|
||||||
const Size& ksize, const Point &anchor, bool rectKernel)
|
const Size& ksize, const Point &anchor, bool rectKernel)
|
||||||
{
|
{
|
||||||
|
#if IPP_VERSION_X100 >= 801
|
||||||
int type = src.type();
|
int type = src.type();
|
||||||
const Mat* _src = &src;
|
const Mat* _src = &src;
|
||||||
Mat temp;
|
Mat temp;
|
||||||
@ -1257,10 +1258,13 @@ static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kerne
|
|||||||
}
|
}
|
||||||
#undef IPP_MORPH_CASE
|
#undef IPP_MORPH_CASE
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
CV_UNUSED(op); CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(kernel); CV_UNUSED(ksize); CV_UNUSED(anchor); CV_UNUSED(rectKernel);
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
static bool ipp_MorphOp(int op, InputArray _src, OutputArray _dst,
|
||||||
const Mat& _kernel, Point anchor, int iterations,
|
const Mat& _kernel, Point anchor, int iterations,
|
||||||
int borderType, const Scalar &borderValue)
|
int borderType, const Scalar &borderValue)
|
||||||
{
|
{
|
||||||
@ -1331,7 +1335,7 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
|||||||
if( iterations > 1 )
|
if( iterations > 1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return IPPMorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel );
|
return ipp_MorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1711,9 +1715,7 @@ static void morphOp( int op, InputArray _src, OutputArray _dst,
|
|||||||
iterations = 1;
|
iterations = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CV_IPP_RUN(IPP_VERSION_X100 >= 801, ipp_MorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue))
|
||||||
CV_IPP_RUN(IPP_VERSION_X100 >= 801, IPPMorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue))
|
|
||||||
|
|
||||||
|
|
||||||
Mat src = _src.getMat();
|
Mat src = _src.getMat();
|
||||||
_dst.create( src.size(), src.type() );
|
_dst.create( src.size(), src.type() );
|
||||||
|
@ -907,22 +907,22 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
|
|||||||
#ifdef HAVE_IPP
|
#ifdef HAVE_IPP
|
||||||
static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size size, unsigned char &thresh)
|
static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size size, unsigned char &thresh)
|
||||||
{
|
{
|
||||||
|
#if IPP_VERSION_X100 >= 801 && !HAVE_ICV
|
||||||
int ippStatus = -1;
|
int ippStatus = -1;
|
||||||
#if IPP_VERSION_X100 >= 801 && !defined(HAVE_IPP_ICV_ONLY)
|
|
||||||
IppiSize srcSize = { size.width, size.height };
|
IppiSize srcSize = { size.width, size.height };
|
||||||
CV_SUPPRESS_DEPRECATED_START
|
CV_SUPPRESS_DEPRECATED_START
|
||||||
ippStatus = ippiComputeThreshold_Otsu_8u_C1R(_src, step, srcSize, &thresh);
|
ippStatus = ippiComputeThreshold_Otsu_8u_C1R(_src, step, srcSize, &thresh);
|
||||||
CV_SUPPRESS_DEPRECATED_END
|
CV_SUPPRESS_DEPRECATED_END
|
||||||
|
|
||||||
|
if(ippStatus >= 0)
|
||||||
|
return true;
|
||||||
#else
|
#else
|
||||||
CV_UNUSED(_src); CV_UNUSED(step); CV_UNUSED(size); CV_UNUSED(thresh);
|
CV_UNUSED(_src); CV_UNUSED(step); CV_UNUSED(size); CV_UNUSED(thresh);
|
||||||
#endif
|
#endif
|
||||||
if(ippStatus >= 0)
|
|
||||||
return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static double
|
static double
|
||||||
getThreshVal_Otsu_8u( const Mat& _src )
|
getThreshVal_Otsu_8u( const Mat& _src )
|
||||||
{
|
{
|
||||||
@ -937,9 +937,8 @@ getThreshVal_Otsu_8u( const Mat& _src )
|
|||||||
|
|
||||||
#ifdef HAVE_IPP
|
#ifdef HAVE_IPP
|
||||||
unsigned char thresh;
|
unsigned char thresh;
|
||||||
|
CV_IPP_RUN(IPP_VERSION_X100 >= 801 && !HAVE_ICV, ipp_getThreshVal_Otsu_8u(_src.ptr(), step, size, thresh), thresh);
|
||||||
#endif
|
#endif
|
||||||
CV_IPP_RUN(true, ipp_getThreshVal_Otsu_8u(_src.ptr(), step, size, thresh), thresh);
|
|
||||||
|
|
||||||
|
|
||||||
const int N = 256;
|
const int N = 256;
|
||||||
int i, j, h[N] = {0};
|
int i, j, h[N] = {0};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user