Implementation detector and selector for IPP and OpenCL;
IPP can be switched on and off on runtime; Optional implementation collector was added (switched off by default in CMake). Gathers data of implementation used in functions and report this info through performance TS; TS modifications for implementations control;
This commit is contained in:
@@ -856,54 +856,60 @@ void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask )
|
||||
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
|
||||
|
||||
#if defined HAVE_IPP
|
||||
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && (mask.empty() || mask.isContinuous())))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiAdd)(const void * pSrc, int srcStep, Ipp32f * pSrcDst, int srcdstStep, IppiSize roiSize);
|
||||
typedef IppStatus (CV_STDCALL * ippiAddMask)(const void * pSrc, int srcStep, const Ipp8u * pMask, int maskStep, Ipp32f * pSrcDst,
|
||||
int srcDstStep, IppiSize roiSize);
|
||||
ippiAdd ippFunc = 0;
|
||||
ippiAddMask ippFuncMask = 0;
|
||||
|
||||
if (mask.empty())
|
||||
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && (mask.empty() || mask.isContinuous())))
|
||||
{
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAdd)ippiAdd_8u32f_C1IR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAdd)ippiAdd_16u32f_C1IR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAdd)ippiAdd_32f_C1IR : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
else if (scn == 1)
|
||||
{
|
||||
ippFuncMask = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddMask)ippiAdd_8u32f_C1IMR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddMask)ippiAdd_16u32f_C1IMR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddMask)ippiAdd_32f_C1IMR : 0;
|
||||
}
|
||||
|
||||
if (ippFunc || ippFuncMask)
|
||||
{
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
Size size = src.size();
|
||||
int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step;
|
||||
if (src.isContinuous() && dst.isContinuous() && mask.isContinuous())
|
||||
{
|
||||
srcstep = static_cast<int>(src.total() * src.elemSize());
|
||||
dststep = static_cast<int>(dst.total() * dst.elemSize());
|
||||
maskstep = static_cast<int>(mask.total() * mask.elemSize());
|
||||
size.width = static_cast<int>(src.total());
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
typedef IppStatus (CV_STDCALL * ippiAdd)(const void * pSrc, int srcStep, Ipp32f * pSrcDst, int srcdstStep, IppiSize roiSize);
|
||||
typedef IppStatus (CV_STDCALL * ippiAddMask)(const void * pSrc, int srcStep, const Ipp8u * pMask, int maskStep, Ipp32f * pSrcDst,
|
||||
int srcDstStep, IppiSize roiSize);
|
||||
ippiAdd ippFunc = 0;
|
||||
ippiAddMask ippFuncMask = 0;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src.ptr(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
else
|
||||
status = ippFuncMask(src.ptr(), srcstep, mask.ptr<Ipp8u>(), maskstep,
|
||||
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
{
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAdd)ippiAdd_8u32f_C1IR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAdd)ippiAdd_16u32f_C1IR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAdd)ippiAdd_32f_C1IR : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
else if (scn == 1)
|
||||
{
|
||||
ippFuncMask = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddMask)ippiAdd_8u32f_C1IMR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddMask)ippiAdd_16u32f_C1IMR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddMask)ippiAdd_32f_C1IMR : 0;
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
if (ippFunc || ippFuncMask)
|
||||
{
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
Size size = src.size();
|
||||
int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step;
|
||||
if (src.isContinuous() && dst.isContinuous() && mask.isContinuous())
|
||||
{
|
||||
srcstep = static_cast<int>(src.total() * src.elemSize());
|
||||
dststep = static_cast<int>(dst.total() * dst.elemSize());
|
||||
maskstep = static_cast<int>(mask.total() * mask.elemSize());
|
||||
size.width = static_cast<int>(src.total());
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src.ptr(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
else
|
||||
status = ippFuncMask(src.ptr(), srcstep, mask.ptr<Ipp8u>(), maskstep,
|
||||
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -935,52 +941,58 @@ void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _m
|
||||
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
|
||||
|
||||
#if defined(HAVE_IPP)
|
||||
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && (mask.empty() || mask.isContinuous())))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiAddSquare)(const void * pSrc, int srcStep, Ipp32f * pSrcDst, int srcdstStep, IppiSize roiSize);
|
||||
typedef IppStatus (CV_STDCALL * ippiAddSquareMask)(const void * pSrc, int srcStep, const Ipp8u * pMask, int maskStep, Ipp32f * pSrcDst,
|
||||
int srcDstStep, IppiSize roiSize);
|
||||
ippiAddSquare ippFunc = 0;
|
||||
ippiAddSquareMask ippFuncMask = 0;
|
||||
|
||||
if (mask.empty())
|
||||
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && (mask.empty() || mask.isContinuous())))
|
||||
{
|
||||
ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddSquare)ippiAddSquare_8u32f_C1IR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddSquare)ippiAddSquare_16u32f_C1IR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddSquare)ippiAddSquare_32f_C1IR : 0;
|
||||
}
|
||||
else if (scn == 1)
|
||||
{
|
||||
ippFuncMask = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddSquareMask)ippiAddSquare_8u32f_C1IMR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddSquareMask)ippiAddSquare_16u32f_C1IMR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddSquareMask)ippiAddSquare_32f_C1IMR : 0;
|
||||
}
|
||||
|
||||
if (ippFunc || ippFuncMask)
|
||||
{
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
Size size = src.size();
|
||||
int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step;
|
||||
if (src.isContinuous() && dst.isContinuous() && mask.isContinuous())
|
||||
{
|
||||
srcstep = static_cast<int>(src.total() * src.elemSize());
|
||||
dststep = static_cast<int>(dst.total() * dst.elemSize());
|
||||
maskstep = static_cast<int>(mask.total() * mask.elemSize());
|
||||
size.width = static_cast<int>(src.total());
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
typedef IppStatus (CV_STDCALL * ippiAddSquare)(const void * pSrc, int srcStep, Ipp32f * pSrcDst, int srcdstStep, IppiSize roiSize);
|
||||
typedef IppStatus (CV_STDCALL * ippiAddSquareMask)(const void * pSrc, int srcStep, const Ipp8u * pMask, int maskStep, Ipp32f * pSrcDst,
|
||||
int srcDstStep, IppiSize roiSize);
|
||||
ippiAddSquare ippFunc = 0;
|
||||
ippiAddSquareMask ippFuncMask = 0;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src.ptr(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
else
|
||||
status = ippFuncMask(src.ptr(), srcstep, mask.ptr<Ipp8u>(), maskstep,
|
||||
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
{
|
||||
ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddSquare)ippiAddSquare_8u32f_C1IR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddSquare)ippiAddSquare_16u32f_C1IR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddSquare)ippiAddSquare_32f_C1IR : 0;
|
||||
}
|
||||
else if (scn == 1)
|
||||
{
|
||||
ippFuncMask = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddSquareMask)ippiAddSquare_8u32f_C1IMR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddSquareMask)ippiAddSquare_16u32f_C1IMR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddSquareMask)ippiAddSquare_32f_C1IMR : 0;
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
if (ippFunc || ippFuncMask)
|
||||
{
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
Size size = src.size();
|
||||
int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step;
|
||||
if (src.isContinuous() && dst.isContinuous() && mask.isContinuous())
|
||||
{
|
||||
srcstep = static_cast<int>(src.total() * src.elemSize());
|
||||
dststep = static_cast<int>(dst.total() * dst.elemSize());
|
||||
maskstep = static_cast<int>(mask.total() * mask.elemSize());
|
||||
size.width = static_cast<int>(src.total());
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src.ptr(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
else
|
||||
status = ippFuncMask(src.ptr(), srcstep, mask.ptr<Ipp8u>(), maskstep,
|
||||
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1014,55 +1026,61 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2,
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
|
||||
|
||||
#if defined(HAVE_IPP)
|
||||
if (src1.dims <= 2 || (src1.isContinuous() && src2.isContinuous() && dst.isContinuous()))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiAddProduct)(const void * pSrc1, int src1Step, const void * pSrc2,
|
||||
int src2Step, Ipp32f * pSrcDst, int srcDstStep, IppiSize roiSize);
|
||||
typedef IppStatus (CV_STDCALL * ippiAddProductMask)(const void * pSrc1, int src1Step, const void * pSrc2, int src2Step,
|
||||
const Ipp8u * pMask, int maskStep, Ipp32f * pSrcDst, int srcDstStep, IppiSize roiSize);
|
||||
ippiAddProduct ippFunc = 0;
|
||||
ippiAddProductMask ippFuncMask = 0;
|
||||
|
||||
if (mask.empty())
|
||||
if (src1.dims <= 2 || (src1.isContinuous() && src2.isContinuous() && dst.isContinuous()))
|
||||
{
|
||||
ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddProduct)ippiAddProduct_8u32f_C1IR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddProduct)ippiAddProduct_16u32f_C1IR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddProduct)ippiAddProduct_32f_C1IR : 0;
|
||||
}
|
||||
else if (scn == 1)
|
||||
{
|
||||
ippFuncMask = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddProductMask)ippiAddProduct_8u32f_C1IMR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddProductMask)ippiAddProduct_16u32f_C1IMR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddProductMask)ippiAddProduct_32f_C1IMR : 0;
|
||||
}
|
||||
|
||||
if (ippFunc || ippFuncMask)
|
||||
{
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
Size size = src1.size();
|
||||
int src1step = (int)src1.step, src2step = (int)src2.step, dststep = (int)dst.step, maskstep = (int)mask.step;
|
||||
if (src1.isContinuous() && src2.isContinuous() && dst.isContinuous() && mask.isContinuous())
|
||||
{
|
||||
src1step = static_cast<int>(src1.total() * src1.elemSize());
|
||||
src2step = static_cast<int>(src2.total() * src2.elemSize());
|
||||
dststep = static_cast<int>(dst.total() * dst.elemSize());
|
||||
maskstep = static_cast<int>(mask.total() * mask.elemSize());
|
||||
size.width = static_cast<int>(src1.total());
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
typedef IppStatus (CV_STDCALL * ippiAddProduct)(const void * pSrc1, int src1Step, const void * pSrc2,
|
||||
int src2Step, Ipp32f * pSrcDst, int srcDstStep, IppiSize roiSize);
|
||||
typedef IppStatus (CV_STDCALL * ippiAddProductMask)(const void * pSrc1, int src1Step, const void * pSrc2, int src2Step,
|
||||
const Ipp8u * pMask, int maskStep, Ipp32f * pSrcDst, int srcDstStep, IppiSize roiSize);
|
||||
ippiAddProduct ippFunc = 0;
|
||||
ippiAddProductMask ippFuncMask = 0;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src1.ptr(), src1step, src2.ptr(), src2step, dst.ptr<Ipp32f>(),
|
||||
dststep, ippiSize(size.width, size.height));
|
||||
else
|
||||
status = ippFuncMask(src1.ptr(), src1step, src2.ptr(), src2step, mask.ptr<Ipp8u>(), maskstep,
|
||||
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
{
|
||||
ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddProduct)ippiAddProduct_8u32f_C1IR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddProduct)ippiAddProduct_16u32f_C1IR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddProduct)ippiAddProduct_32f_C1IR : 0;
|
||||
}
|
||||
else if (scn == 1)
|
||||
{
|
||||
ippFuncMask = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddProductMask)ippiAddProduct_8u32f_C1IMR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddProductMask)ippiAddProduct_16u32f_C1IMR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddProductMask)ippiAddProduct_32f_C1IMR : 0;
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
if (ippFunc || ippFuncMask)
|
||||
{
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
Size size = src1.size();
|
||||
int src1step = (int)src1.step, src2step = (int)src2.step, dststep = (int)dst.step, maskstep = (int)mask.step;
|
||||
if (src1.isContinuous() && src2.isContinuous() && dst.isContinuous() && mask.isContinuous())
|
||||
{
|
||||
src1step = static_cast<int>(src1.total() * src1.elemSize());
|
||||
src2step = static_cast<int>(src2.total() * src2.elemSize());
|
||||
dststep = static_cast<int>(dst.total() * dst.elemSize());
|
||||
maskstep = static_cast<int>(mask.total() * mask.elemSize());
|
||||
size.width = static_cast<int>(src1.total());
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src1.ptr(), src1step, src2.ptr(), src2step, dst.ptr<Ipp32f>(),
|
||||
dststep, ippiSize(size.width, size.height));
|
||||
else
|
||||
status = ippFuncMask(src1.ptr(), src1step, src2.ptr(), src2step, mask.ptr<Ipp8u>(), maskstep,
|
||||
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1095,54 +1113,60 @@ void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst,
|
||||
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
|
||||
|
||||
#if defined(HAVE_IPP)
|
||||
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && mask.isContinuous()))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiAddWeighted)(const void * pSrc, int srcStep, Ipp32f * pSrcDst, int srcdstStep,
|
||||
IppiSize roiSize, Ipp32f alpha);
|
||||
typedef IppStatus (CV_STDCALL * ippiAddWeightedMask)(const void * pSrc, int srcStep, const Ipp8u * pMask,
|
||||
int maskStep, Ipp32f * pSrcDst,
|
||||
int srcDstStep, IppiSize roiSize, Ipp32f alpha);
|
||||
ippiAddWeighted ippFunc = 0;
|
||||
ippiAddWeightedMask ippFuncMask = 0;
|
||||
|
||||
if (mask.empty())
|
||||
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && mask.isContinuous()))
|
||||
{
|
||||
ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddWeighted)ippiAddWeighted_8u32f_C1IR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddWeighted)ippiAddWeighted_16u32f_C1IR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddWeighted)ippiAddWeighted_32f_C1IR : 0;
|
||||
}
|
||||
else if (scn == 1)
|
||||
{
|
||||
ippFuncMask = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddWeightedMask)ippiAddWeighted_8u32f_C1IMR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddWeightedMask)ippiAddWeighted_16u32f_C1IMR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddWeightedMask)ippiAddWeighted_32f_C1IMR : 0;
|
||||
}
|
||||
|
||||
if (ippFunc || ippFuncMask)
|
||||
{
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
Size size = src.size();
|
||||
int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step;
|
||||
if (src.isContinuous() && dst.isContinuous() && mask.isContinuous())
|
||||
{
|
||||
srcstep = static_cast<int>(src.total() * src.elemSize());
|
||||
dststep = static_cast<int>(dst.total() * dst.elemSize());
|
||||
maskstep = static_cast<int>(mask.total() * mask.elemSize());
|
||||
size.width = static_cast<int>((int)src.total());
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
typedef IppStatus (CV_STDCALL * ippiAddWeighted)(const void * pSrc, int srcStep, Ipp32f * pSrcDst, int srcdstStep,
|
||||
IppiSize roiSize, Ipp32f alpha);
|
||||
typedef IppStatus (CV_STDCALL * ippiAddWeightedMask)(const void * pSrc, int srcStep, const Ipp8u * pMask,
|
||||
int maskStep, Ipp32f * pSrcDst,
|
||||
int srcDstStep, IppiSize roiSize, Ipp32f alpha);
|
||||
ippiAddWeighted ippFunc = 0;
|
||||
ippiAddWeightedMask ippFuncMask = 0;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src.ptr(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height), (Ipp32f)alpha);
|
||||
else
|
||||
status = ippFuncMask(src.ptr(), srcstep, mask.ptr<Ipp8u>(), maskstep,
|
||||
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height), (Ipp32f)alpha);
|
||||
{
|
||||
ippFunc = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddWeighted)ippiAddWeighted_8u32f_C1IR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddWeighted)ippiAddWeighted_16u32f_C1IR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddWeighted)ippiAddWeighted_32f_C1IR : 0;
|
||||
}
|
||||
else if (scn == 1)
|
||||
{
|
||||
ippFuncMask = sdepth == CV_8U && ddepth == CV_32F ? (ippiAddWeightedMask)ippiAddWeighted_8u32f_C1IMR :
|
||||
sdepth == CV_16U && ddepth == CV_32F ? (ippiAddWeightedMask)ippiAddWeighted_16u32f_C1IMR :
|
||||
sdepth == CV_32F && ddepth == CV_32F ? (ippiAddWeightedMask)ippiAddWeighted_32f_C1IMR : 0;
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
if (ippFunc || ippFuncMask)
|
||||
{
|
||||
IppStatus status = ippStsNoErr;
|
||||
|
||||
Size size = src.size();
|
||||
int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step;
|
||||
if (src.isContinuous() && dst.isContinuous() && mask.isContinuous())
|
||||
{
|
||||
srcstep = static_cast<int>(src.total() * src.elemSize());
|
||||
dststep = static_cast<int>(dst.total() * dst.elemSize());
|
||||
maskstep = static_cast<int>(mask.total() * mask.elemSize());
|
||||
size.width = static_cast<int>((int)src.total());
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src.ptr(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height), (Ipp32f)alpha);
|
||||
else
|
||||
status = ippFuncMask(src.ptr(), srcstep, mask.ptr<Ipp8u>(), maskstep,
|
||||
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height), (Ipp32f)alpha);
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -265,11 +265,17 @@ void cv::Canny( InputArray _src, OutputArray _dst,
|
||||
#endif
|
||||
|
||||
#ifdef USE_IPP_CANNY
|
||||
if( aperture_size == 3 && !L2gradient && 1 == cn )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (ippCanny(src, dst, (float)low_thresh, (float)high_thresh))
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
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
|
||||
|
||||
|
@@ -404,7 +404,10 @@ namespace
|
||||
#ifdef HAVE_OPENCL
|
||||
if (useOpenCL && clahe::calcLut(_srcForLut, ulut_, tilesX_, tilesY_, tileSize, clipLimit, lutScale) )
|
||||
if( clahe::transform(_src, _dst, ulut_, tilesX_, tilesY_, tileSize) )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_OCL);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
cv::Mat src = _src.getMat();
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -472,56 +472,62 @@ void cv::cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, in
|
||||
_dst.create( src.size(), CV_32FC1 );
|
||||
Mat dst = _dst.getMat();
|
||||
#if defined(HAVE_IPP) && (IPP_VERSION_MAJOR >= 8)
|
||||
typedef IppStatus (CV_STDCALL * ippiMinEigenValGetBufferSize)(IppiSize, int, int, int*);
|
||||
typedef IppStatus (CV_STDCALL * ippiMinEigenVal)(const void*, int, Ipp32f*, int, IppiSize, IppiKernelType, int, int, Ipp8u*);
|
||||
IppiKernelType kerType;
|
||||
int kerSize = ksize;
|
||||
if (ksize < 0)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
kerType = ippKernelScharr;
|
||||
kerSize = 3;
|
||||
} else
|
||||
{
|
||||
kerType = ippKernelSobel;
|
||||
}
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
if ((borderTypeNI == BORDER_REPLICATE && (!src.isSubmatrix() || isolated)) &&
|
||||
(kerSize == 3 || kerSize == 5) && (blockSize == 3 || blockSize == 5))
|
||||
{
|
||||
ippiMinEigenValGetBufferSize getBufferSizeFunc = 0;
|
||||
ippiMinEigenVal minEigenValFunc = 0;
|
||||
float norm_coef = 0.f;
|
||||
|
||||
if (src.type() == CV_8UC1)
|
||||
typedef IppStatus (CV_STDCALL * ippiMinEigenValGetBufferSize)(IppiSize, int, int, int*);
|
||||
typedef IppStatus (CV_STDCALL * ippiMinEigenVal)(const void*, int, Ipp32f*, int, IppiSize, IppiKernelType, int, int, Ipp8u*);
|
||||
IppiKernelType kerType;
|
||||
int kerSize = ksize;
|
||||
if (ksize < 0)
|
||||
{
|
||||
getBufferSizeFunc = (ippiMinEigenValGetBufferSize) ippiMinEigenValGetBufferSize_8u32f_C1R;
|
||||
minEigenValFunc = (ippiMinEigenVal) ippiMinEigenVal_8u32f_C1R;
|
||||
norm_coef = 1.f / 255.f;
|
||||
} else if (src.type() == CV_32FC1)
|
||||
kerType = ippKernelScharr;
|
||||
kerSize = 3;
|
||||
} else
|
||||
{
|
||||
getBufferSizeFunc = (ippiMinEigenValGetBufferSize) ippiMinEigenValGetBufferSize_32f_C1R;
|
||||
minEigenValFunc = (ippiMinEigenVal) ippiMinEigenVal_32f_C1R;
|
||||
norm_coef = 255.f;
|
||||
kerType = ippKernelSobel;
|
||||
}
|
||||
norm_coef = kerType == ippKernelSobel ? norm_coef : norm_coef / 2.45f;
|
||||
|
||||
if (getBufferSizeFunc && minEigenValFunc)
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
if ((borderTypeNI == BORDER_REPLICATE && (!src.isSubmatrix() || isolated)) &&
|
||||
(kerSize == 3 || kerSize == 5) && (blockSize == 3 || blockSize == 5))
|
||||
{
|
||||
int bufferSize;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppStatus ok = getBufferSizeFunc(srcRoi, kerSize, blockSize, &bufferSize);
|
||||
if (ok >= 0)
|
||||
ippiMinEigenValGetBufferSize getBufferSizeFunc = 0;
|
||||
ippiMinEigenVal minEigenValFunc = 0;
|
||||
float norm_coef = 0.f;
|
||||
|
||||
if (src.type() == CV_8UC1)
|
||||
{
|
||||
AutoBuffer<uchar> buffer(bufferSize);
|
||||
ok = minEigenValFunc(src.ptr(), (int) src.step, dst.ptr<Ipp32f>(), (int) dst.step, srcRoi, kerType, kerSize, blockSize, buffer);
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
if (ok >= 0) ok = ippiMulC_32f_C1IR(norm_coef, dst.ptr<Ipp32f>(), (int) dst.step, srcRoi);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
return;
|
||||
getBufferSizeFunc = (ippiMinEigenValGetBufferSize) ippiMinEigenValGetBufferSize_8u32f_C1R;
|
||||
minEigenValFunc = (ippiMinEigenVal) ippiMinEigenVal_8u32f_C1R;
|
||||
norm_coef = 1.f / 255.f;
|
||||
} else if (src.type() == CV_32FC1)
|
||||
{
|
||||
getBufferSizeFunc = (ippiMinEigenValGetBufferSize) ippiMinEigenValGetBufferSize_32f_C1R;
|
||||
minEigenValFunc = (ippiMinEigenVal) ippiMinEigenVal_32f_C1R;
|
||||
norm_coef = 255.f;
|
||||
}
|
||||
norm_coef = kerType == ippKernelSobel ? norm_coef : norm_coef / 2.45f;
|
||||
|
||||
if (getBufferSizeFunc && minEigenValFunc)
|
||||
{
|
||||
int bufferSize;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppStatus ok = getBufferSizeFunc(srcRoi, kerSize, blockSize, &bufferSize);
|
||||
if (ok >= 0)
|
||||
{
|
||||
AutoBuffer<uchar> buffer(bufferSize);
|
||||
ok = minEigenValFunc(src.ptr(), (int) src.step, dst.ptr<Ipp32f>(), (int) dst.step, srcRoi, kerType, kerSize, blockSize, buffer);
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
if (ok >= 0) ok = ippiMulC_32f_C1IR(norm_coef, dst.ptr<Ipp32f>(), (int) dst.step, srcRoi);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -538,44 +544,50 @@ void cv::cornerHarris( InputArray _src, OutputArray _dst, int blockSize, int ksi
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
|
||||
if ( (ksize == 3 || ksize == 5) && (type == CV_8UC1 || type == CV_32FC1) &&
|
||||
(borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE) && cn == 1 && (!src.isSubmatrix() || isolated) )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize roisize = { src.cols, src.rows };
|
||||
IppiMaskSize masksize = ksize == 5 ? ippMskSize5x5 : ippMskSize3x3;
|
||||
IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp32f;
|
||||
Ipp32s bufsize = 0;
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
|
||||
double scale = (double)(1 << ((ksize > 0 ? ksize : 3) - 1)) * blockSize;
|
||||
if (ksize < 0)
|
||||
scale *= 2.0;
|
||||
if (depth == CV_8U)
|
||||
scale *= 255.0;
|
||||
scale = std::pow(scale, -4.0);
|
||||
|
||||
if (ippiHarrisCornerGetBufferSize(roisize, masksize, blockSize, datatype, cn, &bufsize) >= 0)
|
||||
if ( (ksize == 3 || ksize == 5) && (type == CV_8UC1 || type == CV_32FC1) &&
|
||||
(borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE) && cn == 1 && (!src.isSubmatrix() || isolated) )
|
||||
{
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufsize);
|
||||
IppiDifferentialKernel filterType = ksize > 0 ? ippFilterSobel : ippFilterScharr;
|
||||
IppiBorderType borderTypeIpp = borderTypeNI == BORDER_CONSTANT ? ippBorderConst : ippBorderRepl;
|
||||
IppStatus status = (IppStatus)-1;
|
||||
IppiSize roisize = { src.cols, src.rows };
|
||||
IppiMaskSize masksize = ksize == 5 ? ippMskSize5x5 : ippMskSize3x3;
|
||||
IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp32f;
|
||||
Ipp32s bufsize = 0;
|
||||
|
||||
double scale = (double)(1 << ((ksize > 0 ? ksize : 3) - 1)) * blockSize;
|
||||
if (ksize < 0)
|
||||
scale *= 2.0;
|
||||
if (depth == CV_8U)
|
||||
status = ippiHarrisCorner_8u32f_C1R((const Ipp8u *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize,
|
||||
filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer);
|
||||
else if (depth == CV_32F)
|
||||
status = ippiHarrisCorner_32f_C1R((const Ipp32f *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize,
|
||||
filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer);
|
||||
ippsFree(buffer);
|
||||
scale *= 255.0;
|
||||
scale = std::pow(scale, -4.0);
|
||||
|
||||
if (status >= 0)
|
||||
return;
|
||||
if (ippiHarrisCornerGetBufferSize(roisize, masksize, blockSize, datatype, cn, &bufsize) >= 0)
|
||||
{
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufsize);
|
||||
IppiDifferentialKernel filterType = ksize > 0 ? ippFilterSobel : ippFilterScharr;
|
||||
IppiBorderType borderTypeIpp = borderTypeNI == BORDER_CONSTANT ? ippBorderConst : ippBorderRepl;
|
||||
IppStatus status = (IppStatus)-1;
|
||||
|
||||
if (depth == CV_8U)
|
||||
status = ippiHarrisCorner_8u32f_C1R((const Ipp8u *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize,
|
||||
filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer);
|
||||
else if (depth == CV_32F)
|
||||
status = ippiHarrisCorner_32f_C1R((const Ipp32f *)src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, roisize,
|
||||
filterType, masksize, blockSize, (Ipp32f)k, (Ipp32f)scale, borderTypeIpp, 0, buffer);
|
||||
ippsFree(buffer);
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -573,15 +573,24 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
if (ksize < 0)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType))
|
||||
return;
|
||||
}
|
||||
else if (0 < ksize)
|
||||
{
|
||||
if (IPPDerivSobel(_src, _dst, ddepth, dx, dy, ksize, scale, delta, borderType))
|
||||
return;
|
||||
if (ksize < 0)
|
||||
{
|
||||
if (IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (0 < ksize)
|
||||
{
|
||||
if (IPPDerivSobel(_src, _dst, ddepth, dx, dy, ksize, scale, delta, borderType))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
@@ -620,8 +629,14 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
if (IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType))
|
||||
return;
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (IPPDerivScharr(_src, _dst, ddepth, dx, dy, scale, delta, borderType))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
|
||||
|
||||
@@ -793,62 +808,68 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
|
||||
_dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) );
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
if ((ksize == 3 || ksize == 5) && ((borderType & BORDER_ISOLATED) != 0 || !_src.isSubmatrix()) &&
|
||||
((stype == CV_8UC1 && ddepth == CV_16S) || (ddepth == CV_32F && stype == CV_32FC1)) && !ocl::useOpenCL())
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
int iscale = saturate_cast<int>(scale), idelta = saturate_cast<int>(delta);
|
||||
bool floatScale = std::fabs(scale - iscale) > DBL_EPSILON, needScale = iscale != 1;
|
||||
bool floatDelta = std::fabs(delta - idelta) > DBL_EPSILON, needDelta = delta != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
Mat src = _src.getMat(), dst = _dst.getMat();
|
||||
|
||||
if (src.data != dst.data)
|
||||
if ((ksize == 3 || ksize == 5) && ((borderType & BORDER_ISOLATED) != 0 || !_src.isSubmatrix()) &&
|
||||
((stype == CV_8UC1 && ddepth == CV_16S) || (ddepth == CV_32F && stype == CV_32FC1)) && !ocl::useOpenCL())
|
||||
{
|
||||
Ipp32s bufsize;
|
||||
IppStatus status = (IppStatus)-1;
|
||||
IppiSize roisize = { src.cols, src.rows };
|
||||
IppiMaskSize masksize = ksize == 3 ? ippMskSize3x3 : ippMskSize5x5;
|
||||
IppiBorderType borderTypeIpp = ippiGetBorderType(borderTypeNI);
|
||||
int iscale = saturate_cast<int>(scale), idelta = saturate_cast<int>(delta);
|
||||
bool floatScale = std::fabs(scale - iscale) > DBL_EPSILON, needScale = iscale != 1;
|
||||
bool floatDelta = std::fabs(delta - idelta) > DBL_EPSILON, needDelta = delta != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
Mat src = _src.getMat(), dst = _dst.getMat();
|
||||
|
||||
if (src.data != dst.data)
|
||||
{
|
||||
Ipp32s bufsize;
|
||||
IppStatus status = (IppStatus)-1;
|
||||
IppiSize roisize = { src.cols, src.rows };
|
||||
IppiMaskSize masksize = ksize == 3 ? ippMskSize3x3 : ippMskSize5x5;
|
||||
IppiBorderType borderTypeIpp = ippiGetBorderType(borderTypeNI);
|
||||
|
||||
#define IPP_FILTER_LAPLACIAN(ippsrctype, ippdsttype, ippfavor) \
|
||||
do \
|
||||
{ \
|
||||
if (borderTypeIpp >= 0 && ippiFilterLaplacianGetBufferSize_##ippfavor##_C1R(roisize, masksize, &bufsize) >= 0) \
|
||||
do \
|
||||
{ \
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufsize); \
|
||||
status = ippiFilterLaplacianBorder_##ippfavor##_C1R(src.ptr<ippsrctype>(), (int)src.step, dst.ptr<ippdsttype>(), \
|
||||
(int)dst.step, roisize, masksize, borderTypeIpp, 0, buffer); \
|
||||
ippsFree(buffer); \
|
||||
} \
|
||||
} while ((void)0, 0)
|
||||
if (borderTypeIpp >= 0 && ippiFilterLaplacianGetBufferSize_##ippfavor##_C1R(roisize, masksize, &bufsize) >= 0) \
|
||||
{ \
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufsize); \
|
||||
status = ippiFilterLaplacianBorder_##ippfavor##_C1R(src.ptr<ippsrctype>(), (int)src.step, dst.ptr<ippdsttype>(), \
|
||||
(int)dst.step, roisize, masksize, borderTypeIpp, 0, buffer); \
|
||||
ippsFree(buffer); \
|
||||
} \
|
||||
} while ((void)0, 0)
|
||||
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
if (sdepth == CV_8U && ddepth == CV_16S && !floatScale && !floatDelta)
|
||||
{
|
||||
IPP_FILTER_LAPLACIAN(Ipp8u, Ipp16s, 8u16s);
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
if (sdepth == CV_8U && ddepth == CV_16S && !floatScale && !floatDelta)
|
||||
{
|
||||
IPP_FILTER_LAPLACIAN(Ipp8u, Ipp16s, 8u16s);
|
||||
|
||||
if (needScale && status >= 0)
|
||||
status = ippiMulC_16s_C1IRSfs((Ipp16s)iscale, dst.ptr<Ipp16s>(), (int)dst.step, roisize, 0);
|
||||
if (needDelta && status >= 0)
|
||||
status = ippiAddC_16s_C1IRSfs((Ipp16s)idelta, dst.ptr<Ipp16s>(), (int)dst.step, roisize, 0);
|
||||
if (needScale && status >= 0)
|
||||
status = ippiMulC_16s_C1IRSfs((Ipp16s)iscale, dst.ptr<Ipp16s>(), (int)dst.step, roisize, 0);
|
||||
if (needDelta && status >= 0)
|
||||
status = ippiAddC_16s_C1IRSfs((Ipp16s)idelta, dst.ptr<Ipp16s>(), (int)dst.step, roisize, 0);
|
||||
}
|
||||
else if (sdepth == CV_32F && ddepth == CV_32F)
|
||||
{
|
||||
IPP_FILTER_LAPLACIAN(Ipp32f, Ipp32f, 32f);
|
||||
|
||||
if (needScale && status >= 0)
|
||||
status = ippiMulC_32f_C1IR((Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, roisize);
|
||||
if (needDelta && status >= 0)
|
||||
status = ippiAddC_32f_C1IR((Ipp32f)delta, dst.ptr<Ipp32f>(), (int)dst.step, roisize);
|
||||
}
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if (status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
else if (sdepth == CV_32F && ddepth == CV_32F)
|
||||
{
|
||||
IPP_FILTER_LAPLACIAN(Ipp32f, Ipp32f, 32f);
|
||||
|
||||
if (needScale && status >= 0)
|
||||
status = ippiMulC_32f_C1IR((Ipp32f)scale, dst.ptr<Ipp32f>(), (int)dst.step, roisize);
|
||||
if (needDelta && status >= 0)
|
||||
status = ippiAddC_32f_C1IR((Ipp32f)delta, dst.ptr<Ipp32f>(), (int)dst.step, roisize);
|
||||
}
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if (status >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#undef IPP_FILTER_LAPLACIAN
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
|
@@ -688,13 +688,19 @@ static void distanceTransform_L1_8U(InputArray _src, OutputArray _dst)
|
||||
_dst.create( src.size(), CV_8UC1);
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
#ifdef HAVE_IPP
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize roi = { src.cols, src.rows };
|
||||
Ipp32s pMetrics[2] = { 1, 2 }; //L1, 3x3 mask
|
||||
if (ippiDistanceTransform_3x3_8u_C1R(src.ptr<uchar>(), (int)src.step, dst.ptr<uchar>(), (int)dst.step, roi, pMetrics)>=0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
distanceATS_L1_8u(src, dst);
|
||||
}
|
||||
@@ -735,22 +741,28 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe
|
||||
{
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
if ((currentParallelFramework()==NULL) || (src.total()<(int)(1<<14)))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppStatus status;
|
||||
IppiSize roi = { src.cols, src.rows };
|
||||
Ipp8u *pBuffer;
|
||||
int bufSize=0;
|
||||
|
||||
status = ippiTrueDistanceTransformGetBufferSize_8u32f_C1R(roi, &bufSize);
|
||||
if (status>=0)
|
||||
if ((currentParallelFramework()==NULL) || (src.total()<(int)(1<<14)))
|
||||
{
|
||||
pBuffer = (Ipp8u *)ippMalloc( bufSize );
|
||||
status = ippiTrueDistanceTransform_8u32f_C1R(src.ptr<uchar>(),(int)src.step, dst.ptr<float>(), (int)dst.step, roi, pBuffer);
|
||||
ippFree( pBuffer );
|
||||
IppStatus status;
|
||||
IppiSize roi = { src.cols, src.rows };
|
||||
Ipp8u *pBuffer;
|
||||
int bufSize=0;
|
||||
|
||||
status = ippiTrueDistanceTransformGetBufferSize_8u32f_C1R(roi, &bufSize);
|
||||
if (status>=0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
{
|
||||
pBuffer = (Ipp8u *)ippMalloc( bufSize );
|
||||
status = ippiTrueDistanceTransform_8u32f_C1R(src.ptr<uchar>(),(int)src.step, dst.ptr<float>(), (int)dst.step, roi, pBuffer);
|
||||
ippFree( pBuffer );
|
||||
if (status>=0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -773,23 +785,35 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe
|
||||
{
|
||||
if( maskSize == CV_DIST_MASK_3 )
|
||||
{
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize roi = { src.cols, src.rows };
|
||||
if (ippiDistanceTransform_3x3_8u32f_C1R(src.ptr<uchar>(), (int)src.step, dst.ptr<float>(), (int)dst.step, roi, _mask)>=0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
distanceTransform_3x3(src, temp, dst, _mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
IppiSize roi = { src.cols, src.rows };
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize roi = { src.cols, src.rows };
|
||||
if (ippiDistanceTransform_5x5_8u32f_C1R(src.ptr<uchar>(), (int)src.step, dst.ptr<float>(), (int)dst.step, roi, _mask)>=0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
distanceTransform_5x5(src, temp, dst, _mask);
|
||||
}
|
||||
|
@@ -1423,9 +1423,12 @@ struct RowVec_32f
|
||||
int operator()(const uchar* _src, uchar* _dst, int width, int cn) const
|
||||
{
|
||||
#if defined USE_IPP_SEP_FILTERS && 0
|
||||
int ret = ippiOperator(_src, _dst, width, cn);
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
int ret = ippiOperator(_src, _dst, width, cn);
|
||||
if (ret > 0)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
int _ksize = kernel.rows + kernel.cols - 1;
|
||||
const float* src0 = (const float*)_src;
|
||||
@@ -1494,6 +1497,7 @@ private:
|
||||
setIppErrorStatus();
|
||||
return 0;
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return width - _ksize + 1;
|
||||
}
|
||||
#endif
|
||||
@@ -3743,67 +3747,73 @@ void cv::filter2D( InputArray _src, OutputArray _dst, int ddepth,
|
||||
Point anchor = normalizeAnchor(anchor0, kernel.size());
|
||||
|
||||
#if IPP_VERSION_X100 > 0 && !defined HAVE_IPP_ICV_ONLY
|
||||
typedef IppStatus (CV_STDCALL * ippiFilterBorder)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize dstRoiSize,
|
||||
IppiBorderType border, const void * borderValue,
|
||||
const IppiFilterBorderSpec* pSpec, Ipp8u* pBuffer);
|
||||
|
||||
int stype = src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype),
|
||||
ktype = kernel.type(), kdepth = CV_MAT_DEPTH(ktype);
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
Point ippAnchor(kernel.cols >> 1, kernel.rows >> 1);
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
IppiBorderType ippBorderType = ippiGetBorderType(borderTypeNI);
|
||||
|
||||
if (borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
ippiFilterBorder ippFunc =
|
||||
stype == CV_8UC1 ? (ippiFilterBorder)ippiFilterBorder_8u_C1R :
|
||||
stype == CV_8UC3 ? (ippiFilterBorder)ippiFilterBorder_8u_C3R :
|
||||
stype == CV_8UC4 ? (ippiFilterBorder)ippiFilterBorder_8u_C4R :
|
||||
stype == CV_16UC1 ? (ippiFilterBorder)ippiFilterBorder_16u_C1R :
|
||||
stype == CV_16UC3 ? (ippiFilterBorder)ippiFilterBorder_16u_C3R :
|
||||
stype == CV_16UC4 ? (ippiFilterBorder)ippiFilterBorder_16u_C4R :
|
||||
stype == CV_16SC1 ? (ippiFilterBorder)ippiFilterBorder_16s_C1R :
|
||||
stype == CV_16SC3 ? (ippiFilterBorder)ippiFilterBorder_16s_C3R :
|
||||
stype == CV_16SC4 ? (ippiFilterBorder)ippiFilterBorder_16s_C4R :
|
||||
stype == CV_32FC1 ? (ippiFilterBorder)ippiFilterBorder_32f_C1R :
|
||||
stype == CV_32FC3 ? (ippiFilterBorder)ippiFilterBorder_32f_C3R :
|
||||
stype == CV_32FC4 ? (ippiFilterBorder)ippiFilterBorder_32f_C4R : 0;
|
||||
typedef IppStatus (CV_STDCALL * ippiFilterBorder)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize dstRoiSize,
|
||||
IppiBorderType border, const void * borderValue,
|
||||
const IppiFilterBorderSpec* pSpec, Ipp8u* pBuffer);
|
||||
|
||||
if (sdepth == ddepth && (ktype == CV_16SC1 || ktype == CV_32FC1) &&
|
||||
ippFunc && (int)ippBorderType >= 0 && (!src.isSubmatrix() || isolated) &&
|
||||
std::fabs(delta - 0) < DBL_EPSILON && ippAnchor == anchor && dst.data != src.data)
|
||||
int stype = src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype),
|
||||
ktype = kernel.type(), kdepth = CV_MAT_DEPTH(ktype);
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
Point ippAnchor(kernel.cols >> 1, kernel.rows >> 1);
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
IppiBorderType ippBorderType = ippiGetBorderType(borderTypeNI);
|
||||
|
||||
if (borderTypeNI == BORDER_CONSTANT || borderTypeNI == BORDER_REPLICATE)
|
||||
{
|
||||
IppiSize kernelSize = { kernel.cols, kernel.rows }, dstRoiSize = { dst.cols, dst.rows };
|
||||
IppDataType dataType = ippiGetDataType(ddepth), kernelType = ippiGetDataType(kdepth);
|
||||
Ipp32s specSize = 0, bufsize = 0;
|
||||
IppStatus status = (IppStatus)-1;
|
||||
ippiFilterBorder ippFunc =
|
||||
stype == CV_8UC1 ? (ippiFilterBorder)ippiFilterBorder_8u_C1R :
|
||||
stype == CV_8UC3 ? (ippiFilterBorder)ippiFilterBorder_8u_C3R :
|
||||
stype == CV_8UC4 ? (ippiFilterBorder)ippiFilterBorder_8u_C4R :
|
||||
stype == CV_16UC1 ? (ippiFilterBorder)ippiFilterBorder_16u_C1R :
|
||||
stype == CV_16UC3 ? (ippiFilterBorder)ippiFilterBorder_16u_C3R :
|
||||
stype == CV_16UC4 ? (ippiFilterBorder)ippiFilterBorder_16u_C4R :
|
||||
stype == CV_16SC1 ? (ippiFilterBorder)ippiFilterBorder_16s_C1R :
|
||||
stype == CV_16SC3 ? (ippiFilterBorder)ippiFilterBorder_16s_C3R :
|
||||
stype == CV_16SC4 ? (ippiFilterBorder)ippiFilterBorder_16s_C4R :
|
||||
stype == CV_32FC1 ? (ippiFilterBorder)ippiFilterBorder_32f_C1R :
|
||||
stype == CV_32FC3 ? (ippiFilterBorder)ippiFilterBorder_32f_C3R :
|
||||
stype == CV_32FC4 ? (ippiFilterBorder)ippiFilterBorder_32f_C4R : 0;
|
||||
|
||||
if ((status = ippiFilterBorderGetSize(kernelSize, dstRoiSize, dataType, kernelType, cn, &specSize, &bufsize)) >= 0)
|
||||
if (sdepth == ddepth && (ktype == CV_16SC1 || ktype == CV_32FC1) &&
|
||||
ippFunc && (int)ippBorderType >= 0 && (!src.isSubmatrix() || isolated) &&
|
||||
std::fabs(delta - 0) < DBL_EPSILON && ippAnchor == anchor && dst.data != src.data)
|
||||
{
|
||||
IppiFilterBorderSpec * spec = (IppiFilterBorderSpec *)ippMalloc(specSize);
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufsize);
|
||||
Ipp32f borderValue[4] = { 0, 0, 0, 0 };
|
||||
IppiSize kernelSize = { kernel.cols, kernel.rows }, dstRoiSize = { dst.cols, dst.rows };
|
||||
IppDataType dataType = ippiGetDataType(ddepth), kernelType = ippiGetDataType(kdepth);
|
||||
Ipp32s specSize = 0, bufsize = 0;
|
||||
IppStatus status = (IppStatus)-1;
|
||||
|
||||
Mat reversedKernel;
|
||||
flip(kernel, reversedKernel, -1);
|
||||
|
||||
if ((kdepth == CV_32F && (status = ippiFilterBorderInit_32f((const Ipp32f *)reversedKernel.data, kernelSize,
|
||||
dataType, cn, ippRndFinancial, spec)) >= 0 ) ||
|
||||
(kdepth == CV_16S && (status = ippiFilterBorderInit_16s((const Ipp16s *)reversedKernel.data,
|
||||
kernelSize, 0, dataType, cn, ippRndFinancial, spec)) >= 0))
|
||||
if ((status = ippiFilterBorderGetSize(kernelSize, dstRoiSize, dataType, kernelType, cn, &specSize, &bufsize)) >= 0)
|
||||
{
|
||||
status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, dstRoiSize,
|
||||
ippBorderType, borderValue, spec, buffer);
|
||||
IppiFilterBorderSpec * spec = (IppiFilterBorderSpec *)ippMalloc(specSize);
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufsize);
|
||||
Ipp32f borderValue[4] = { 0, 0, 0, 0 };
|
||||
|
||||
Mat reversedKernel;
|
||||
flip(kernel, reversedKernel, -1);
|
||||
|
||||
if ((kdepth == CV_32F && (status = ippiFilterBorderInit_32f((const Ipp32f *)reversedKernel.data, kernelSize,
|
||||
dataType, cn, ippRndFinancial, spec)) >= 0 ) ||
|
||||
(kdepth == CV_16S && (status = ippiFilterBorderInit_16s((const Ipp16s *)reversedKernel.data,
|
||||
kernelSize, 0, dataType, cn, ippRndFinancial, spec)) >= 0))
|
||||
{
|
||||
status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, dstRoiSize,
|
||||
ippBorderType, borderValue, spec, buffer);
|
||||
}
|
||||
|
||||
ippsFree(buffer);
|
||||
ippsFree(spec);
|
||||
}
|
||||
|
||||
ippsFree(buffer);
|
||||
ippsFree(spec);
|
||||
if (status >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -1200,6 +1200,7 @@ 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));
|
||||
@@ -1233,29 +1234,33 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels,
|
||||
ihist.flags = (ihist.flags & ~CV_MAT_TYPE_MASK)|CV_32S;
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
if (nimages == 1 && images[0].type() == CV_8UC1 && dims == 1 && channels &&
|
||||
channels[0] == 0 && mask.empty() && images[0].dims <= 2 &&
|
||||
!accumulate && uniform)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
ihist.setTo(Scalar::all(0));
|
||||
AutoBuffer<Ipp32s> levels(histSize[0] + 1);
|
||||
|
||||
bool ok = true;
|
||||
const Mat & src = images[0];
|
||||
int nstripes = std::min<int>(8, static_cast<int>(src.total() / (1 << 16)));
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
nstripes = 1;
|
||||
#endif
|
||||
IPPCalcHistInvoker invoker(src, ihist, levels, histSize[0] + 1, (Ipp32s)ranges[0][0], (Ipp32s)ranges[0][1], &ok);
|
||||
Range range(0, src.rows);
|
||||
parallel_for_(range, invoker, nstripes);
|
||||
|
||||
if (ok)
|
||||
if (nimages == 1 && images[0].type() == CV_8UC1 && dims == 1 && channels &&
|
||||
channels[0] == 0 && mask.empty() && images[0].dims <= 2 &&
|
||||
!accumulate && uniform)
|
||||
{
|
||||
ihist.convertTo(hist, CV_32F);
|
||||
return;
|
||||
ihist.setTo(Scalar::all(0));
|
||||
AutoBuffer<Ipp32s> levels(histSize[0] + 1);
|
||||
|
||||
bool ok = true;
|
||||
const Mat & src = images[0];
|
||||
int nstripes = std::min<int>(8, static_cast<int>(src.total() / (1 << 16)));
|
||||
#ifdef HAVE_CONCURRENCY
|
||||
nstripes = 1;
|
||||
#endif
|
||||
IPPCalcHistInvoker invoker(src, ihist, levels, histSize[0] + 1, (Ipp32s)ranges[0][0], (Ipp32s)ranges[0][1], &ok);
|
||||
Range range(0, src.rows);
|
||||
parallel_for_(range, invoker, nstripes);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
ihist.convertTo(hist, CV_32F);
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -100,25 +100,29 @@ HoughLinesStandard( const Mat& img, float rho, float theta,
|
||||
int numrho = cvRound(((width + height) * 2 + 1) / rho);
|
||||
|
||||
#if (0 && defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 801)
|
||||
IppiSize srcSize = { width, height };
|
||||
IppPointPolar delta = { rho, theta };
|
||||
IppPointPolar dstRoi[2] = {{(Ipp32f) -(width + height), (Ipp32f) min_theta},{(Ipp32f) (width + height), (Ipp32f) max_theta}};
|
||||
int bufferSize;
|
||||
int nz = countNonZero(img);
|
||||
int ipp_linesMax = std::min(linesMax, nz*numangle/threshold);
|
||||
int linesCount = 0;
|
||||
lines.resize(ipp_linesMax);
|
||||
IppStatus ok = ippiHoughLineGetSize_8u_C1R(srcSize, delta, ipp_linesMax, &bufferSize);
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
if (ok >= 0) ok = ippiHoughLine_Region_8u32f_C1R(image, step, srcSize, (IppPointPolar*) &lines[0], dstRoi, ipp_linesMax, &linesCount, delta, threshold, buffer);
|
||||
ippsFree(buffer);
|
||||
if (ok >= 0)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
lines.resize(linesCount);
|
||||
return;
|
||||
IppiSize srcSize = { width, height };
|
||||
IppPointPolar delta = { rho, theta };
|
||||
IppPointPolar dstRoi[2] = {{(Ipp32f) -(width + height), (Ipp32f) min_theta},{(Ipp32f) (width + height), (Ipp32f) max_theta}};
|
||||
int bufferSize;
|
||||
int nz = countNonZero(img);
|
||||
int ipp_linesMax = std::min(linesMax, nz*numangle/threshold);
|
||||
int linesCount = 0;
|
||||
lines.resize(ipp_linesMax);
|
||||
IppStatus ok = ippiHoughLineGetSize_8u_C1R(srcSize, delta, ipp_linesMax, &bufferSize);
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
if (ok >= 0) ok = ippiHoughLine_Region_8u32f_C1R(image, step, srcSize, (IppPointPolar*) &lines[0], dstRoi, ipp_linesMax, &linesCount, delta, threshold, buffer);
|
||||
ippsFree(buffer);
|
||||
if (ok >= 0)
|
||||
{
|
||||
lines.resize(linesCount);
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
lines.clear();
|
||||
setIppErrorStatus();
|
||||
}
|
||||
lines.clear();
|
||||
setIppErrorStatus();
|
||||
#endif
|
||||
|
||||
AutoBuffer<int> _accum((numangle+2) * (numrho+2));
|
||||
@@ -429,28 +433,32 @@ HoughLinesProbabilistic( Mat& image,
|
||||
int numrho = cvRound(((width + height) * 2 + 1) / rho);
|
||||
|
||||
#if (0 && defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 801)
|
||||
IppiSize srcSize = { width, height };
|
||||
IppPointPolar delta = { rho, theta };
|
||||
IppiHoughProbSpec* pSpec;
|
||||
int bufferSize, specSize;
|
||||
int ipp_linesMax = std::min(linesMax, numangle*numrho);
|
||||
int linesCount = 0;
|
||||
lines.resize(ipp_linesMax);
|
||||
IppStatus ok = ippiHoughProbLineGetSize_8u_C1R(srcSize, delta, &specSize, &bufferSize);
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
pSpec = (IppiHoughProbSpec*) malloc(specSize);
|
||||
if (ok >= 0) ok = ippiHoughProbLineInit_8u32f_C1R(srcSize, delta, ippAlgHintNone, pSpec);
|
||||
if (ok >= 0) ok = ippiHoughProbLine_8u32f_C1R(image.data, image.step, srcSize, threshold, lineLength, lineGap, (IppiPoint*) &lines[0], ipp_linesMax, &linesCount, buffer, pSpec);
|
||||
|
||||
free(pSpec);
|
||||
ippsFree(buffer);
|
||||
if (ok >= 0)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
lines.resize(linesCount);
|
||||
return;
|
||||
IppiSize srcSize = { width, height };
|
||||
IppPointPolar delta = { rho, theta };
|
||||
IppiHoughProbSpec* pSpec;
|
||||
int bufferSize, specSize;
|
||||
int ipp_linesMax = std::min(linesMax, numangle*numrho);
|
||||
int linesCount = 0;
|
||||
lines.resize(ipp_linesMax);
|
||||
IppStatus ok = ippiHoughProbLineGetSize_8u_C1R(srcSize, delta, &specSize, &bufferSize);
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
pSpec = (IppiHoughProbSpec*) malloc(specSize);
|
||||
if (ok >= 0) ok = ippiHoughProbLineInit_8u32f_C1R(srcSize, delta, ippAlgHintNone, pSpec);
|
||||
if (ok >= 0) ok = ippiHoughProbLine_8u32f_C1R(image.data, image.step, srcSize, threshold, lineLength, lineGap, (IppiPoint*) &lines[0], ipp_linesMax, &linesCount, buffer, pSpec);
|
||||
|
||||
free(pSpec);
|
||||
ippsFree(buffer);
|
||||
if (ok >= 0)
|
||||
{
|
||||
lines.resize(linesCount);
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
lines.clear();
|
||||
setIppErrorStatus();
|
||||
}
|
||||
lines.clear();
|
||||
setIppErrorStatus();
|
||||
#endif
|
||||
|
||||
Mat accum = Mat::zeros( numangle, numrho, CV_32SC1 );
|
||||
|
@@ -2271,6 +2271,10 @@ public:
|
||||
|
||||
if( func( pSrc, (int)src.step[0], pDst, (int)dst.step[0], dstOffset, dstSize, ippBorderRepl, 0, pSpec, bufptr ) < 0 )
|
||||
*ok = false;
|
||||
else
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
}
|
||||
}
|
||||
private:
|
||||
const Mat & src;
|
||||
@@ -2694,35 +2698,41 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
std::abs(scale_y - iscale_y) < DBL_EPSILON;
|
||||
|
||||
#if IPP_VERSION_X100 >= 701
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
#define IPP_RESIZE_EPS 1e-10
|
||||
|
||||
double ex = fabs((double)dsize.width / src.cols - inv_scale_x) / inv_scale_x;
|
||||
double ey = fabs((double)dsize.height / src.rows - inv_scale_y) / inv_scale_y;
|
||||
double ex = fabs((double)dsize.width / src.cols - inv_scale_x) / inv_scale_x;
|
||||
double ey = fabs((double)dsize.height / src.rows - inv_scale_y) / inv_scale_y;
|
||||
|
||||
if ( ((ex < IPP_RESIZE_EPS && ey < IPP_RESIZE_EPS && depth != CV_64F) || (ex == 0 && ey == 0 && depth == CV_64F)) &&
|
||||
(interpolation == INTER_LINEAR || interpolation == INTER_CUBIC) &&
|
||||
!(interpolation == INTER_LINEAR && is_area_fast && iscale_x == 2 && iscale_y == 2 && depth == CV_8U))
|
||||
{
|
||||
int mode = -1;
|
||||
if (interpolation == INTER_LINEAR && src.rows >= 2 && src.cols >= 2)
|
||||
mode = ippLinear;
|
||||
else if (interpolation == INTER_CUBIC && src.rows >= 4 && src.cols >= 4)
|
||||
mode = ippCubic;
|
||||
|
||||
if( mode >= 0 && (cn == 1 || cn == 3 || cn == 4) &&
|
||||
(depth == CV_16U || depth == CV_16S || depth == CV_32F ||
|
||||
(depth == CV_64F && mode == ippLinear)))
|
||||
if ( ((ex < IPP_RESIZE_EPS && ey < IPP_RESIZE_EPS && depth != CV_64F) || (ex == 0 && ey == 0 && depth == CV_64F)) &&
|
||||
(interpolation == INTER_LINEAR || interpolation == INTER_CUBIC) &&
|
||||
!(interpolation == INTER_LINEAR && is_area_fast && iscale_x == 2 && iscale_y == 2 && depth == CV_8U))
|
||||
{
|
||||
bool ok = true;
|
||||
Range range(0, src.rows);
|
||||
IPPresizeInvoker invoker(src, dst, inv_scale_x, inv_scale_y, mode, &ok);
|
||||
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
|
||||
if( ok )
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
int mode = -1;
|
||||
if (interpolation == INTER_LINEAR && src.rows >= 2 && src.cols >= 2)
|
||||
mode = ippLinear;
|
||||
else if (interpolation == INTER_CUBIC && src.rows >= 4 && src.cols >= 4)
|
||||
mode = ippCubic;
|
||||
|
||||
if( mode >= 0 && (cn == 1 || cn == 3 || cn == 4) &&
|
||||
(depth == CV_16U || depth == CV_16S || depth == CV_32F ||
|
||||
(depth == CV_64F && mode == ippLinear)))
|
||||
{
|
||||
bool ok = true;
|
||||
Range range(0, src.rows);
|
||||
IPPresizeInvoker invoker(src, dst, inv_scale_x, inv_scale_y, mode, &ok);
|
||||
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
|
||||
if( ok )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef IPP_RESIZE_EPS
|
||||
}
|
||||
#endif
|
||||
|
||||
if( interpolation == INTER_NEAREST )
|
||||
@@ -4033,6 +4043,10 @@ public:
|
||||
map1.ptr<Ipp32f>(), (int)map1.step, map2.ptr<Ipp32f>(), (int)map2.step,
|
||||
dstRoi.ptr(), (int)dstRoi.step, dstRoiSize, ippInterpolation) < 0)
|
||||
*ok = false;
|
||||
else
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -4102,36 +4116,42 @@ void cv::remap( InputArray _src, OutputArray _dst,
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type);
|
||||
|
||||
#if IPP_VERSION_X100 >= 0 && !defined HAVE_IPP_ICV_ONLY && 0
|
||||
if ((interpolation == INTER_LINEAR || interpolation == INTER_CUBIC || interpolation == INTER_NEAREST) &&
|
||||
map1.type() == CV_32FC1 && map2.type() == CV_32FC1 &&
|
||||
(borderType == BORDER_CONSTANT || borderType == BORDER_TRANSPARENT))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
int ippInterpolation =
|
||||
interpolation == INTER_NEAREST ? IPPI_INTER_NN :
|
||||
interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR : IPPI_INTER_CUBIC;
|
||||
|
||||
ippiRemap ippFunc =
|
||||
type == CV_8UC1 ? (ippiRemap)ippiRemap_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiRemap)ippiRemap_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiRemap)ippiRemap_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiRemap)ippiRemap_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiRemap)ippiRemap_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiRemap)ippiRemap_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiRemap)ippiRemap_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiRemap)ippiRemap_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiRemap)ippiRemap_32f_C4R : 0;
|
||||
|
||||
if (ippFunc)
|
||||
if ((interpolation == INTER_LINEAR || interpolation == INTER_CUBIC || interpolation == INTER_NEAREST) &&
|
||||
map1.type() == CV_32FC1 && map2.type() == CV_32FC1 &&
|
||||
(borderType == BORDER_CONSTANT || borderType == BORDER_TRANSPARENT))
|
||||
{
|
||||
bool ok;
|
||||
IPPRemapInvoker invoker(src, dst, map1, map2, ippFunc, ippInterpolation,
|
||||
borderType, borderValue, &ok);
|
||||
Range range(0, dst.rows);
|
||||
parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
|
||||
int ippInterpolation =
|
||||
interpolation == INTER_NEAREST ? IPPI_INTER_NN :
|
||||
interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR : IPPI_INTER_CUBIC;
|
||||
|
||||
if (ok)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
ippiRemap ippFunc =
|
||||
type == CV_8UC1 ? (ippiRemap)ippiRemap_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiRemap)ippiRemap_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiRemap)ippiRemap_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiRemap)ippiRemap_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiRemap)ippiRemap_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiRemap)ippiRemap_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiRemap)ippiRemap_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiRemap)ippiRemap_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiRemap)ippiRemap_32f_C4R : 0;
|
||||
|
||||
if (ippFunc)
|
||||
{
|
||||
bool ok;
|
||||
IPPRemapInvoker invoker(src, dst, map1, map2, ippFunc, ippInterpolation,
|
||||
borderType, borderValue, &ok);
|
||||
Range range(0, dst.rows);
|
||||
parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
|
||||
|
||||
if (ok)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -4482,6 +4502,10 @@ public:
|
||||
(int)dst.step[0], dstroi, coeffs, mode );
|
||||
if( status < 0)
|
||||
*ok = false;
|
||||
else
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
}
|
||||
}
|
||||
private:
|
||||
Mat &src;
|
||||
@@ -4649,60 +4673,66 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
|
||||
const int AB_SCALE = 1 << AB_BITS;
|
||||
|
||||
#if defined (HAVE_IPP) && IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR >= 801 && 0
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
if( ( depth == CV_8U || depth == CV_16U || depth == CV_32F ) &&
|
||||
( cn == 1 || cn == 3 || cn == 4 ) &&
|
||||
( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC) &&
|
||||
( borderType == cv::BORDER_TRANSPARENT || borderType == cv::BORDER_CONSTANT) )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
ippiWarpAffineBackFunc ippFunc = 0;
|
||||
if ((flags & WARP_INVERSE_MAP) != 0)
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
if( ( depth == CV_8U || depth == CV_16U || depth == CV_32F ) &&
|
||||
( cn == 1 || cn == 3 || cn == 4 ) &&
|
||||
( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC) &&
|
||||
( borderType == cv::BORDER_TRANSPARENT || borderType == cv::BORDER_CONSTANT) )
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_8UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C4R :
|
||||
ippiWarpAffineBackFunc ippFunc = 0;
|
||||
if ((flags & WARP_INVERSE_MAP) != 0)
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_8UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiWarpAffineBackFunc)ippiWarpAffineBack_32f_C4R :
|
||||
0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_8UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffine_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffine_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffine_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffine_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffine_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffine_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiWarpAffineBackFunc)ippiWarpAffine_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiWarpAffineBackFunc)ippiWarpAffine_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiWarpAffineBackFunc)ippiWarpAffine_32f_C4R :
|
||||
0;
|
||||
}
|
||||
int mode =
|
||||
interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR :
|
||||
interpolation == INTER_NEAREST ? IPPI_INTER_NN :
|
||||
interpolation == INTER_CUBIC ? IPPI_INTER_CUBIC :
|
||||
0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_8UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffine_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffine_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffine_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiWarpAffineBackFunc)ippiWarpAffine_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiWarpAffineBackFunc)ippiWarpAffine_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiWarpAffineBackFunc)ippiWarpAffine_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiWarpAffineBackFunc)ippiWarpAffine_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiWarpAffineBackFunc)ippiWarpAffine_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiWarpAffineBackFunc)ippiWarpAffine_32f_C4R :
|
||||
0;
|
||||
}
|
||||
int mode =
|
||||
interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR :
|
||||
interpolation == INTER_NEAREST ? IPPI_INTER_NN :
|
||||
interpolation == INTER_CUBIC ? IPPI_INTER_CUBIC :
|
||||
0;
|
||||
CV_Assert(mode && ippFunc);
|
||||
CV_Assert(mode && ippFunc);
|
||||
|
||||
double coeffs[2][3];
|
||||
for( int i = 0; i < 2; i++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
coeffs[i][j] = matM.at<double>(i, j);
|
||||
double coeffs[2][3];
|
||||
for( int i = 0; i < 2; i++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
coeffs[i][j] = matM.at<double>(i, j);
|
||||
|
||||
bool ok;
|
||||
Range range(0, dst.rows);
|
||||
IPPWarpAffineInvoker invoker(src, dst, coeffs, mode, borderType, borderValue, ippFunc, &ok);
|
||||
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
|
||||
if( ok )
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
bool ok;
|
||||
Range range(0, dst.rows);
|
||||
IPPWarpAffineInvoker invoker(src, dst, coeffs, mode, borderType, borderValue, ippFunc, &ok);
|
||||
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
|
||||
if( ok )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4847,6 +4877,10 @@ public:
|
||||
IppStatus status = func(src.ptr(), srcsize, (int)src.step[0], srcroi, dst.ptr(), (int)dst.step[0], dstroi, coeffs, mode);
|
||||
if (status != ippStsNoErr)
|
||||
*ok = false;
|
||||
else
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
}
|
||||
}
|
||||
private:
|
||||
Mat &src;
|
||||
@@ -4895,55 +4929,61 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,
|
||||
|
||||
|
||||
#if defined (HAVE_IPP) && IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR >= 801 && 0
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
if( (depth == CV_8U || depth == CV_16U || depth == CV_32F) &&
|
||||
(cn == 1 || cn == 3 || cn == 4) &&
|
||||
( borderType == cv::BORDER_TRANSPARENT || borderType == cv::BORDER_CONSTANT ) &&
|
||||
(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
ippiWarpPerspectiveFunc ippFunc = 0;
|
||||
if ((flags & WARP_INVERSE_MAP) != 0)
|
||||
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
if( (depth == CV_8U || depth == CV_16U || depth == CV_32F) &&
|
||||
(cn == 1 || cn == 3 || cn == 4) &&
|
||||
( borderType == cv::BORDER_TRANSPARENT || borderType == cv::BORDER_CONSTANT ) &&
|
||||
(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC))
|
||||
{
|
||||
ippFunc = type == CV_8UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_32f_C4R : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ippFunc = type == CV_8UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_32f_C4R : 0;
|
||||
}
|
||||
int mode =
|
||||
interpolation == INTER_NEAREST ? IPPI_INTER_NN :
|
||||
interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR :
|
||||
interpolation == INTER_CUBIC ? IPPI_INTER_CUBIC : 0;
|
||||
CV_Assert(mode && ippFunc);
|
||||
ippiWarpPerspectiveFunc ippFunc = 0;
|
||||
if ((flags & WARP_INVERSE_MAP) != 0)
|
||||
{
|
||||
ippFunc = type == CV_8UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspectiveBack_32f_C4R : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ippFunc = type == CV_8UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_8u_C3R :
|
||||
type == CV_8UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_8u_C4R :
|
||||
type == CV_16UC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_16u_C1R :
|
||||
type == CV_16UC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_16u_C3R :
|
||||
type == CV_16UC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_16u_C4R :
|
||||
type == CV_32FC1 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_32f_C3R :
|
||||
type == CV_32FC4 ? (ippiWarpPerspectiveFunc)ippiWarpPerspective_32f_C4R : 0;
|
||||
}
|
||||
int mode =
|
||||
interpolation == INTER_NEAREST ? IPPI_INTER_NN :
|
||||
interpolation == INTER_LINEAR ? IPPI_INTER_LINEAR :
|
||||
interpolation == INTER_CUBIC ? IPPI_INTER_CUBIC : 0;
|
||||
CV_Assert(mode && ippFunc);
|
||||
|
||||
double coeffs[3][3];
|
||||
for( int i = 0; i < 3; i++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
coeffs[i][j] = matM.at<double>(i, j);
|
||||
double coeffs[3][3];
|
||||
for( int i = 0; i < 3; i++ )
|
||||
for( int j = 0; j < 3; j++ )
|
||||
coeffs[i][j] = matM.at<double>(i, j);
|
||||
|
||||
bool ok;
|
||||
Range range(0, dst.rows);
|
||||
IPPWarpPerspectiveInvoker invoker(src, dst, coeffs, mode, borderType, borderValue, ippFunc, &ok);
|
||||
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
|
||||
if( ok )
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
bool ok;
|
||||
Range range(0, dst.rows);
|
||||
IPPWarpPerspectiveInvoker invoker(src, dst, coeffs, mode, borderType, borderValue, ippFunc, &ok);
|
||||
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
|
||||
if( ok )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -578,64 +578,68 @@ cv::Moments cv::moments( InputArray _src, bool binary )
|
||||
CV_Error( CV_StsBadArg, "Invalid image type (must be single-channel)" );
|
||||
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
if (!binary)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize roi = { mat.cols, mat.rows };
|
||||
IppiMomentState_64f * moment = NULL;
|
||||
// ippiMomentInitAlloc_64f, ippiMomentFree_64f are deprecated in 8.1, but there are not another way
|
||||
// to initialize IppiMomentState_64f. When GetStateSize and Init functions will appear we have to
|
||||
// change our code.
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
if (ippiMomentInitAlloc_64f(&moment, ippAlgHintAccurate) >= 0)
|
||||
if (!binary)
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiMoments)(const void * pSrc, int srcStep, IppiSize roiSize, IppiMomentState_64f* pCtx);
|
||||
ippiMoments ippFunc =
|
||||
type == CV_8UC1 ? (ippiMoments)ippiMoments64f_8u_C1R :
|
||||
type == CV_16UC1 ? (ippiMoments)ippiMoments64f_16u_C1R :
|
||||
type == CV_32FC1? (ippiMoments)ippiMoments64f_32f_C1R : 0;
|
||||
|
||||
if (ippFunc)
|
||||
IppiSize roi = { mat.cols, mat.rows };
|
||||
IppiMomentState_64f * moment = NULL;
|
||||
// ippiMomentInitAlloc_64f, ippiMomentFree_64f are deprecated in 8.1, but there are not another way
|
||||
// to initialize IppiMomentState_64f. When GetStateSize and Init functions will appear we have to
|
||||
// change our code.
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
if (ippiMomentInitAlloc_64f(&moment, ippAlgHintAccurate) >= 0)
|
||||
{
|
||||
if (ippFunc(mat.data, (int)mat.step, roi, moment) >= 0)
|
||||
typedef IppStatus (CV_STDCALL * ippiMoments)(const void * pSrc, int srcStep, IppiSize roiSize, IppiMomentState_64f* pCtx);
|
||||
ippiMoments ippFunc =
|
||||
type == CV_8UC1 ? (ippiMoments)ippiMoments64f_8u_C1R :
|
||||
type == CV_16UC1 ? (ippiMoments)ippiMoments64f_16u_C1R :
|
||||
type == CV_32FC1? (ippiMoments)ippiMoments64f_32f_C1R : 0;
|
||||
|
||||
if (ippFunc)
|
||||
{
|
||||
IppiPoint point = { 0, 0 };
|
||||
ippiGetSpatialMoment_64f(moment, 0, 0, 0, point, &m.m00);
|
||||
ippiGetSpatialMoment_64f(moment, 1, 0, 0, point, &m.m10);
|
||||
ippiGetSpatialMoment_64f(moment, 0, 1, 0, point, &m.m01);
|
||||
if (ippFunc(mat.data, (int)mat.step, roi, moment) >= 0)
|
||||
{
|
||||
IppiPoint point = { 0, 0 };
|
||||
ippiGetSpatialMoment_64f(moment, 0, 0, 0, point, &m.m00);
|
||||
ippiGetSpatialMoment_64f(moment, 1, 0, 0, point, &m.m10);
|
||||
ippiGetSpatialMoment_64f(moment, 0, 1, 0, point, &m.m01);
|
||||
|
||||
ippiGetSpatialMoment_64f(moment, 2, 0, 0, point, &m.m20);
|
||||
ippiGetSpatialMoment_64f(moment, 1, 1, 0, point, &m.m11);
|
||||
ippiGetSpatialMoment_64f(moment, 0, 2, 0, point, &m.m02);
|
||||
ippiGetSpatialMoment_64f(moment, 2, 0, 0, point, &m.m20);
|
||||
ippiGetSpatialMoment_64f(moment, 1, 1, 0, point, &m.m11);
|
||||
ippiGetSpatialMoment_64f(moment, 0, 2, 0, point, &m.m02);
|
||||
|
||||
ippiGetSpatialMoment_64f(moment, 3, 0, 0, point, &m.m30);
|
||||
ippiGetSpatialMoment_64f(moment, 2, 1, 0, point, &m.m21);
|
||||
ippiGetSpatialMoment_64f(moment, 1, 2, 0, point, &m.m12);
|
||||
ippiGetSpatialMoment_64f(moment, 0, 3, 0, point, &m.m03);
|
||||
ippiGetCentralMoment_64f(moment, 2, 0, 0, &m.mu20);
|
||||
ippiGetCentralMoment_64f(moment, 1, 1, 0, &m.mu11);
|
||||
ippiGetCentralMoment_64f(moment, 0, 2, 0, &m.mu02);
|
||||
ippiGetCentralMoment_64f(moment, 3, 0, 0, &m.mu30);
|
||||
ippiGetCentralMoment_64f(moment, 2, 1, 0, &m.mu21);
|
||||
ippiGetCentralMoment_64f(moment, 1, 2, 0, &m.mu12);
|
||||
ippiGetCentralMoment_64f(moment, 0, 3, 0, &m.mu03);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 2, 0, 0, &m.nu20);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 1, 1, 0, &m.nu11);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 0, 2, 0, &m.nu02);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 3, 0, 0, &m.nu30);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 2, 1, 0, &m.nu21);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 1, 2, 0, &m.nu12);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 0, 3, 0, &m.nu03);
|
||||
ippiGetSpatialMoment_64f(moment, 3, 0, 0, point, &m.m30);
|
||||
ippiGetSpatialMoment_64f(moment, 2, 1, 0, point, &m.m21);
|
||||
ippiGetSpatialMoment_64f(moment, 1, 2, 0, point, &m.m12);
|
||||
ippiGetSpatialMoment_64f(moment, 0, 3, 0, point, &m.m03);
|
||||
ippiGetCentralMoment_64f(moment, 2, 0, 0, &m.mu20);
|
||||
ippiGetCentralMoment_64f(moment, 1, 1, 0, &m.mu11);
|
||||
ippiGetCentralMoment_64f(moment, 0, 2, 0, &m.mu02);
|
||||
ippiGetCentralMoment_64f(moment, 3, 0, 0, &m.mu30);
|
||||
ippiGetCentralMoment_64f(moment, 2, 1, 0, &m.mu21);
|
||||
ippiGetCentralMoment_64f(moment, 1, 2, 0, &m.mu12);
|
||||
ippiGetCentralMoment_64f(moment, 0, 3, 0, &m.mu03);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 2, 0, 0, &m.nu20);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 1, 1, 0, &m.nu11);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 0, 2, 0, &m.nu02);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 3, 0, 0, &m.nu30);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 2, 1, 0, &m.nu21);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 1, 2, 0, &m.nu12);
|
||||
ippiGetNormalizedCentralMoment_64f(moment, 0, 3, 0, &m.nu03);
|
||||
|
||||
ippiMomentFree_64f(moment);
|
||||
return m;
|
||||
ippiMomentFree_64f(moment);
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return m;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
setIppErrorStatus();
|
||||
ippiMomentFree_64f(moment);
|
||||
}
|
||||
ippiMomentFree_64f(moment);
|
||||
else
|
||||
setIppErrorStatus();
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
else
|
||||
setIppErrorStatus();
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -1707,8 +1707,14 @@ static void morphOp( int op, InputArray _src, OutputArray _dst,
|
||||
}
|
||||
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
if( IPPMorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue) )
|
||||
return;
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if( IPPMorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue) )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Mat src = _src.getMat();
|
||||
|
@@ -703,36 +703,42 @@ void cv::pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borde
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size((src.cols + 1)/2, (src.rows + 1)/2))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiPyrDown)(const void* pSrc, int srcStep, void* pDst, int dstStep, IppiSize srcRoi, Ipp8u* buffer);
|
||||
int type = src.type();
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippiPyrDown pyrDownFunc = type == CV_8UC1 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_8u_C3R :
|
||||
type == CV_32FC1 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_32f_C3R : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if (pyrDownFunc)
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size((src.cols + 1)/2, (src.rows + 1)/2))
|
||||
{
|
||||
int bufferSize;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppDataType dataType = depth == CV_8U ? ipp8u : ipp32f;
|
||||
typedef IppStatus (CV_STDCALL * ippiPyrDown)(const void* pSrc, int srcStep, void* pDst, int dstStep, IppiSize srcRoi, Ipp8u* buffer);
|
||||
int type = src.type();
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
IppStatus ok = ippiPyrDownGetBufSize_Gauss5x5(srcRoi.width, dataType, src.channels(), &bufferSize);
|
||||
ippiPyrDown pyrDownFunc = type == CV_8UC1 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_8u_C3R :
|
||||
type == CV_32FC1 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiPyrDown) ippiPyrDown_Gauss5x5_32f_C3R : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
{
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
ok = pyrDownFunc(src.data, (int) src.step, dst.data, (int) dst.step, srcRoi, buffer);
|
||||
ippsFree(buffer);
|
||||
|
||||
if (pyrDownFunc)
|
||||
{
|
||||
int bufferSize;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppDataType dataType = depth == CV_8U ? ipp8u : ipp32f;
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
IppStatus ok = ippiPyrDownGetBufSize_Gauss5x5(srcRoi.width, dataType, src.channels(), &bufferSize);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
{
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
ok = pyrDownFunc(src.data, (int) src.step, dst.data, (int) dst.step, srcRoi, buffer);
|
||||
ippsFree(buffer);
|
||||
|
||||
if (ok >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -774,36 +780,42 @@ void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderT
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 >= 801 && 0
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size(src.cols*2, src.rows*2))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiPyrUp)(const void* pSrc, int srcStep, void* pDst, int dstStep, IppiSize srcRoi, Ipp8u* buffer);
|
||||
int type = src.type();
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippiPyrUp pyrUpFunc = type == CV_8UC1 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_8u_C3R :
|
||||
type == CV_32FC1 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_32f_C3R : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if (pyrUpFunc)
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated) && dsz == Size(src.cols*2, src.rows*2))
|
||||
{
|
||||
int bufferSize;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppDataType dataType = depth == CV_8U ? ipp8u : ipp32f;
|
||||
typedef IppStatus (CV_STDCALL * ippiPyrUp)(const void* pSrc, int srcStep, void* pDst, int dstStep, IppiSize srcRoi, Ipp8u* buffer);
|
||||
int type = src.type();
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
IppStatus ok = ippiPyrUpGetBufSize_Gauss5x5(srcRoi.width, dataType, src.channels(), &bufferSize);
|
||||
ippiPyrUp pyrUpFunc = type == CV_8UC1 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_8u_C1R :
|
||||
type == CV_8UC3 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_8u_C3R :
|
||||
type == CV_32FC1 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_32f_C1R :
|
||||
type == CV_32FC3 ? (ippiPyrUp) ippiPyrUp_Gauss5x5_32f_C3R : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
{
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
ok = pyrUpFunc(src.data, (int) src.step, dst.data, (int) dst.step, srcRoi, buffer);
|
||||
ippsFree(buffer);
|
||||
|
||||
if (pyrUpFunc)
|
||||
{
|
||||
int bufferSize;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppDataType dataType = depth == CV_8U ? ipp8u : ipp32f;
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
IppStatus ok = ippiPyrUpGetBufSize_Gauss5x5(srcRoi.width, dataType, src.channels(), &bufferSize);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
{
|
||||
Ipp8u* buffer = ippsMalloc_8u(bufferSize);
|
||||
ok = pyrUpFunc(src.data, (int) src.step, dst.data, (int) dst.step, srcRoi, buffer);
|
||||
ippsFree(buffer);
|
||||
|
||||
if (ok >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -847,87 +859,94 @@ 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;
|
||||
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated))
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiPyramidLayerDownInitAlloc)(void** ppState, IppiSize srcRoi, Ipp32f rate, void* pKernel, int kerSize, int mode);
|
||||
typedef IppStatus (CV_STDCALL * ippiPyramidLayerDown)(void* pSrc, int srcStep, IppiSize srcRoiSize, void* pDst, int dstStep, IppiSize dstRoiSize, void* pState);
|
||||
typedef IppStatus (CV_STDCALL * ippiPyramidLayerDownFree)(void* pState);
|
||||
|
||||
int type = src.type();
|
||||
int depth = src.depth();
|
||||
ippiPyramidLayerDownInitAlloc pyrInitAllocFunc = 0;
|
||||
ippiPyramidLayerDown pyrDownFunc = 0;
|
||||
ippiPyramidLayerDownFree pyrFreeFunc = 0;
|
||||
|
||||
if (type == CV_8UC1)
|
||||
bool isolated = (borderType & BORDER_ISOLATED) != 0;
|
||||
int borderTypeNI = borderType & ~BORDER_ISOLATED;
|
||||
if (borderTypeNI == BORDER_DEFAULT && (!src.isSubmatrix() || isolated))
|
||||
{
|
||||
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_8u_C1R;
|
||||
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_8u_C1R;
|
||||
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_8u_C1R;
|
||||
}
|
||||
else if (type == CV_8UC3)
|
||||
{
|
||||
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_8u_C3R;
|
||||
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_8u_C3R;
|
||||
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_8u_C3R;
|
||||
}
|
||||
else if (type == CV_32FC1)
|
||||
{
|
||||
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_32f_C1R;
|
||||
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_32f_C1R;
|
||||
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_32f_C1R;
|
||||
}
|
||||
else if (type == CV_32FC3)
|
||||
{
|
||||
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_32f_C3R;
|
||||
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_32f_C3R;
|
||||
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_32f_C3R;
|
||||
}
|
||||
typedef IppStatus (CV_STDCALL * ippiPyramidLayerDownInitAlloc)(void** ppState, IppiSize srcRoi, Ipp32f rate, void* pKernel, int kerSize, int mode);
|
||||
typedef IppStatus (CV_STDCALL * ippiPyramidLayerDown)(void* pSrc, int srcStep, IppiSize srcRoiSize, void* pDst, int dstStep, IppiSize dstRoiSize, void* pState);
|
||||
typedef IppStatus (CV_STDCALL * ippiPyramidLayerDownFree)(void* pState);
|
||||
|
||||
if (pyrInitAllocFunc && pyrDownFunc && pyrFreeFunc)
|
||||
{
|
||||
float rate = 2.f;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppiPyramid *gPyr;
|
||||
IppStatus ok = ippiPyramidInitAlloc(&gPyr, maxlevel + 1, srcRoi, rate);
|
||||
int type = src.type();
|
||||
int depth = src.depth();
|
||||
ippiPyramidLayerDownInitAlloc pyrInitAllocFunc = 0;
|
||||
ippiPyramidLayerDown pyrDownFunc = 0;
|
||||
ippiPyramidLayerDownFree pyrFreeFunc = 0;
|
||||
|
||||
Ipp16s iKernel[5] = { 1, 4, 6, 4, 1 };
|
||||
Ipp32f fKernel[5] = { 1.f, 4.f, 6.f, 4.f, 1.f };
|
||||
void* kernel = depth >= CV_32F ? (void*) fKernel : (void*) iKernel;
|
||||
|
||||
if (ok >= 0) ok = pyrInitAllocFunc((void**) &(gPyr->pState), srcRoi, rate, kernel, 5, IPPI_INTER_LINEAR);
|
||||
if (ok >= 0)
|
||||
if (type == CV_8UC1)
|
||||
{
|
||||
gPyr->pImage[0] = src.data;
|
||||
gPyr->pStep[0] = (int) src.step;
|
||||
gPyr->pRoi[0] = srcRoi;
|
||||
for( ; i <= maxlevel; i++ )
|
||||
{
|
||||
IppiSize dstRoi;
|
||||
ok = ippiGetPyramidDownROI(gPyr->pRoi[i-1], &dstRoi, rate);
|
||||
Mat& dst = _dst.getMatRef(i);
|
||||
dst.create(Size(dstRoi.width, dstRoi.height), type);
|
||||
gPyr->pImage[i] = dst.data;
|
||||
gPyr->pStep[i] = (int) dst.step;
|
||||
gPyr->pRoi[i] = dstRoi;
|
||||
|
||||
if (ok >= 0) ok = pyrDownFunc(gPyr->pImage[i-1], gPyr->pStep[i-1], gPyr->pRoi[i-1],
|
||||
gPyr->pImage[i], gPyr->pStep[i], gPyr->pRoi[i], gPyr->pState);
|
||||
|
||||
if (ok < 0)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
pyrFreeFunc(gPyr->pState);
|
||||
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_8u_C1R;
|
||||
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_8u_C1R;
|
||||
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_8u_C1R;
|
||||
}
|
||||
else if (type == CV_8UC3)
|
||||
{
|
||||
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_8u_C3R;
|
||||
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_8u_C3R;
|
||||
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_8u_C3R;
|
||||
}
|
||||
else if (type == CV_32FC1)
|
||||
{
|
||||
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_32f_C1R;
|
||||
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_32f_C1R;
|
||||
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_32f_C1R;
|
||||
}
|
||||
else if (type == CV_32FC3)
|
||||
{
|
||||
pyrInitAllocFunc = (ippiPyramidLayerDownInitAlloc) ippiPyramidLayerDownInitAlloc_32f_C3R;
|
||||
pyrDownFunc = (ippiPyramidLayerDown) ippiPyramidLayerDown_32f_C3R;
|
||||
pyrFreeFunc = (ippiPyramidLayerDownFree) ippiPyramidLayerDownFree_32f_C3R;
|
||||
}
|
||||
else
|
||||
setIppErrorStatus();
|
||||
|
||||
ippiPyramidFree(gPyr);
|
||||
if (pyrInitAllocFunc && pyrDownFunc && pyrFreeFunc)
|
||||
{
|
||||
float rate = 2.f;
|
||||
IppiSize srcRoi = { src.cols, src.rows };
|
||||
IppiPyramid *gPyr;
|
||||
IppStatus ok = ippiPyramidInitAlloc(&gPyr, maxlevel + 1, srcRoi, rate);
|
||||
|
||||
Ipp16s iKernel[5] = { 1, 4, 6, 4, 1 };
|
||||
Ipp32f fKernel[5] = { 1.f, 4.f, 6.f, 4.f, 1.f };
|
||||
void* kernel = depth >= CV_32F ? (void*) fKernel : (void*) iKernel;
|
||||
|
||||
if (ok >= 0) ok = pyrInitAllocFunc((void**) &(gPyr->pState), srcRoi, rate, kernel, 5, IPPI_INTER_LINEAR);
|
||||
if (ok >= 0)
|
||||
{
|
||||
gPyr->pImage[0] = src.data;
|
||||
gPyr->pStep[0] = (int) src.step;
|
||||
gPyr->pRoi[0] = srcRoi;
|
||||
for( ; i <= maxlevel; i++ )
|
||||
{
|
||||
IppiSize dstRoi;
|
||||
ok = ippiGetPyramidDownROI(gPyr->pRoi[i-1], &dstRoi, rate);
|
||||
Mat& dst = _dst.getMatRef(i);
|
||||
dst.create(Size(dstRoi.width, dstRoi.height), type);
|
||||
gPyr->pImage[i] = dst.data;
|
||||
gPyr->pStep[i] = (int) dst.step;
|
||||
gPyr->pRoi[i] = dstRoi;
|
||||
|
||||
if (ok >= 0) ok = pyrDownFunc(gPyr->pImage[i-1], gPyr->pStep[i-1], gPyr->pRoi[i-1],
|
||||
gPyr->pImage[i], gPyr->pStep[i], gPyr->pRoi[i], gPyr->pState);
|
||||
|
||||
if (ok < 0)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
}
|
||||
}
|
||||
pyrFreeFunc(gPyr->pState);
|
||||
}
|
||||
else
|
||||
setIppErrorStatus();
|
||||
|
||||
ippiPyramidFree(gPyr);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -375,27 +375,33 @@ void cv::getRectSubPix( InputArray _image, Size patchSize, Point2f center,
|
||||
Mat patch = _patch.getMat();
|
||||
|
||||
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
|
||||
typedef IppStatus (CV_STDCALL *ippiGetRectSubPixFunc)( const void* src, int src_step,
|
||||
IppiSize src_size, void* dst,
|
||||
int dst_step, IppiSize win_size,
|
||||
IppiPoint_32f center,
|
||||
IppiPoint* minpt, IppiPoint* maxpt );
|
||||
|
||||
IppiPoint minpt={0,0}, maxpt={0,0};
|
||||
IppiPoint_32f icenter = {center.x, center.y};
|
||||
IppiSize src_size={image.cols, image.rows}, win_size={patch.cols, patch.rows};
|
||||
int srctype = image.type();
|
||||
ippiGetRectSubPixFunc ippfunc =
|
||||
srctype == CV_8UC1 && ddepth == CV_8U ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_8u_C1R :
|
||||
srctype == CV_8UC1 && ddepth == CV_32F ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_8u32f_C1R :
|
||||
srctype == CV_32FC1 && ddepth == CV_32F ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_32f_C1R : 0;
|
||||
|
||||
if( ippfunc)
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (ippfunc(image.ptr(), (int)image.step, src_size, patch.ptr(),
|
||||
(int)patch.step, win_size, icenter, &minpt, &maxpt) >= 0 )
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
typedef IppStatus (CV_STDCALL *ippiGetRectSubPixFunc)( const void* src, int src_step,
|
||||
IppiSize src_size, void* dst,
|
||||
int dst_step, IppiSize win_size,
|
||||
IppiPoint_32f center,
|
||||
IppiPoint* minpt, IppiPoint* maxpt );
|
||||
|
||||
IppiPoint minpt={0,0}, maxpt={0,0};
|
||||
IppiPoint_32f icenter = {center.x, center.y};
|
||||
IppiSize src_size={image.cols, image.rows}, win_size={patch.cols, patch.rows};
|
||||
int srctype = image.type();
|
||||
ippiGetRectSubPixFunc ippfunc =
|
||||
srctype == CV_8UC1 && ddepth == CV_8U ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_8u_C1R :
|
||||
srctype == CV_8UC1 && ddepth == CV_32F ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_8u32f_C1R :
|
||||
srctype == CV_32FC1 && ddepth == CV_32F ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_32f_C1R : 0;
|
||||
|
||||
if( ippfunc)
|
||||
{
|
||||
if (ippfunc(image.ptr(), (int)image.step, src_size, patch.ptr(),
|
||||
(int)patch.step, win_size, icenter, &minpt, &maxpt) >= 0 )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -1178,68 +1178,74 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_IPP)
|
||||
int ippBorderType = borderType & ~BORDER_ISOLATED;
|
||||
Point ocvAnchor, ippAnchor;
|
||||
ocvAnchor.x = anchor.x < 0 ? ksize.width / 2 : anchor.x;
|
||||
ocvAnchor.y = anchor.y < 0 ? ksize.height / 2 : anchor.y;
|
||||
ippAnchor.x = ksize.width / 2 - (ksize.width % 2 == 0 ? 1 : 0);
|
||||
ippAnchor.y = ksize.height / 2 - (ksize.height % 2 == 0 ? 1 : 0);
|
||||
|
||||
if (normalize && !src.isSubmatrix() && ddepth == sdepth &&
|
||||
(/*ippBorderType == BORDER_REPLICATE ||*/ /* returns ippStsStepErr: Step value is not valid */
|
||||
ippBorderType == BORDER_CONSTANT) && ocvAnchor == ippAnchor &&
|
||||
dst.cols != ksize.width && dst.rows != ksize.height) // returns ippStsMaskSizeErr: mask has an illegal value
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
Ipp32s bufSize = 0;
|
||||
IppiSize roiSize = { dst.cols, dst.rows }, maskSize = { ksize.width, ksize.height };
|
||||
int ippBorderType = borderType & ~BORDER_ISOLATED;
|
||||
Point ocvAnchor, ippAnchor;
|
||||
ocvAnchor.x = anchor.x < 0 ? ksize.width / 2 : anchor.x;
|
||||
ocvAnchor.y = anchor.y < 0 ? ksize.height / 2 : anchor.y;
|
||||
ippAnchor.x = ksize.width / 2 - (ksize.width % 2 == 0 ? 1 : 0);
|
||||
ippAnchor.y = ksize.height / 2 - (ksize.height % 2 == 0 ? 1 : 0);
|
||||
|
||||
if (normalize && !src.isSubmatrix() && ddepth == sdepth &&
|
||||
(/*ippBorderType == BORDER_REPLICATE ||*/ /* returns ippStsStepErr: Step value is not valid */
|
||||
ippBorderType == BORDER_CONSTANT) && ocvAnchor == ippAnchor &&
|
||||
dst.cols != ksize.width && dst.rows != ksize.height) // returns ippStsMaskSizeErr: mask has an illegal value
|
||||
{
|
||||
Ipp32s bufSize = 0;
|
||||
IppiSize roiSize = { dst.cols, dst.rows }, maskSize = { ksize.width, ksize.height };
|
||||
|
||||
#define IPP_FILTER_BOX_BORDER(ippType, ippDataType, flavor) \
|
||||
do \
|
||||
{ \
|
||||
if (ippiFilterBoxBorderGetBufferSize(roiSize, maskSize, ippDataType, cn, &bufSize) >= 0) \
|
||||
do \
|
||||
{ \
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufSize); \
|
||||
ippType borderValue[4] = { 0, 0, 0, 0 }; \
|
||||
ippBorderType = ippBorderType == BORDER_CONSTANT ? ippBorderConst : ippBorderRepl; \
|
||||
IppStatus status = ippiFilterBoxBorder_##flavor(src.ptr<ippType>(), (int)src.step, dst.ptr<ippType>(), \
|
||||
(int)dst.step, roiSize, maskSize, \
|
||||
(IppiBorderType)ippBorderType, borderValue, buffer); \
|
||||
ippsFree(buffer); \
|
||||
if (status >= 0) \
|
||||
return; \
|
||||
} \
|
||||
setIppErrorStatus(); \
|
||||
} while ((void)0, 0)
|
||||
if (ippiFilterBoxBorderGetBufferSize(roiSize, maskSize, ippDataType, cn, &bufSize) >= 0) \
|
||||
{ \
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufSize); \
|
||||
ippType borderValue[4] = { 0, 0, 0, 0 }; \
|
||||
ippBorderType = ippBorderType == BORDER_CONSTANT ? ippBorderConst : ippBorderRepl; \
|
||||
IppStatus status = ippiFilterBoxBorder_##flavor(src.ptr<ippType>(), (int)src.step, dst.ptr<ippType>(), \
|
||||
(int)dst.step, roiSize, maskSize, \
|
||||
(IppiBorderType)ippBorderType, borderValue, buffer); \
|
||||
ippsFree(buffer); \
|
||||
if (status >= 0) \
|
||||
{ \
|
||||
CV_IMPL_ADD(CV_IMPL_IPP); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
setIppErrorStatus(); \
|
||||
} while ((void)0, 0)
|
||||
|
||||
if (stype == CV_8UC1)
|
||||
IPP_FILTER_BOX_BORDER(Ipp8u, ipp8u, 8u_C1R);
|
||||
else if (stype == CV_8UC3)
|
||||
IPP_FILTER_BOX_BORDER(Ipp8u, ipp8u, 8u_C3R);
|
||||
else if (stype == CV_8UC4)
|
||||
IPP_FILTER_BOX_BORDER(Ipp8u, ipp8u, 8u_C4R);
|
||||
if (stype == CV_8UC1)
|
||||
IPP_FILTER_BOX_BORDER(Ipp8u, ipp8u, 8u_C1R);
|
||||
else if (stype == CV_8UC3)
|
||||
IPP_FILTER_BOX_BORDER(Ipp8u, ipp8u, 8u_C3R);
|
||||
else if (stype == CV_8UC4)
|
||||
IPP_FILTER_BOX_BORDER(Ipp8u, ipp8u, 8u_C4R);
|
||||
|
||||
else if (stype == CV_16UC1)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16u, ipp16u, 16u_C1R);
|
||||
else if (stype == CV_16UC3)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16u, ipp16u, 16u_C3R);
|
||||
else if (stype == CV_16UC4)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16u, ipp16u, 16u_C4R);
|
||||
else if (stype == CV_16UC1)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16u, ipp16u, 16u_C1R);
|
||||
else if (stype == CV_16UC3)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16u, ipp16u, 16u_C3R);
|
||||
else if (stype == CV_16UC4)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16u, ipp16u, 16u_C4R);
|
||||
|
||||
else if (stype == CV_16SC1)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16s, ipp16s, 16s_C1R);
|
||||
else if (stype == CV_16SC3)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16s, ipp16s, 16s_C3R);
|
||||
else if (stype == CV_16SC4)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16s, ipp16s, 16s_C4R);
|
||||
else if (stype == CV_16SC1)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16s, ipp16s, 16s_C1R);
|
||||
else if (stype == CV_16SC3)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16s, ipp16s, 16s_C3R);
|
||||
else if (stype == CV_16SC4)
|
||||
IPP_FILTER_BOX_BORDER(Ipp16s, ipp16s, 16s_C4R);
|
||||
|
||||
else if (stype == CV_32FC1)
|
||||
IPP_FILTER_BOX_BORDER(Ipp32f, ipp32f, 32f_C1R);
|
||||
else if (stype == CV_32FC3)
|
||||
IPP_FILTER_BOX_BORDER(Ipp32f, ipp32f, 32f_C3R);
|
||||
else if (stype == CV_32FC4)
|
||||
IPP_FILTER_BOX_BORDER(Ipp32f, ipp32f, 32f_C4R);
|
||||
}
|
||||
else if (stype == CV_32FC1)
|
||||
IPP_FILTER_BOX_BORDER(Ipp32f, ipp32f, 32f_C1R);
|
||||
else if (stype == CV_32FC3)
|
||||
IPP_FILTER_BOX_BORDER(Ipp32f, ipp32f, 32f_C3R);
|
||||
else if (stype == CV_32FC4)
|
||||
IPP_FILTER_BOX_BORDER(Ipp32f, ipp32f, 32f_C4R);
|
||||
}
|
||||
#undef IPP_FILTER_BOX_BORDER
|
||||
}
|
||||
#endif
|
||||
|
||||
Ptr<FilterEngine> f = createBoxFilter( src.type(), dst.type(),
|
||||
@@ -1494,62 +1500,68 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
|
||||
#endif
|
||||
|
||||
#if IPP_VERSION_X100 >= 801 && 0 // these functions are slower in IPP 8.1
|
||||
int depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
|
||||
if ((depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F) && (cn == 1 || cn == 3) &&
|
||||
sigma1 == sigma2 && ksize.width == ksize.height && sigma1 != 0.0 )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiBorderType ippBorder = ippiGetBorderType(borderType);
|
||||
if (ippBorderConst == ippBorder || ippBorderRepl == ippBorder)
|
||||
int depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
|
||||
if ((depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F) && (cn == 1 || cn == 3) &&
|
||||
sigma1 == sigma2 && ksize.width == ksize.height && sigma1 != 0.0 )
|
||||
{
|
||||
Mat src = _src.getMat(), dst = _dst.getMat();
|
||||
IppiSize roiSize = { src.cols, src.rows };
|
||||
IppDataType dataType = ippiGetDataType(depth);
|
||||
Ipp32s specSize = 0, bufferSize = 0;
|
||||
|
||||
if (ippiFilterGaussianGetBufferSize(roiSize, (Ipp32u)ksize.width, dataType, cn, &specSize, &bufferSize) >= 0)
|
||||
IppiBorderType ippBorder = ippiGetBorderType(borderType);
|
||||
if (ippBorderConst == ippBorder || ippBorderRepl == ippBorder)
|
||||
{
|
||||
IppFilterGaussianSpec * pSpec = (IppFilterGaussianSpec *)ippMalloc(specSize);
|
||||
Ipp8u * pBuffer = (Ipp8u*)ippMalloc(bufferSize);
|
||||
Mat src = _src.getMat(), dst = _dst.getMat();
|
||||
IppiSize roiSize = { src.cols, src.rows };
|
||||
IppDataType dataType = ippiGetDataType(depth);
|
||||
Ipp32s specSize = 0, bufferSize = 0;
|
||||
|
||||
if (ippiFilterGaussianInit(roiSize, (Ipp32u)ksize.width, (Ipp32f)sigma1, ippBorder, dataType, 1, pSpec, pBuffer) >= 0)
|
||||
if (ippiFilterGaussianGetBufferSize(roiSize, (Ipp32u)ksize.width, dataType, cn, &specSize, &bufferSize) >= 0)
|
||||
{
|
||||
#define IPP_FILTER_GAUSS(ippfavor, ippcn) \
|
||||
do \
|
||||
{ \
|
||||
typedef Ipp##ippfavor ippType; \
|
||||
ippType borderValues[] = { 0, 0, 0 }; \
|
||||
IppStatus status = ippcn == 1 ? \
|
||||
ippiFilterGaussianBorder_##ippfavor##_C1R(src.ptr<ippType>(), (int)src.step, \
|
||||
dst.ptr<ippType>(), (int)dst.step, roiSize, borderValues[0], pSpec, pBuffer) : \
|
||||
ippiFilterGaussianBorder_##ippfavor##_C3R(src.ptr<ippType>(), (int)src.step, \
|
||||
dst.ptr<ippType>(), (int)dst.step, roiSize, borderValues, pSpec, pBuffer); \
|
||||
ippFree(pBuffer); \
|
||||
ippFree(pSpec); \
|
||||
if (status >= 0) \
|
||||
return; \
|
||||
} while ((void)0, 0)
|
||||
IppFilterGaussianSpec * pSpec = (IppFilterGaussianSpec *)ippMalloc(specSize);
|
||||
Ipp8u * pBuffer = (Ipp8u*)ippMalloc(bufferSize);
|
||||
|
||||
if (type == CV_8UC1)
|
||||
IPP_FILTER_GAUSS(8u, 1);
|
||||
else if (type == CV_8UC3)
|
||||
IPP_FILTER_GAUSS(8u, 3);
|
||||
else if (type == CV_16UC1)
|
||||
IPP_FILTER_GAUSS(16u, 1);
|
||||
else if (type == CV_16UC3)
|
||||
IPP_FILTER_GAUSS(16u, 3);
|
||||
else if (type == CV_16SC1)
|
||||
IPP_FILTER_GAUSS(16s, 1);
|
||||
else if (type == CV_16SC3)
|
||||
IPP_FILTER_GAUSS(16s, 3);
|
||||
else if (type == CV_32FC1)
|
||||
IPP_FILTER_GAUSS(32f, 1);
|
||||
else if (type == CV_32FC3)
|
||||
IPP_FILTER_GAUSS(32f, 3);
|
||||
if (ippiFilterGaussianInit(roiSize, (Ipp32u)ksize.width, (Ipp32f)sigma1, ippBorder, dataType, 1, pSpec, pBuffer) >= 0)
|
||||
{
|
||||
#define IPP_FILTER_GAUSS(ippfavor, ippcn) \
|
||||
do \
|
||||
{ \
|
||||
typedef Ipp##ippfavor ippType; \
|
||||
ippType borderValues[] = { 0, 0, 0 }; \
|
||||
IppStatus status = ippcn == 1 ? \
|
||||
ippiFilterGaussianBorder_##ippfavor##_C1R(src.ptr<ippType>(), (int)src.step, \
|
||||
dst.ptr<ippType>(), (int)dst.step, roiSize, borderValues[0], pSpec, pBuffer) : \
|
||||
ippiFilterGaussianBorder_##ippfavor##_C3R(src.ptr<ippType>(), (int)src.step, \
|
||||
dst.ptr<ippType>(), (int)dst.step, roiSize, borderValues, pSpec, pBuffer); \
|
||||
ippFree(pBuffer); \
|
||||
ippFree(pSpec); \
|
||||
if (status >= 0) \
|
||||
{ \
|
||||
CV_IMPL_ADD(CV_IMPL_IPP); \
|
||||
return; \
|
||||
} \
|
||||
} while ((void)0, 0)
|
||||
|
||||
if (type == CV_8UC1)
|
||||
IPP_FILTER_GAUSS(8u, 1);
|
||||
else if (type == CV_8UC3)
|
||||
IPP_FILTER_GAUSS(8u, 3);
|
||||
else if (type == CV_16UC1)
|
||||
IPP_FILTER_GAUSS(16u, 1);
|
||||
else if (type == CV_16UC3)
|
||||
IPP_FILTER_GAUSS(16u, 3);
|
||||
else if (type == CV_16SC1)
|
||||
IPP_FILTER_GAUSS(16s, 1);
|
||||
else if (type == CV_16SC3)
|
||||
IPP_FILTER_GAUSS(16s, 3);
|
||||
else if (type == CV_32FC1)
|
||||
IPP_FILTER_GAUSS(32f, 1);
|
||||
else if (type == CV_32FC3)
|
||||
IPP_FILTER_GAUSS(32f, 3);
|
||||
#undef IPP_FILTER_GAUSS
|
||||
}
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2483,45 +2495,51 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize )
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
#define IPP_FILTER_MEDIAN_BORDER(ippType, ippDataType, flavor) \
|
||||
do \
|
||||
{ \
|
||||
if (ippiFilterMedianBorderGetBufferSize(dstRoiSize, maskSize, \
|
||||
ippDataType, CV_MAT_CN(type), &bufSize) >= 0) \
|
||||
{ \
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufSize); \
|
||||
IppStatus status = ippiFilterMedianBorder_##flavor(src.ptr<ippType>(), (int)src.step, \
|
||||
dst.ptr<ippType>(), (int)dst.step, dstRoiSize, maskSize, \
|
||||
ippBorderRepl, (ippType)0, buffer); \
|
||||
ippsFree(buffer); \
|
||||
if (status >= 0) \
|
||||
return; \
|
||||
} \
|
||||
setIppErrorStatus(); \
|
||||
} \
|
||||
while ((void)0, 0)
|
||||
|
||||
if( ksize <= 5 )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
Ipp32s bufSize;
|
||||
IppiSize dstRoiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize, ksize);
|
||||
Mat src;
|
||||
if( dst.data != src0.data )
|
||||
src = src0;
|
||||
else
|
||||
src0.copyTo(src);
|
||||
#define IPP_FILTER_MEDIAN_BORDER(ippType, ippDataType, flavor) \
|
||||
do \
|
||||
{ \
|
||||
if (ippiFilterMedianBorderGetBufferSize(dstRoiSize, maskSize, \
|
||||
ippDataType, CV_MAT_CN(type), &bufSize) >= 0) \
|
||||
{ \
|
||||
Ipp8u * buffer = ippsMalloc_8u(bufSize); \
|
||||
IppStatus status = ippiFilterMedianBorder_##flavor(src.ptr<ippType>(), (int)src.step, \
|
||||
dst.ptr<ippType>(), (int)dst.step, dstRoiSize, maskSize, \
|
||||
ippBorderRepl, (ippType)0, buffer); \
|
||||
ippsFree(buffer); \
|
||||
if (status >= 0) \
|
||||
{ \
|
||||
CV_IMPL_ADD(CV_IMPL_IPP); \
|
||||
return; \
|
||||
} \
|
||||
} \
|
||||
setIppErrorStatus(); \
|
||||
} \
|
||||
while ((void)0, 0)
|
||||
|
||||
int type = src0.type();
|
||||
if (type == CV_8UC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp8u, ipp8u, 8u_C1R);
|
||||
else if (type == CV_16UC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp16u, ipp16u, 16u_C1R);
|
||||
else if (type == CV_16SC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp16s, ipp16s, 16s_C1R);
|
||||
else if (type == CV_32FC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp32f, ipp32f, 32f_C1R);
|
||||
}
|
||||
if( ksize <= 5 )
|
||||
{
|
||||
Ipp32s bufSize;
|
||||
IppiSize dstRoiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize, ksize);
|
||||
Mat src;
|
||||
if( dst.data != src0.data )
|
||||
src = src0;
|
||||
else
|
||||
src0.copyTo(src);
|
||||
|
||||
int type = src0.type();
|
||||
if (type == CV_8UC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp8u, ipp8u, 8u_C1R);
|
||||
else if (type == CV_16UC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp16u, ipp16u, 16u_C1R);
|
||||
else if (type == CV_16SC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp16s, ipp16s, 16s_C1R);
|
||||
else if (type == CV_32FC1)
|
||||
IPP_FILTER_MEDIAN_BORDER(Ipp32f, ipp32f, 32f_C1R);
|
||||
}
|
||||
#undef IPP_FILTER_MEDIAN_BORDER
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
@@ -2771,6 +2789,10 @@ public:
|
||||
}
|
||||
if (0 > ippiFilterBilateral_8u_C1R( src.ptr<uchar>(range.start) + radius * ((int)src.step[0] + 1), (int)src.step[0], dst.ptr<uchar>(range.start), (int)dst.step[0], roi, kernel, pSpec ))
|
||||
*ok = false;
|
||||
else
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
}
|
||||
}
|
||||
private:
|
||||
Mat &src;
|
||||
@@ -2902,14 +2924,20 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
|
||||
copyMakeBorder( src, temp, radius, radius, radius, radius, borderType );
|
||||
|
||||
#if defined HAVE_IPP && (IPP_VERSION_MAJOR >= 7) && 0
|
||||
if( cn == 1 )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
bool ok;
|
||||
IPPBilateralFilter_8u_Invoker body(temp, dst, sigma_color * sigma_color, sigma_space * sigma_space, radius, &ok );
|
||||
parallel_for_(Range(0, dst.rows), body, dst.total()/(double)(1<<16));
|
||||
if( ok )
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
if( cn == 1 )
|
||||
{
|
||||
bool ok;
|
||||
IPPBilateralFilter_8u_Invoker body(temp, dst, sigma_color * sigma_color, sigma_space * sigma_space, radius, &ok );
|
||||
parallel_for_(Range(0, dst.rows), body, dst.total()/(double)(1<<16));
|
||||
if( ok )
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -355,35 +355,41 @@ void cv::integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, Output
|
||||
};
|
||||
|
||||
#if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) // Disabled on ICV due invalid results
|
||||
if( ( depth == CV_8U ) && ( sdepth == CV_32F || sdepth == CV_32S ) && ( !_tilted.needed() ) && ( !_sqsum.needed() || sqdepth == CV_64F ) && ( cn == 1 ) )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppStatus status = ippStsErr;
|
||||
IppiSize srcRoiSize = ippiSize( src.cols, src.rows );
|
||||
if( sdepth == CV_32F )
|
||||
if( ( depth == CV_8U ) && ( sdepth == CV_32F || sdepth == CV_32S ) && ( !_tilted.needed() ) && ( !_sqsum.needed() || sqdepth == CV_64F ) && ( cn == 1 ) )
|
||||
{
|
||||
if( _sqsum.needed() )
|
||||
IppStatus status = ippStsErr;
|
||||
IppiSize srcRoiSize = ippiSize( src.cols, src.rows );
|
||||
if( sdepth == CV_32F )
|
||||
{
|
||||
status = ippiSqrIntegral_8u32f64f_C1R( (const Ipp8u*)src.data, (int)src.step, (Ipp32f*)sum.data, (int)sum.step, (Ipp64f*)sqsum.data, (int)sqsum.step, srcRoiSize, 0, 0 );
|
||||
if( _sqsum.needed() )
|
||||
{
|
||||
status = ippiSqrIntegral_8u32f64f_C1R( (const Ipp8u*)src.data, (int)src.step, (Ipp32f*)sum.data, (int)sum.step, (Ipp64f*)sqsum.data, (int)sqsum.step, srcRoiSize, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ippiIntegral_8u32f_C1R( (const Ipp8u*)src.data, (int)src.step, (Ipp32f*)sum.data, (int)sum.step, srcRoiSize, 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
else if( sdepth == CV_32S )
|
||||
{
|
||||
status = ippiIntegral_8u32f_C1R( (const Ipp8u*)src.data, (int)src.step, (Ipp32f*)sum.data, (int)sum.step, srcRoiSize, 0 );
|
||||
if( _sqsum.needed() )
|
||||
{
|
||||
status = ippiSqrIntegral_8u32s64f_C1R( (const Ipp8u*)src.data, (int)src.step, (Ipp32s*)sum.data, (int)sum.step, (Ipp64f*)sqsum.data, (int)sqsum.step, srcRoiSize, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ippiIntegral_8u32s_C1R( (const Ipp8u*)src.data, (int)src.step, (Ipp32s*)sum.data, (int)sum.step, srcRoiSize, 0 );
|
||||
}
|
||||
}
|
||||
if (0 <= status)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
else if( sdepth == CV_32S )
|
||||
{
|
||||
if( _sqsum.needed() )
|
||||
{
|
||||
status = ippiSqrIntegral_8u32s64f_C1R( (const Ipp8u*)src.data, (int)src.step, (Ipp32s*)sum.data, (int)sum.step, (Ipp64f*)sqsum.data, (int)sqsum.step, srcRoiSize, 0, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ippiIntegral_8u32s_C1R( (const Ipp8u*)src.data, (int)src.step, (Ipp32s*)sum.data, (int)sum.step, srcRoiSize, 0 );
|
||||
}
|
||||
}
|
||||
if (0 <= status)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -853,13 +853,20 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
|
||||
#endif
|
||||
|
||||
#if defined HAVE_IPP
|
||||
bool useIppMT = (templ.rows < img.rows/2 && templ.cols < img.cols/2);
|
||||
|
||||
if (method == CV_TM_SQDIFF && cn == 1 && useIppMT)
|
||||
bool useIppMT = false;
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (ipp_sqrDistance(img, templ, result))
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
useIppMT = (templ.rows < img.rows/2 && templ.cols < img.cols/2);
|
||||
|
||||
if (method == CV_TM_SQDIFF && cn == 1 && useIppMT)
|
||||
{
|
||||
if (ipp_sqrDistance(img, templ, result))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -871,6 +878,10 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
|
||||
setIppErrorStatus();
|
||||
crossCorr( img, templ, result, result.size(), result.type(), Point(0,0), 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@@ -69,39 +69,60 @@ thresh_8u( const Mat& _src, Mat& _dst, uchar thresh, uchar maxval, int type )
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_IPP)
|
||||
IppiSize sz = { roi.width, roi.height };
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
switch( type )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
case THRESH_TRUNC:
|
||||
IppiSize sz = { roi.width, roi.height };
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
switch( type )
|
||||
{
|
||||
case THRESH_TRUNC:
|
||||
#ifndef HAVE_IPP_ICV_ONLY
|
||||
if (_src.data == _dst.data && ippiThreshold_GT_8u_C1IR(_dst.ptr(), (int)dst_step, sz, thresh) >= 0)
|
||||
return;
|
||||
if (_src.data == _dst.data && ippiThreshold_GT_8u_C1IR(_dst.ptr(), (int)dst_step, sz, thresh) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (ippiThreshold_GT_8u_C1R(_src.ptr(), (int)src_step, _dst.ptr(), (int)dst_step, sz, thresh) >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO:
|
||||
if (ippiThreshold_GT_8u_C1R(_src.ptr(), (int)src_step, _dst.ptr(), (int)dst_step, sz, thresh) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO:
|
||||
#ifndef HAVE_IPP_ICV_ONLY
|
||||
if (_src.data == _dst.data && ippiThreshold_LTVal_8u_C1IR(_dst.ptr(), (int)dst_step, sz, thresh+1, 0) >= 0)
|
||||
return;
|
||||
if (_src.data == _dst.data && ippiThreshold_LTVal_8u_C1IR(_dst.ptr(), (int)dst_step, sz, thresh+1, 0) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (ippiThreshold_LTVal_8u_C1R(_src.ptr(), (int)src_step, _dst.ptr(), (int)dst_step, sz, thresh+1, 0) >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO_INV:
|
||||
if (ippiThreshold_LTVal_8u_C1R(_src.ptr(), (int)src_step, _dst.ptr(), (int)dst_step, sz, thresh+1, 0) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO_INV:
|
||||
#ifndef HAVE_IPP_ICV_ONLY
|
||||
if (_src.data == _dst.data && ippiThreshold_GTVal_8u_C1IR(_dst.ptr(), (int)dst_step, sz, thresh, 0) >= 0)
|
||||
return;
|
||||
if (_src.data == _dst.data && ippiThreshold_GTVal_8u_C1IR(_dst.ptr(), (int)dst_step, sz, thresh, 0) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (ippiThreshold_GTVal_8u_C1R(_src.ptr(), (int)src_step, _dst.ptr(), (int)dst_step, sz, thresh, 0) >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
if (ippiThreshold_GTVal_8u_C1R(_src.ptr(), (int)src_step, _dst.ptr(), (int)dst_step, sz, thresh, 0) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
}
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
#endif
|
||||
|
||||
switch( type )
|
||||
@@ -392,39 +413,60 @@ thresh_16s( const Mat& _src, Mat& _dst, short thresh, short maxval, int type )
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_IPP)
|
||||
IppiSize sz = { roi.width, roi.height };
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
switch( type )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
case THRESH_TRUNC:
|
||||
IppiSize sz = { roi.width, roi.height };
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
switch( type )
|
||||
{
|
||||
case THRESH_TRUNC:
|
||||
#ifndef HAVE_IPP_ICV_ONLY
|
||||
if (_src.data == _dst.data && ippiThreshold_GT_16s_C1IR(dst, (int)dst_step*sizeof(dst[0]), sz, thresh) >= 0)
|
||||
return;
|
||||
if (_src.data == _dst.data && ippiThreshold_GT_16s_C1IR(dst, (int)dst_step*sizeof(dst[0]), sz, thresh) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (ippiThreshold_GT_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh) >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO:
|
||||
if (ippiThreshold_GT_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO:
|
||||
#ifndef HAVE_IPP_ICV_ONLY
|
||||
if (_src.data == _dst.data && ippiThreshold_LTVal_16s_C1IR(dst, (int)dst_step*sizeof(dst[0]), sz, thresh + 1, 0) >= 0)
|
||||
return;
|
||||
if (_src.data == _dst.data && ippiThreshold_LTVal_16s_C1IR(dst, (int)dst_step*sizeof(dst[0]), sz, thresh + 1, 0) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (ippiThreshold_LTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh+1, 0) >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO_INV:
|
||||
if (ippiThreshold_LTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh+1, 0) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO_INV:
|
||||
#ifndef HAVE_IPP_ICV_ONLY
|
||||
if (_src.data == _dst.data && ippiThreshold_GTVal_16s_C1IR(dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0) >= 0)
|
||||
return;
|
||||
if (_src.data == _dst.data && ippiThreshold_GTVal_16s_C1IR(dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (ippiThreshold_GTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0) >= 0)
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
if (ippiThreshold_GTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
}
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
#endif
|
||||
|
||||
switch( type )
|
||||
@@ -639,24 +681,36 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_IPP)
|
||||
IppiSize sz = { roi.width, roi.height };
|
||||
switch( type )
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
case THRESH_TRUNC:
|
||||
if (0 <= ippiThreshold_GT_32f_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh))
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO:
|
||||
if (0 <= ippiThreshold_LTVal_32f_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh+FLT_EPSILON, 0))
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO_INV:
|
||||
if (0 <= ippiThreshold_GTVal_32f_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0))
|
||||
return;
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
IppiSize sz = { roi.width, roi.height };
|
||||
switch( type )
|
||||
{
|
||||
case THRESH_TRUNC:
|
||||
if (0 <= ippiThreshold_GT_32f_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO:
|
||||
if (0 <= ippiThreshold_LTVal_32f_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh+FLT_EPSILON, 0))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
case THRESH_TOZERO_INV:
|
||||
if (0 <= ippiThreshold_GTVal_32f_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -864,14 +918,20 @@ getThreshVal_Otsu_8u( const Mat& _src )
|
||||
}
|
||||
|
||||
#if IPP_VERSION_X100 >= 801 && !defined(HAVE_IPP_ICV_ONLY)
|
||||
IppiSize srcSize = { size.width, size.height };
|
||||
Ipp8u thresh;
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
IppStatus ok = ippiComputeThreshold_Otsu_8u_C1R(_src.ptr(), step, srcSize, &thresh);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
return thresh;
|
||||
setIppErrorStatus();
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
IppiSize srcSize = { size.width, size.height };
|
||||
Ipp8u thresh;
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
IppStatus ok = ippiComputeThreshold_Otsu_8u_C1R(_src.ptr(), step, srcSize, &thresh);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
if (ok >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return thresh;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
#endif
|
||||
|
||||
const int N = 256;
|
||||
|
Reference in New Issue
Block a user