mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 22:00:25 +08:00
Merge pull request #2614 from ilya-lavrenov:ipp_laplacian
This commit is contained in:
commit
f4c5679db8
@ -230,6 +230,15 @@ static inline IppiSize ippiSize(const cv::Size & _size)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline IppiBorderType ippiGetBorderType(int borderTypeNI)
|
||||||
|
{
|
||||||
|
return borderTypeNI == cv::BORDER_CONSTANT ? ippBorderConst :
|
||||||
|
borderTypeNI == cv::BORDER_WRAP ? ippBorderWrap :
|
||||||
|
borderTypeNI == cv::BORDER_REPLICATE ? ippBorderRepl :
|
||||||
|
borderTypeNI == cv::BORDER_REFLECT_101 ? ippBorderMirror :
|
||||||
|
borderTypeNI == cv::BORDER_REFLECT ? ippBorderMirrorR : (IppiBorderType)-1;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define IPP_VERSION_X100 0
|
# define IPP_VERSION_X100 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -696,7 +696,7 @@ int cv::countNonZero( InputArray _src )
|
|||||||
if (src.dims <= 2 || src.isContinuous())
|
if (src.dims <= 2 || src.isContinuous())
|
||||||
{
|
{
|
||||||
IppiSize roiSize = { src.cols, src.rows };
|
IppiSize roiSize = { src.cols, src.rows };
|
||||||
Ipp32s count, srcstep = (Ipp32s)src.step;
|
Ipp32s count = 0, srcstep = (Ipp32s)src.step;
|
||||||
IppStatus status = (IppStatus)-1;
|
IppStatus status = (IppStatus)-1;
|
||||||
|
|
||||||
if (src.isContinuous())
|
if (src.isContinuous())
|
||||||
|
@ -112,7 +112,7 @@ OCL_PERF_TEST_P(LaplacianFixture, Laplacian,
|
|||||||
const FilterParams params = GetParam();
|
const FilterParams params = GetParam();
|
||||||
const Size srcSize = get<0>(params);
|
const Size srcSize = get<0>(params);
|
||||||
const int type = get<1>(params), ksize = get<2>(params);
|
const int type = get<1>(params), ksize = get<2>(params);
|
||||||
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
|
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 2e-5;
|
||||||
|
|
||||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||||
|
|
||||||
|
@ -577,6 +577,64 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
|
|||||||
ddepth = sdepth;
|
ddepth = sdepth;
|
||||||
_dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) );
|
_dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) );
|
||||||
|
|
||||||
|
#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY
|
||||||
|
if ((ksize == 3 || ksize == 5) && ((borderType & BORDER_ISOLATED) != 0 || !_src.isSubmatrix()) &&
|
||||||
|
((stype == CV_8UC1 && ddepth == CV_16S) || (ddepth == CV_32F && stype == CV_32FC1)))
|
||||||
|
{
|
||||||
|
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) \
|
||||||
|
{ \
|
||||||
|
Ipp8u * buffer = ippsMalloc_8u(bufsize); \
|
||||||
|
status = ippiFilterLaplacianBorder_##ippfavor##_C1R((const ippsrctype *)src.data, (int)src.step, (ippdsttype *)dst.data, \
|
||||||
|
(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);
|
||||||
|
|
||||||
|
if (needScale && status >= 0)
|
||||||
|
status = ippiMulC_16s_C1IRSfs((Ipp16s)iscale, (Ipp16s *)dst.data, (int)dst.step, roisize, 0);
|
||||||
|
if (needDelta && status >= 0)
|
||||||
|
status = ippiAddC_16s_C1IRSfs((Ipp16s)idelta, (Ipp16s *)dst.data, (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, (Ipp32f *)dst.data, (int)dst.step, roisize);
|
||||||
|
if (needDelta && status >= 0)
|
||||||
|
status = ippiAddC_32f_C1IR((Ipp32f)delta, (Ipp32f *)dst.data, (int)dst.step, roisize);
|
||||||
|
}
|
||||||
|
CV_SUPPRESS_DEPRECATED_END
|
||||||
|
|
||||||
|
if (status >= 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#undef IPP_FILTER_LAPLACIAN
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||||
if (scale == 1.0 && delta == 0)
|
if (scale == 1.0 && delta == 0)
|
||||||
{
|
{
|
||||||
|
@ -1413,14 +1413,14 @@ struct RowVec_32f
|
|||||||
{
|
{
|
||||||
kernel = _kernel;
|
kernel = _kernel;
|
||||||
haveSSE = checkHardwareSupport(CV_CPU_SSE);
|
haveSSE = checkHardwareSupport(CV_CPU_SSE);
|
||||||
#ifdef USE_IPP_SEP_FILTERS
|
#if defined USE_IPP_SEP_FILTERS && 0
|
||||||
bufsz = -1;
|
bufsz = -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int operator()(const uchar* _src, uchar* _dst, int width, int cn) const
|
int operator()(const uchar* _src, uchar* _dst, int width, int cn) const
|
||||||
{
|
{
|
||||||
#ifdef USE_IPP_SEP_FILTERS
|
#if defined USE_IPP_SEP_FILTERS && 0
|
||||||
int ret = ippiOperator(_src, _dst, width, cn);
|
int ret = ippiOperator(_src, _dst, width, cn);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -1458,13 +1458,13 @@ struct RowVec_32f
|
|||||||
|
|
||||||
Mat kernel;
|
Mat kernel;
|
||||||
bool haveSSE;
|
bool haveSSE;
|
||||||
#ifdef USE_IPP_SEP_FILTERS
|
#if defined USE_IPP_SEP_FILTERS && 0
|
||||||
private:
|
private:
|
||||||
mutable int bufsz;
|
mutable int bufsz;
|
||||||
int ippiOperator(const uchar* _src, uchar* _dst, int width, int cn) const
|
int ippiOperator(const uchar* _src, uchar* _dst, int width, int cn) const
|
||||||
{
|
{
|
||||||
int _ksize = kernel.rows + kernel.cols - 1;
|
int _ksize = kernel.rows + kernel.cols - 1;
|
||||||
// if ((1 != cn && 3 != cn) || width < _ksize*8)
|
if ((1 != cn && 3 != cn) || width < _ksize*8)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const float* src = (const float*)_src;
|
const float* src = (const float*)_src;
|
||||||
|
@ -1242,7 +1242,7 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels,
|
|||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
const Mat & src = images[0];
|
const Mat & src = images[0];
|
||||||
int nstripes = std::min<int>(8, src.total() / (1 << 16));
|
int nstripes = std::min<int>(8, static_cast<int>(src.total() / (1 << 16)));
|
||||||
#ifdef HAVE_CONCURRENCY
|
#ifdef HAVE_CONCURRENCY
|
||||||
nstripes = 1;
|
nstripes = 1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -474,6 +474,7 @@ cv::Moments cv::moments( InputArray _src, bool binary )
|
|||||||
// ippiMomentInitAlloc_64f, ippiMomentFree_64f are deprecated in 8.1, but there are not another way
|
// 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
|
// to initialize IppiMomentState_64f. When GetStateSize and Init functions will appear we have to
|
||||||
// change our code.
|
// change our code.
|
||||||
|
CV_SUPPRESS_DEPRECATED_START
|
||||||
if (0 <= ippiMomentInitAlloc_64f(&moment, ippAlgHintAccurate))
|
if (0 <= ippiMomentInitAlloc_64f(&moment, ippAlgHintAccurate))
|
||||||
{
|
{
|
||||||
IppStatus sts = (IppStatus)(-1);
|
IppStatus sts = (IppStatus)(-1);
|
||||||
@ -518,6 +519,7 @@ cv::Moments cv::moments( InputArray _src, bool binary )
|
|||||||
}
|
}
|
||||||
ippiMomentFree_64f(moment);
|
ippiMomentFree_64f(moment);
|
||||||
}
|
}
|
||||||
|
CV_SUPPRESS_DEPRECATED_END
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user