Some IPP functions were encapsulated;
Minor changes to IPP implementations;
This commit is contained in:
parent
3a3f4038bf
commit
2177c7c5a8
@ -1688,6 +1688,45 @@ void filterSpecklesImpl(cv::Mat& img, int newVal, int maxSpeckleSize, int maxDif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_filterSpeckles(Mat &img, int maxSpeckleSize, int newVal, int maxDiff)
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
int type = img.type();
|
||||
Ipp32s bufsize = 0;
|
||||
IppiSize roisize = { img.cols, img.rows };
|
||||
IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s;
|
||||
Ipp8u *pBuffer = NULL;
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
if(ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize) < 0)
|
||||
return false;
|
||||
|
||||
pBuffer = (Ipp8u*)ippMalloc(bufsize);
|
||||
if(!pBuffer && bufsize)
|
||||
return false;
|
||||
|
||||
if (type == CV_8UC1)
|
||||
{
|
||||
status = ippiMarkSpeckles_8u_C1IR(img.ptr<Ipp8u>(), (int)img.step, roisize,
|
||||
(Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, pBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ippiMarkSpeckles_16s_C1IR(img.ptr<Ipp16s>(), (int)img.step, roisize,
|
||||
(Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, pBuffer);
|
||||
}
|
||||
if(pBuffer) ippFree(pBuffer);
|
||||
|
||||
if (status >= 0)
|
||||
return true;
|
||||
#else
|
||||
CV_UNUSED(img); CV_UNUSED(maxSpeckleSize); CV_UNUSED(newVal); CV_UNUSED(maxDiff);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSize,
|
||||
@ -1700,37 +1739,7 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi
|
||||
|
||||
int newVal = cvRound(_newval), maxDiff = cvRound(_maxDiff);
|
||||
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
Ipp32s bufsize = 0;
|
||||
IppiSize roisize = { img.cols, img.rows };
|
||||
IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s;
|
||||
|
||||
if (!__buf.needed() && (type == CV_8UC1 || type == CV_16SC1))
|
||||
{
|
||||
IppStatus status = ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize);
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufsize);
|
||||
|
||||
if ((int)status >= 0)
|
||||
{
|
||||
if (type == CV_8UC1)
|
||||
status = ippiMarkSpeckles_8u_C1IR(img.ptr<Ipp8u>(), (int)img.step, roisize,
|
||||
(Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer);
|
||||
else
|
||||
status = ippiMarkSpeckles_16s_C1IR(img.ptr<Ipp16s>(), (int)img.step, roisize,
|
||||
(Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer);
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 801 && !__buf.needed() && (type == CV_8UC1 || type == CV_16SC1), ipp_filterSpeckles(img, maxSpeckleSize, newVal, maxDiff));
|
||||
|
||||
if (type == CV_8UC1)
|
||||
filterSpecklesImpl<uchar>(img, newVal, maxSpeckleSize, maxDiff, _buf);
|
||||
|
@ -3473,21 +3473,7 @@ void cv::dct( InputArray _src0, OutputArray _dst, int flags )
|
||||
_dst.create( src.rows, src.cols, type );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
bool row = (flags & DCT_ROWS) != 0;
|
||||
if (src.type() == CV_32F)
|
||||
{
|
||||
if(ippi_DCT_32f(src,dst,inv, row))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700 && src.type() == CV_32F, ippi_DCT_32f(src, dst, inv, ((flags & DCT_ROWS) != 0)))
|
||||
|
||||
DCTFunc dct_func = dct_tbl[(int)inv + (depth == CV_64F)*2];
|
||||
|
||||
|
@ -3367,22 +3367,20 @@ typedef void (*ReduceFunc)( const Mat& src, Mat& dst );
|
||||
#define reduceMinR32f reduceR_<float, float, OpMin<float> >
|
||||
#define reduceMinR64f reduceR_<double,double,OpMin<double> >
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
|
||||
static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& dstmat)
|
||||
#ifdef HAVE_IPP
|
||||
static inline bool ipp_reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& dstmat)
|
||||
{
|
||||
cv::Size size = srcmat.size();
|
||||
IppiSize roisize = { size.width, 1 };
|
||||
int sstep = (int)srcmat.step, stype = srcmat.type(),
|
||||
sdepth = CV_MAT_DEPTH(stype), ddepth = dstmat.depth();
|
||||
ddepth = dstmat.depth();
|
||||
|
||||
IppiSize roisize = { srcmat.size().width, 1 };
|
||||
|
||||
typedef IppStatus (CV_STDCALL * ippiSum)(const void * pSrc, int srcStep, IppiSize roiSize, Ipp64f* pSum);
|
||||
typedef IppStatus (CV_STDCALL * ippiSumHint)(const void * pSrc, int srcStep, IppiSize roiSize, Ipp64f* pSum, IppHintAlgorithm hint);
|
||||
ippiSum ippFunc = 0;
|
||||
ippiSumHint ippFuncHint = 0;
|
||||
cv::ReduceFunc func = 0;
|
||||
|
||||
if (ddepth == CV_64F)
|
||||
if(ddepth == CV_64F)
|
||||
{
|
||||
ippFunc =
|
||||
stype == CV_8UC1 ? (ippiSum)ippiSum_8u_C1R :
|
||||
@ -3398,41 +3396,46 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds
|
||||
stype == CV_32FC1 ? (ippiSumHint)ippiSum_32f_C1R :
|
||||
stype == CV_32FC3 ? (ippiSumHint)ippiSum_32f_C3R :
|
||||
stype == CV_32FC4 ? (ippiSumHint)ippiSum_32f_C4R : 0;
|
||||
}
|
||||
|
||||
if(ippFunc)
|
||||
{
|
||||
for(int y = 0; y < srcmat.size().height; y++)
|
||||
{
|
||||
if(ippFunc(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y)) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(ippFuncHint)
|
||||
{
|
||||
for(int y = 0; y < srcmat.size().height; y++)
|
||||
{
|
||||
if(ippFuncHint(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y), ippAlgHintAccurate) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& dstmat)
|
||||
{
|
||||
CV_IPP_RUN(true, ipp_reduceSumC_8u16u16s32f_64f(srcmat, dstmat));
|
||||
|
||||
cv::ReduceFunc func = 0;
|
||||
|
||||
if(dstmat.depth() == CV_64F)
|
||||
{
|
||||
int sdepth = CV_MAT_DEPTH(srcmat.type());
|
||||
func =
|
||||
sdepth == CV_8U ? (cv::ReduceFunc)cv::reduceC_<uchar, double, cv::OpAdd<double> > :
|
||||
sdepth == CV_16U ? (cv::ReduceFunc)cv::reduceC_<ushort, double, cv::OpAdd<double> > :
|
||||
sdepth == CV_16S ? (cv::ReduceFunc)cv::reduceC_<short, double, cv::OpAdd<double> > :
|
||||
sdepth == CV_32F ? (cv::ReduceFunc)cv::reduceC_<float, double, cv::OpAdd<double> > : 0;
|
||||
}
|
||||
CV_Assert(!(ippFunc && ippFuncHint) && func);
|
||||
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (ippFunc)
|
||||
{
|
||||
for (int y = 0; y < size.height; ++y)
|
||||
if (ippFunc(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y)) < 0)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
cv::Mat dstroi = dstmat.rowRange(y, y + 1);
|
||||
func(srcmat.rowRange(y, y + 1), dstroi);
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
else if (ippFuncHint)
|
||||
{
|
||||
for (int y = 0; y < size.height; ++y)
|
||||
if (ippFuncHint(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y), ippAlgHintAccurate) < 0)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
cv::Mat dstroi = dstmat.rowRange(y, y + 1);
|
||||
func(srcmat.rowRange(y, y + 1), dstroi);
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
CV_Assert(func);
|
||||
|
||||
func(srcmat, dstmat);
|
||||
}
|
||||
@ -3446,7 +3449,7 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds
|
||||
#define reduceSumC32f32f reduceC_<float, float, OpAdd<float> >
|
||||
#define reduceSumC64f64f reduceC_<double,double,OpAdd<double> >
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
#define reduceSumC8u64f reduceSumC_8u16u16s32f_64f
|
||||
#define reduceSumC16u64f reduceSumC_8u16u16s32f_64f
|
||||
#define reduceSumC16s64f reduceSumC_8u16u16s32f_64f
|
||||
@ -3458,35 +3461,32 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds
|
||||
#define reduceSumC32f64f reduceC_<float, double,OpAdd<double> >
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
#define REDUCE_OP(favor, optype, type1, type2) \
|
||||
static inline bool ipp_reduce##optype##C##favor(const cv::Mat& srcmat, cv::Mat& dstmat) \
|
||||
{ \
|
||||
if((srcmat.channels() == 1)) \
|
||||
{ \
|
||||
int sstep = (int)srcmat.step; \
|
||||
typedef Ipp##favor IppType; \
|
||||
IppiSize roisize = ippiSize(srcmat.size().width, 1);\
|
||||
for(int y = 0; y < srcmat.size().height; y++)\
|
||||
{\
|
||||
if(ippi##optype##_##favor##_C1R(srcmat.ptr<IppType>(y), sstep, roisize, dstmat.ptr<IppType>(y)) < 0)\
|
||||
return false;\
|
||||
}\
|
||||
return true;\
|
||||
}\
|
||||
return false; \
|
||||
} \
|
||||
static inline void reduce##optype##C##favor(const cv::Mat& srcmat, cv::Mat& dstmat) \
|
||||
{ \
|
||||
typedef Ipp##favor IppType; \
|
||||
cv::Size size = srcmat.size(); \
|
||||
IppiSize roisize = ippiSize(size.width, 1);\
|
||||
int sstep = (int)srcmat.step; \
|
||||
\
|
||||
if (CV_IPP_CHECK_COND && (srcmat.channels() == 1)) \
|
||||
{ \
|
||||
for (int y = 0; y < size.height; ++y) \
|
||||
if (ippi##optype##_##favor##_C1R(srcmat.ptr<IppType>(y), sstep, roisize, dstmat.ptr<IppType>(y)) < 0) \
|
||||
{ \
|
||||
setIppErrorStatus(); \
|
||||
cv::Mat dstroi = dstmat.rowRange(y, y + 1); \
|
||||
cv::reduceC_ < type1, type2, cv::Op##optype < type2 > >(srcmat.rowRange(y, y + 1), dstroi); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);\
|
||||
} \
|
||||
return; \
|
||||
} \
|
||||
CV_IPP_RUN(true, ipp_reduce##optype##C##favor(srcmat, dstmat)); \
|
||||
cv::reduceC_ < type1, type2, cv::Op##optype < type2 > >(srcmat, dstmat); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
REDUCE_OP(8u, Max, uchar, uchar)
|
||||
REDUCE_OP(16u, Max, ushort, ushort)
|
||||
REDUCE_OP(16s, Max, short, short)
|
||||
@ -3499,7 +3499,7 @@ REDUCE_OP(32f, Max, float, float)
|
||||
#endif
|
||||
#define reduceMaxC64f reduceC_<double,double,OpMax<double> >
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
REDUCE_OP(8u, Min, uchar, uchar)
|
||||
REDUCE_OP(16u, Min, ushort, ushort)
|
||||
REDUCE_OP(16s, Min, short, short)
|
||||
@ -3772,7 +3772,7 @@ void cv::reduce(InputArray _src, OutputArray _dst, int dim, int op, int dtype)
|
||||
namespace cv
|
||||
{
|
||||
|
||||
#if IPP_VERSION_X100 > 0
|
||||
#ifdef HAVE_IPP
|
||||
#define USE_IPP_SORT
|
||||
|
||||
typedef IppStatus (CV_STDCALL * IppSortFunc)(void *, int);
|
||||
|
@ -1368,100 +1368,106 @@ int cv::countNonZero( InputArray _src )
|
||||
return nz;
|
||||
}
|
||||
|
||||
#if defined HAVE_IPP
|
||||
namespace cv
|
||||
{
|
||||
static bool ipp_mean( Mat &src, Mat &mask, Scalar &ret )
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 700
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
if( !mask.empty() )
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskMeanFuncC1 ippFuncC1 =
|
||||
type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR :
|
||||
0;
|
||||
if( ippFuncC1 )
|
||||
{
|
||||
Ipp64f res;
|
||||
if( ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &res) >= 0 )
|
||||
{
|
||||
ret = Scalar(res);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
|
||||
ippiMaskMeanFuncC3 ippFuncC3 =
|
||||
type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR :
|
||||
type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR :
|
||||
0;
|
||||
if( ippFuncC3 )
|
||||
{
|
||||
Ipp64f res1, res2, res3;
|
||||
if( ippFuncC3(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 &&
|
||||
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 3, &res3) >= 0 )
|
||||
{
|
||||
ret = Scalar(res1, res2, res3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm);
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFuncNoHint)(const void*, int, IppiSize, double *);
|
||||
ippiMeanFuncHint ippFuncHint =
|
||||
type == CV_32FC1 ? (ippiMeanFuncHint)ippiMean_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMeanFuncHint)ippiMean_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMeanFuncHint)ippiMean_32f_C4R :
|
||||
0;
|
||||
ippiMeanFuncNoHint ippFuncNoHint =
|
||||
type == CV_8UC1 ? (ippiMeanFuncNoHint)ippiMean_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMeanFuncNoHint)ippiMean_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMeanFuncNoHint)ippiMean_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiMeanFuncNoHint)ippiMean_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiMeanFuncNoHint)ippiMean_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiMeanFuncNoHint)ippiMean_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiMeanFuncNoHint)ippiMean_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiMeanFuncNoHint)ippiMean_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiMeanFuncNoHint)ippiMean_16s_C4R :
|
||||
0;
|
||||
// Make sure only zero or one version of the function pointer is valid
|
||||
CV_Assert(!ippFuncHint || !ippFuncNoHint);
|
||||
if( ippFuncHint || ippFuncNoHint )
|
||||
{
|
||||
Ipp64f res[4];
|
||||
IppStatus status = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) :
|
||||
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, res);
|
||||
if( status >= 0 )
|
||||
{
|
||||
for( int i = 0; i < src.channels(); i++ )
|
||||
ret[i] = res[i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
cv::Scalar cv::mean( InputArray _src, InputArray _mask )
|
||||
{
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
CV_Assert( mask.empty() || mask.type() == CV_8U );
|
||||
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
Scalar s;
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
size_t total_size = src.total();
|
||||
int rows = src.size[0], cols = rows ? (int)(total_size/rows) : 0;
|
||||
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
|
||||
{
|
||||
IppiSize sz = { cols, rows };
|
||||
int type = src.type();
|
||||
if( !mask.empty() )
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *);
|
||||
ippiMaskMeanFuncC1 ippFuncC1 =
|
||||
type == CV_8UC1 ? (ippiMaskMeanFuncC1)ippiMean_8u_C1MR :
|
||||
type == CV_16UC1 ? (ippiMaskMeanFuncC1)ippiMean_16u_C1MR :
|
||||
type == CV_32FC1 ? (ippiMaskMeanFuncC1)ippiMean_32f_C1MR :
|
||||
0;
|
||||
if( ippFuncC1 )
|
||||
{
|
||||
Ipp64f res;
|
||||
if( ippFuncC1(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, &res) >= 0 )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return Scalar(res);
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
|
||||
ippiMaskMeanFuncC3 ippFuncC3 =
|
||||
type == CV_8UC3 ? (ippiMaskMeanFuncC3)ippiMean_8u_C3CMR :
|
||||
type == CV_16UC3 ? (ippiMaskMeanFuncC3)ippiMean_16u_C3CMR :
|
||||
type == CV_32FC3 ? (ippiMaskMeanFuncC3)ippiMean_32f_C3CMR :
|
||||
0;
|
||||
if( ippFuncC3 )
|
||||
{
|
||||
Ipp64f res1, res2, res3;
|
||||
if( ippFuncC3(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 &&
|
||||
ippFuncC3(src.ptr(), (int)src.step[0], mask.ptr(), (int)mask.step[0], sz, 3, &res3) >= 0 )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return Scalar(res1, res2, res3);
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFuncHint)(const void*, int, IppiSize, double *, IppHintAlgorithm);
|
||||
typedef IppStatus (CV_STDCALL* ippiMeanFuncNoHint)(const void*, int, IppiSize, double *);
|
||||
ippiMeanFuncHint ippFuncHint =
|
||||
type == CV_32FC1 ? (ippiMeanFuncHint)ippiMean_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiMeanFuncHint)ippiMean_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiMeanFuncHint)ippiMean_32f_C4R :
|
||||
0;
|
||||
ippiMeanFuncNoHint ippFuncNoHint =
|
||||
type == CV_8UC1 ? (ippiMeanFuncNoHint)ippiMean_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiMeanFuncNoHint)ippiMean_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiMeanFuncNoHint)ippiMean_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiMeanFuncNoHint)ippiMean_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiMeanFuncNoHint)ippiMean_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiMeanFuncNoHint)ippiMean_16u_C4R :
|
||||
type == CV_16SC1 ? (ippiMeanFuncNoHint)ippiMean_16s_C1R :
|
||||
type == CV_16SC3 ? (ippiMeanFuncNoHint)ippiMean_16s_C3R :
|
||||
type == CV_16SC4 ? (ippiMeanFuncNoHint)ippiMean_16s_C4R :
|
||||
0;
|
||||
// Make sure only zero or one version of the function pointer is valid
|
||||
CV_Assert(!ippFuncHint || !ippFuncNoHint);
|
||||
if( ippFuncHint || ippFuncNoHint )
|
||||
{
|
||||
Ipp64f res[4];
|
||||
IppStatus ret = ippFuncHint ? ippFuncHint(src.ptr(), (int)src.step[0], sz, res, ippAlgHintAccurate) :
|
||||
ippFuncNoHint(src.ptr(), (int)src.step[0], sz, res);
|
||||
if( ret >= 0 )
|
||||
{
|
||||
Scalar sc;
|
||||
for( int i = 0; i < cn; i++ )
|
||||
sc[i] = res[i];
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return sc;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_mean(src, mask, s), s)
|
||||
|
||||
SumFunc func = getSumFunc(depth);
|
||||
|
||||
@ -1470,7 +1476,6 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
|
||||
const Mat* arrays[] = {&src, &mask, 0};
|
||||
uchar* ptrs[2];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
Scalar s;
|
||||
int total = (int)it.size, blockSize = total, intSumBlockSize = 0;
|
||||
int j, count = 0;
|
||||
AutoBuffer<int> _buf;
|
||||
|
@ -47,16 +47,16 @@
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
#define USE_IPP_CANNY 1
|
||||
#else
|
||||
#undef USE_IPP_CANNY
|
||||
#define USE_IPP_CANNY 0
|
||||
#endif
|
||||
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
#ifdef USE_IPP_CANNY
|
||||
#ifdef HAVE_IPP
|
||||
static bool ippCanny(const Mat& _src, Mat& _dst, float low, float high)
|
||||
{
|
||||
#if USE_IPP_CANNY
|
||||
int size = 0, size1 = 0;
|
||||
IppiSize roi = { _src.cols, _src.rows };
|
||||
|
||||
@ -90,6 +90,10 @@ static bool ippCanny(const Mat& _src, Mat& _dst, float low, float high)
|
||||
_dst.ptr(), (int)_dst.step, roi, low, high, buffer) < 0 )
|
||||
return false;
|
||||
return true;
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(low); CV_UNUSED(high);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -610,20 +614,7 @@ void cv::Canny( InputArray _src, OutputArray _dst,
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef USE_IPP_CANNY
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if( aperture_size == 3 && !L2gradient && 1 == cn )
|
||||
{
|
||||
if (ippCanny(src, dst, (float)low_thresh, (float)high_thresh))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CV_IPP_RUN(USE_IPP_CANNY && (aperture_size == 3 && !L2gradient && 1 == cn), ippCanny(src, dst, (float)low_thresh, (float)high_thresh))
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
|
||||
|
@ -603,11 +603,7 @@ void cv::cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, in
|
||||
ocl_cornerMinEigenValVecs(_src, _dst, blockSize, ksize, 0.0, borderType, MINEIGENVAL))
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
int kerSize = ksize;
|
||||
if (ksize < 0)
|
||||
{
|
||||
kerSize = 3;
|
||||
}
|
||||
int kerSize = (ksize < 0)?3:ksize;
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
#endif
|
||||
|
@ -183,15 +183,12 @@ cv::Ptr<cv::FilterEngine> cv::createDerivFilter(int srcType, int dstType,
|
||||
kx, ky, Point(-1,-1), 0, borderType );
|
||||
}
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
|
||||
#define IPP_RETURN_ERROR {setIppErrorStatus(); return false;}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
namespace cv
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, double scale, double delta, int borderType)
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
if ((0 > dx) || (0 > dy) || (1 != dx + dy))
|
||||
return false;
|
||||
if (fabs(delta) > FLT_EPSILON)
|
||||
@ -233,19 +230,19 @@ static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx
|
||||
if (horz)
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp8u, ipp16s, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrHorizMaskBorder_8u16s_C1R(src.ptr(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 > ippiFilterScharrVertMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp8u, ipp16s, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrVertMaskBorder_8u16s_C1R(src.ptr(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
ippsFree(pBuffer);
|
||||
@ -256,19 +253,19 @@ static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx
|
||||
if (horz)
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp16s, ipp16s, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrHorizMaskBorder_16s_C1R(src.ptr<Ipp16s>(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 > ippiFilterScharrVertMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp16s, ipp16s, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrVertMaskBorder_16s_C1R(src.ptr<Ipp16s>(), (int)src.step, dst.ptr<Ipp16s>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
ippsFree(pBuffer);
|
||||
@ -279,134 +276,34 @@ static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx
|
||||
if (horz)
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp32f, ipp32f, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrHorizMaskBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step, dst.ptr<Ipp32f>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 > ippiFilterScharrVertMaskBorderGetBufferSize(roiSize, ippMskSize3x3, ipp32f, ipp32f, 1, &bufferSize))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
pBuffer = ippsMalloc_8u(bufferSize);
|
||||
if (NULL == pBuffer)
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
sts = ippiFilterScharrVertMaskBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step, dst.ptr<Ipp32f>(), (int)dst.step, roiSize, ippMskSize3x3, ippiBorderType, 0, pBuffer);
|
||||
}
|
||||
ippsFree(pBuffer);
|
||||
if (sts < 0)
|
||||
IPP_RETURN_ERROR;
|
||||
return false;;
|
||||
|
||||
if (FLT_EPSILON < fabs(scale - 1.0))
|
||||
sts = ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, roiSize);
|
||||
}
|
||||
return (0 <= sts);
|
||||
}
|
||||
#elif IPP_VERSION_X100 >= 700
|
||||
static bool IPPDerivScharr(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, double scale, double delta, int borderType)
|
||||
{
|
||||
if (BORDER_REPLICATE != borderType)
|
||||
return false;
|
||||
if ((0 > dx) || (0 > dy) || (1 != dx + dy))
|
||||
return false;
|
||||
if (fabs(delta) > FLT_EPSILON)
|
||||
return false;
|
||||
|
||||
Mat src = _src.getMat(), dst = _dst.getMat();
|
||||
|
||||
int bufSize = 0;
|
||||
cv::AutoBuffer<char> buffer;
|
||||
IppiSize roi = ippiSize(src.cols, src.rows);
|
||||
|
||||
if( ddepth < 0 )
|
||||
ddepth = src.depth();
|
||||
|
||||
dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) );
|
||||
|
||||
switch(src.type())
|
||||
{
|
||||
case CV_8UC1:
|
||||
{
|
||||
if(scale != 1)
|
||||
return false;
|
||||
|
||||
switch(dst.type())
|
||||
{
|
||||
case CV_16S:
|
||||
{
|
||||
if ((dx == 1) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterScharrVertGetBufferSize_8u16s_C1R(roi,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
return (0 <= ippiFilterScharrVertBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
|
||||
}
|
||||
if ((dx == 0) && (dy == 1))
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizGetBufferSize_8u16s_C1R(roi,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
return (0 <= ippiFilterScharrHorizBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case CV_32FC1:
|
||||
{
|
||||
switch(dst.type())
|
||||
{
|
||||
case CV_32FC1:
|
||||
{
|
||||
if ((dx == 1) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterScharrVertGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows),&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterScharrVertBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows),
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (scale != 1)
|
||||
/* IPP is fast, so MulC produce very little perf degradation.*/
|
||||
//ippiMulC_32f_C1IR((Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
}
|
||||
if ((dx == 0) && (dy == 1))
|
||||
{
|
||||
if (0 > ippiFilterScharrHorizGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows),&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterScharrHorizBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows),
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
return false;
|
||||
|
||||
if (scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(ddepth); CV_UNUSED(dx); CV_UNUSED(dy); CV_UNUSED(scale); CV_UNUSED(delta); CV_UNUSED(borderType);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType)
|
||||
{
|
||||
@ -423,58 +320,61 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
if ( ddepth < 0 )
|
||||
ddepth = src.depth();
|
||||
|
||||
IppiSize roi = {src.cols, src.rows};
|
||||
IppiMaskSize kernel = (IppiMaskSize)(ksize*10+ksize);
|
||||
|
||||
if (src.type() == CV_8U && dst.type() == CV_16S && scale == 1)
|
||||
{
|
||||
if ((dx == 1) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
if (0 > ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterSobelNegVertBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((dx == 0) && (dy == 1))
|
||||
{
|
||||
if (0 > ippiFilterSobelHorizGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
if (0 > ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterSobelHorizBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !defined(HAVE_IPP_ICV_ONLY)
|
||||
if ((dx == 2) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterSobelVertSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
if (0 > ippiFilterSobelVertSecondGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterSobelVertSecondBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((dx == 0) && (dy == 2))
|
||||
{
|
||||
if (0 > ippiFilterSobelHorizSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
if (0 > ippiFilterSobelHorizSecondGetBufferSize_8u16s_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterSobelHorizSecondBorder_8u16s_C1R(src.ptr<Ipp8u>(), (int)src.step,
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp16s>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@ -485,14 +385,14 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
#if 0
|
||||
if ((dx == 1) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterSobelNegVertGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), &bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
if (0 > ippiFilterSobelNegVertGetBufferSize_32f_C1R(roi, kernel, &bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterSobelNegVertBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
if(scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
@ -500,13 +400,13 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
|
||||
if ((dx == 0) && (dy == 1))
|
||||
{
|
||||
if (0 > ippiFilterSobelHorizGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
if (0 > ippiFilterSobelHorizGetBufferSize_32f_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
if (0 > ippiFilterSobelHorizBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
if(scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
@ -515,14 +415,14 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
#if !defined(HAVE_IPP_ICV_ONLY)
|
||||
if((dx == 2) && (dy == 0))
|
||||
{
|
||||
if (0 > ippiFilterSobelVertSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
if (0 > ippiFilterSobelVertSecondGetBufferSize_32f_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterSobelVertSecondBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
if(scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
return true;
|
||||
@ -530,14 +430,14 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
|
||||
if((dx == 0) && (dy == 2))
|
||||
{
|
||||
if (0 > ippiFilterSobelHorizSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
|
||||
IPP_RETURN_ERROR
|
||||
if (0 > ippiFilterSobelHorizSecondGetBufferSize_32f_C1R(roi, kernel,&bufSize))
|
||||
return false;
|
||||
buffer.allocate(bufSize);
|
||||
|
||||
if (0 > ippiFilterSobelHorizSecondBorder_32f_C1R(src.ptr<Ipp32f>(), (int)src.step,
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
|
||||
dst.ptr<Ipp32f>(), (int)dst.step, roi, kernel,
|
||||
ippBorderRepl, 0, (Ipp8u*)(char*)buffer))
|
||||
IPP_RETURN_ERROR
|
||||
return false;
|
||||
|
||||
if(scale != 1)
|
||||
ippiMulC_32f_C1R(dst.ptr<Ipp32f>(), (int)dst.step, (Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, ippiSize(dst.cols*dst.channels(), dst.rows));
|
||||
@ -547,41 +447,22 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#ifdef HAVE_IPP
|
||||
|
||||
static bool ipp_sobel(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType)
|
||||
{
|
||||
if (ksize < 0)
|
||||
{
|
||||
if (IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (0 < ksize)
|
||||
{
|
||||
if (IPPDerivSobel(_src, _dst, ddepth, dx, dy, ksize, scale, delta, borderType))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static bool ipp_scharr(InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, double scale, double delta, int borderType)
|
||||
{
|
||||
#if IPP_VERSION_MAJOR >= 7
|
||||
if (IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
@ -604,10 +485,8 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
CV_IPP_RUN(true, ipp_sobel(_src, _dst, ddepth, dx, dy, ksize, scale, delta, borderType));
|
||||
|
||||
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
|
||||
Mat kx, ky;
|
||||
@ -643,9 +522,7 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
CV_IPP_RUN(true, ipp_scharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType));
|
||||
|
||||
CV_IPP_RUN(true, IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType));
|
||||
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
|
||||
|
@ -1200,7 +1200,6 @@ public:
|
||||
*ok = false;
|
||||
return;
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
|
||||
for (int i = 0; i < histSize; ++i)
|
||||
CV_XADD((int *)(hist->data + i * hist->step), *(int *)(phist.data + i * phist.step));
|
||||
@ -1256,7 +1255,6 @@ static bool ipp_calchist(const Mat* images, int nimages, const int* channels,
|
||||
if (ok)
|
||||
{
|
||||
ihist.convertTo(hist, CV_32F);
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1375,7 +1375,7 @@ void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderT
|
||||
}
|
||||
|
||||
|
||||
#if 0 //#ifdef HAVE_IPP
|
||||
#ifdef HAVE_IPP
|
||||
namespace cv
|
||||
{
|
||||
static bool ipp_buildpyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel, int borderType )
|
||||
@ -1508,13 +1508,8 @@ void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel,
|
||||
|
||||
int i=1;
|
||||
|
||||
#if (IPP_VERSION_X100 >= 801 && 0)
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
CV_IPP_RUN(((IPP_VERSION_X100 >= 801 && 0) && (borderTypeNI == BORDER_DEFAULT && (!_src.isSubmatrix() || isolated))),
|
||||
CV_IPP_RUN(((IPP_VERSION_X100 >= 801 && 0) && ((borderType & ~BORDER_ISOLATED) == BORDER_DEFAULT && (!_src.isSubmatrix() || ((borderType & BORDER_ISOLATED) != 0)))),
|
||||
ipp_buildpyramid( _src, _dst, maxlevel, borderType));
|
||||
#endif
|
||||
|
||||
|
||||
for( ; i <= maxlevel; i++ )
|
||||
pyrDown( _dst.getMatRef(i-1), _dst.getMatRef(i), Size(), borderType );
|
||||
|
@ -1668,6 +1668,7 @@ static bool ipp_GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
|
||||
double sigma1, double sigma2,
|
||||
int borderType )
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
int type = _src.type();
|
||||
Size size = _src.size();
|
||||
|
||||
@ -1742,10 +1743,7 @@ static bool ipp_GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
|
||||
ippFree(pBuffer);
|
||||
|
||||
if(status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return true;
|
||||
}
|
||||
|
||||
#undef IPP_FILTER_GAUSS_C1
|
||||
#undef IPP_FILTER_GAUSS_CN
|
||||
@ -1753,6 +1751,9 @@ static bool ipp_GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(ksize); CV_UNUSED(sigma1); CV_UNUSED(sigma2); CV_UNUSED(borderType);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1788,10 +1789,8 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
|
||||
return;
|
||||
#endif
|
||||
|
||||
|
||||
CV_IPP_RUN(true, ipp_GaussianBlur( _src, _dst, ksize, sigma1, sigma2, borderType));
|
||||
|
||||
|
||||
Mat kx, ky;
|
||||
createGaussianKernels(kx, ky, type, ksize, sigma1, sigma2);
|
||||
sepFilter2D(_src, _dst, CV_MAT_DEPTH(type), kx, ky, Point(-1,-1), 0, borderType );
|
||||
@ -2754,6 +2753,8 @@ static bool ipp_medianFilter( InputArray _src0, OutputArray _dst, int ksize )
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp32f, ipp32f, 32f_C1R);
|
||||
}
|
||||
#undef IPP_FILTER_MEDIAN_BORDER
|
||||
#else
|
||||
CV_UNUSED(_src0); CV_UNUSED(_dst); CV_UNUSED(ksize);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user