mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 22:00:25 +08:00
cv::accumulateSquare && cv::acumulateProduct
This commit is contained in:
parent
2c0c887f70
commit
c224cfa628
@ -457,6 +457,56 @@ void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _m
|
||||
|
||||
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && (mask.empty() || mask.isContinuous())))
|
||||
{
|
||||
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())
|
||||
{
|
||||
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 = src.total() * src.elemSize();
|
||||
dststep = dst.total() * dst.elemSize();
|
||||
maskstep = mask.total() * mask.elemSize();
|
||||
size.width = (int)src.total();
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src.data, srcstep, (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height));
|
||||
else
|
||||
status = ippFuncMask(src.data, srcstep, (Ipp8u *)mask.data, maskstep,
|
||||
(Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height));
|
||||
|
||||
if (status == ippStsNoErr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int fidx = getAccTabIdx(sdepth, ddepth);
|
||||
AccFunc func = fidx >= 0 ? accSqrTab[fidx] : 0;
|
||||
CV_Assert( func != 0 );
|
||||
@ -485,6 +535,59 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2,
|
||||
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
if (src1.dims <= 2 || (src1.isContinuous() && src2.isContinuous() && dst.isContinuous()))
|
||||
{
|
||||
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())
|
||||
{
|
||||
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.empty())
|
||||
{
|
||||
src1step = src1.total() * src1.elemSize();
|
||||
src2step = src2.total() * src2.elemSize();
|
||||
dststep = dst.total() * dst.elemSize();
|
||||
maskstep = mask.total() * mask.elemSize();
|
||||
size.width = (int)src1.total();
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src1.data, src1step, src2.data, src2step, (Ipp32f *)dst.data,
|
||||
dststep, ippiSize(size.width, size.height));
|
||||
else
|
||||
status = ippFuncMask(src1.data, src1step, src2.data, src2step, (Ipp8u *)mask.data, maskstep,
|
||||
(Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height));
|
||||
|
||||
if (status == ippStsNoErr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int fidx = getAccTabIdx(sdepth, ddepth);
|
||||
AccProdFunc func = fidx >= 0 ? accProdTab[fidx] : 0;
|
||||
CV_Assert( func != 0 );
|
||||
@ -513,35 +616,54 @@ void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst,
|
||||
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
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 (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && mask.isContinuous()))
|
||||
{
|
||||
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())
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
if (mask.empty())
|
||||
status = ippFunc(src.data, (int)src.step, (Ipp32f *)dst.data, (int)dst.step, ippiSize(src.cols * scn, src.rows), (Ipp32f)alpha);
|
||||
else
|
||||
status = ippFuncMask(src.data, (int)src.step, (Ipp8u *)mask.data, (int)mask.step,
|
||||
(Ipp32f *)dst.data, (int)dst.step, ippiSize(src.cols * scn, src.rows), (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 == ippStsNoErr)
|
||||
return;
|
||||
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.empty())
|
||||
{
|
||||
srcstep = src.total() * src.elemSize();
|
||||
dststep = dst.total() * dst.elemSize();
|
||||
maskstep = mask.total() * mask.elemSize();
|
||||
size.width = (int)src.total();
|
||||
size.height = 1;
|
||||
}
|
||||
size.width *= scn;
|
||||
|
||||
if (mask.empty())
|
||||
status = ippFunc(src.data, srcstep, (Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height), (Ipp32f)alpha);
|
||||
else
|
||||
status = ippFuncMask(src.data, srcstep, (Ipp8u *)mask.data, maskstep,
|
||||
(Ipp32f *)dst.data, dststep, ippiSize(size.width, size.height), (Ipp32f)alpha);
|
||||
|
||||
if (status == ippStsNoErr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user