|
|
|
@ -843,78 +843,87 @@ static bool ocl_accumulate( InputArray _src, InputArray _src2, InputOutputArray |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask ) |
|
|
|
|
#if defined(HAVE_IPP) |
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
|
static bool ipp_accumulate(InputArray _src, InputOutputArray _dst, InputArray _mask) |
|
|
|
|
{ |
|
|
|
|
int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); |
|
|
|
|
|
|
|
|
|
CV_Assert( _src.sameSize(_dst) && dcn == scn ); |
|
|
|
|
CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8U) ); |
|
|
|
|
|
|
|
|
|
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), |
|
|
|
|
ocl_accumulate(_src, noArray(), _dst, 0.0, _mask, ACCUMULATE)) |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype); |
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
#if defined HAVE_IPP |
|
|
|
|
CV_IPP_CHECK() |
|
|
|
|
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && (mask.empty() || mask.isContinuous()))) |
|
|
|
|
{ |
|
|
|
|
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && (mask.empty() || mask.isContinuous()))) |
|
|
|
|
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()) |
|
|
|
|
{ |
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
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 (mask.empty()) |
|
|
|
|
{ |
|
|
|
|
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 = ippStsErr; |
|
|
|
|
|
|
|
|
|
if (ippFunc || ippFuncMask) |
|
|
|
|
Size size = src.size(); |
|
|
|
|
int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step; |
|
|
|
|
if (src.isContinuous() && dst.isContinuous() && mask.isContinuous()) |
|
|
|
|
{ |
|
|
|
|
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(); |
|
|
|
|
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 (ippFunc) |
|
|
|
|
status = ippFunc(src.ptr(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height)); |
|
|
|
|
else if(ippFuncMask) |
|
|
|
|
status = ippFuncMask(src.ptr(), srcstep, mask.ptr<Ipp8u>(), maskstep, |
|
|
|
|
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height)); |
|
|
|
|
|
|
|
|
|
if (status >= 0) |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask ) |
|
|
|
|
{ |
|
|
|
|
int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); |
|
|
|
|
|
|
|
|
|
CV_Assert( _src.sameSize(_dst) && dcn == scn ); |
|
|
|
|
CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8U) ); |
|
|
|
|
|
|
|
|
|
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), |
|
|
|
|
ocl_accumulate(_src, noArray(), _dst, 0.0, _mask, ACCUMULATE)) |
|
|
|
|
|
|
|
|
|
CV_IPP_RUN((_src.dims() <= 2 || (_src.isContinuous() && _dst.isContinuous() && (_mask.empty() || _mask.isContinuous()))), |
|
|
|
|
ipp_accumulate(_src, _dst, _mask)); |
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int fidx = getAccTabIdx(sdepth, ddepth); |
|
|
|
|
AccFunc func = fidx >= 0 ? accTab[fidx] : 0; |
|
|
|
|
CV_Assert( func != 0 ); |
|
|
|
@ -928,76 +937,84 @@ void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask ) |
|
|
|
|
func(ptrs[0], ptrs[1], ptrs[2], len, scn); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _mask ) |
|
|
|
|
#if defined(HAVE_IPP) |
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
|
static bool ipp_accumulate_square(InputArray _src, InputOutputArray _dst, InputArray _mask) |
|
|
|
|
{ |
|
|
|
|
int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); |
|
|
|
|
|
|
|
|
|
CV_Assert( _src.sameSize(_dst) && dcn == scn ); |
|
|
|
|
CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8U) ); |
|
|
|
|
|
|
|
|
|
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), |
|
|
|
|
ocl_accumulate(_src, noArray(), _dst, 0.0, _mask, ACCUMULATE_SQUARE)) |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype); |
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
#if defined(HAVE_IPP) |
|
|
|
|
CV_IPP_CHECK() |
|
|
|
|
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && (mask.empty() || mask.isContinuous()))) |
|
|
|
|
{ |
|
|
|
|
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()) |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
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 (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 = ippStsErr; |
|
|
|
|
|
|
|
|
|
if (ippFunc || ippFuncMask) |
|
|
|
|
Size size = src.size(); |
|
|
|
|
int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step; |
|
|
|
|
if (src.isContinuous() && dst.isContinuous() && mask.isContinuous()) |
|
|
|
|
{ |
|
|
|
|
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(); |
|
|
|
|
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 (ippFunc) |
|
|
|
|
status = ippFunc(src.ptr(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height)); |
|
|
|
|
else if(ippFuncMask) |
|
|
|
|
status = ippFuncMask(src.ptr(), srcstep, mask.ptr<Ipp8u>(), maskstep, |
|
|
|
|
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height)); |
|
|
|
|
|
|
|
|
|
if (status >= 0) |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _mask ) |
|
|
|
|
{ |
|
|
|
|
int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); |
|
|
|
|
|
|
|
|
|
CV_Assert( _src.sameSize(_dst) && dcn == scn ); |
|
|
|
|
CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8U) ); |
|
|
|
|
|
|
|
|
|
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), |
|
|
|
|
ocl_accumulate(_src, noArray(), _dst, 0.0, _mask, ACCUMULATE_SQUARE)) |
|
|
|
|
|
|
|
|
|
CV_IPP_RUN((_src.dims() <= 2 || (_src.isContinuous() && _dst.isContinuous() && (_mask.empty() || _mask.isContinuous()))), |
|
|
|
|
ipp_accumulate_square(_src, _dst, _mask)); |
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
int fidx = getAccTabIdx(sdepth, ddepth); |
|
|
|
|
AccFunc func = fidx >= 0 ? accSqrTab[fidx] : 0; |
|
|
|
|
CV_Assert( func != 0 ); |
|
|
|
@ -1011,6 +1028,74 @@ void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _m |
|
|
|
|
func(ptrs[0], ptrs[1], ptrs[2], len, scn); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if defined(HAVE_IPP) |
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
|
static bool ipp_accumulate_product(InputArray _src1, InputArray _src2, |
|
|
|
|
InputOutputArray _dst, InputArray _mask) |
|
|
|
|
{ |
|
|
|
|
int stype = _src1.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype); |
|
|
|
|
|
|
|
|
|
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
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 = ippStsErr; |
|
|
|
|
|
|
|
|
|
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 (ippFunc) |
|
|
|
|
status = ippFunc(src1.ptr(), src1step, src2.ptr(), src2step, dst.ptr<Ipp32f>(), |
|
|
|
|
dststep, ippiSize(size.width, size.height)); |
|
|
|
|
else if(ippFuncMask) |
|
|
|
|
status = ippFuncMask(src1.ptr(), src1step, src2.ptr(), src2step, mask.ptr<Ipp8u>(), maskstep, |
|
|
|
|
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height)); |
|
|
|
|
|
|
|
|
|
if (status >= 0) |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cv::accumulateProduct( InputArray _src1, InputArray _src2, |
|
|
|
|
InputOutputArray _dst, InputArray _mask ) |
|
|
|
|
{ |
|
|
|
@ -1024,67 +1109,10 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2, |
|
|
|
|
CV_OCL_RUN(_src1.dims() <= 2 && _dst.isUMat(), |
|
|
|
|
ocl_accumulate(_src1, _src2, _dst, 0.0, _mask, ACCUMULATE_PRODUCT)) |
|
|
|
|
|
|
|
|
|
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
#if defined(HAVE_IPP) |
|
|
|
|
CV_IPP_CHECK() |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
CV_IPP_RUN( (_src1.dims() <= 2 || (_src1.isContinuous() && _src2.isContinuous() && _dst.isContinuous())), |
|
|
|
|
ipp_accumulate_product(_src1, _src2, _dst, _mask)); |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
int fidx = getAccTabIdx(sdepth, ddepth); |
|
|
|
|
AccProdFunc func = fidx >= 0 ? accProdTab[fidx] : 0; |
|
|
|
@ -1099,79 +1127,89 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2, |
|
|
|
|
func(ptrs[0], ptrs[1], ptrs[2], ptrs[3], len, scn); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst, |
|
|
|
|
#if defined(HAVE_IPP) |
|
|
|
|
namespace cv |
|
|
|
|
{ |
|
|
|
|
static bool ipp_accumulate_weighted( InputArray _src, InputOutputArray _dst, |
|
|
|
|
double alpha, InputArray _mask ) |
|
|
|
|
{ |
|
|
|
|
int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); |
|
|
|
|
|
|
|
|
|
CV_Assert( _src.sameSize(_dst) && dcn == scn ); |
|
|
|
|
CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8U) ); |
|
|
|
|
|
|
|
|
|
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), |
|
|
|
|
ocl_accumulate(_src, noArray(), _dst, alpha, _mask, ACCUMULATE_WEIGHTED)) |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype); |
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
#if defined(HAVE_IPP) |
|
|
|
|
CV_IPP_CHECK() |
|
|
|
|
if (src.dims <= 2 || (src.isContinuous() && dst.isContinuous() && mask.isContinuous())) |
|
|
|
|
{ |
|
|
|
|
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()) |
|
|
|
|
{ |
|
|
|
|
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 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; |
|
|
|
|
} |
|
|
|
|
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) |
|
|
|
|
if (ippFunc || ippFuncMask) |
|
|
|
|
{ |
|
|
|
|
IppStatus status = ippStsErr; |
|
|
|
|
|
|
|
|
|
Size size = src.size(); |
|
|
|
|
int srcstep = (int)src.step, dststep = (int)dst.step, maskstep = (int)mask.step; |
|
|
|
|
if (src.isContinuous() && dst.isContinuous() && mask.isContinuous()) |
|
|
|
|
{ |
|
|
|
|
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(); |
|
|
|
|
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 (ippFunc) |
|
|
|
|
status = ippFunc(src.ptr(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height), (Ipp32f)alpha); |
|
|
|
|
else if(ippFuncMask) |
|
|
|
|
status = ippFuncMask(src.ptr(), srcstep, mask.ptr<Ipp8u>(), maskstep, |
|
|
|
|
dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height), (Ipp32f)alpha); |
|
|
|
|
|
|
|
|
|
if (status >= 0) |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst, |
|
|
|
|
double alpha, InputArray _mask ) |
|
|
|
|
{ |
|
|
|
|
int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), scn = CV_MAT_CN(stype); |
|
|
|
|
int dtype = _dst.type(), ddepth = CV_MAT_DEPTH(dtype), dcn = CV_MAT_CN(dtype); |
|
|
|
|
|
|
|
|
|
CV_Assert( _src.sameSize(_dst) && dcn == scn ); |
|
|
|
|
CV_Assert( _mask.empty() || (_src.sameSize(_mask) && _mask.type() == CV_8U) ); |
|
|
|
|
|
|
|
|
|
CV_OCL_RUN(_src.dims() <= 2 && _dst.isUMat(), |
|
|
|
|
ocl_accumulate(_src, noArray(), _dst, alpha, _mask, ACCUMULATE_WEIGHTED)) |
|
|
|
|
|
|
|
|
|
CV_IPP_RUN((_src.dims() <= 2 || (_src.isContinuous() && _dst.isContinuous() && _mask.isContinuous())), ipp_accumulate_weighted(_src, _dst, alpha, _mask)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int fidx = getAccTabIdx(sdepth, ddepth); |
|
|
|
|
AccWFunc func = fidx >= 0 ? accWTab[fidx] : 0; |
|
|
|
|
CV_Assert( func != 0 ); |
|
|
|
|