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:
Pavel Vlasov 2014-10-03 15:17:28 +04:00
parent 83ef276697
commit 45958eaabc
49 changed files with 4279 additions and 2799 deletions

View File

@ -222,6 +222,11 @@ OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors"
OCV_OPTION(ENABLE_WINRT_MODE "Build with Windows Runtime support" OFF IF WIN32 )
OCV_OPTION(ENABLE_WINRT_MODE_NATIVE "Build with Windows Runtime native C++ support" OFF IF WIN32 )
OCV_OPTION(ANDROID_EXAMPLES_WITH_LIBS "Build binaries of Android examples with native libraries" OFF IF ANDROID )
OCV_OPTION(ENABLE_IMPL_COLLECTION "Collect implementation data on function call" OFF )
if(ENABLE_IMPL_COLLECTION)
add_definitions(-DCV_COLLECT_IMPL_DATA)
endif()
# ----------------------------------------------------------------------------

View File

@ -925,6 +925,7 @@ public:
filterSpeckles(disparr.getMat(), FILTERED, params.speckleWindowSize, params.speckleRange, slidingSumBuf);
if (dtype == CV_32F)
disparr.getUMat().convertTo(disparr, CV_32FC1, 1./(1 << DISPARITY_SHIFT), 0);
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
}

View File

@ -1085,28 +1085,34 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi
int newVal = cvRound(_newval), maxDiff = cvRound(_maxDiff);
#if IPP_VERSION_X100 >= 801
Ipp32s bufsize = 0;
IppiSize roisize = { img.cols, img.rows };
IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s;
if (!__buf.needed() && (type == CV_8UC1 || type == CV_16SC1))
CV_IPP_CHECK()
{
IppStatus status = ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize);
Ipp8u * buffer = ippsMalloc_8u(bufsize);
Ipp32s bufsize = 0;
IppiSize roisize = { img.cols, img.rows };
IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s;
if ((int)status >= 0)
if (!__buf.needed() && (type == CV_8UC1 || type == CV_16SC1))
{
if (type == CV_8UC1)
status = ippiMarkSpeckles_8u_C1IR(img.ptr<Ipp8u>(), (int)img.step, roisize,
(Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer);
else
status = ippiMarkSpeckles_16s_C1IR(img.ptr<Ipp16s>(), (int)img.step, roisize,
(Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer);
}
IppStatus status = ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize);
Ipp8u * buffer = ippsMalloc_8u(bufsize);
if (status >= 0)
return;
setIppErrorStatus();
if ((int)status >= 0)
{
if (type == CV_8UC1)
status = ippiMarkSpeckles_8u_C1IR(img.ptr<Ipp8u>(), (int)img.step, roisize,
(Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer);
else
status = ippiMarkSpeckles_16s_C1IR(img.ptr<Ipp16s>(), (int)img.step, roisize,
(Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer);
}
if (status >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif

View File

@ -566,6 +566,8 @@ CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, con
int line = 0);
CV_EXPORTS int getIppStatus();
CV_EXPORTS String getIppErrorLocation();
CV_EXPORTS bool useIPP();
CV_EXPORTS void setUseIPP(bool flag);
} // ipp

View File

@ -5,6 +5,7 @@
// Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
#include "opencv2/core/utility.hpp"
//#define CV_OPENCL_RUN_ASSERT
#ifdef HAVE_OPENCL
@ -16,6 +17,7 @@
{ \
printf("%s: OpenCL implementation is running\n", CV_Func); \
fflush(stdout); \
CV_IMPL_ADD(CV_IMPL_OCL); \
return __VA_ARGS__; \
} \
else \
@ -29,14 +31,24 @@
{ \
if (cv::ocl::useOpenCL() && (condition)) \
{ \
CV_Assert(func); \
if(func) \
{ \
CV_IMPL_ADD(CV_IMPL_OCL); \
} \
else \
{ \
CV_Error(cv::Error::StsAssert, #func); \
} \
return __VA_ARGS__; \
} \
}
#else
#define CV_OCL_RUN_(condition, func, ...) \
if (cv::ocl::useOpenCL() && (condition) && func) \
return __VA_ARGS__;
{ \
CV_IMPL_ADD(CV_IMPL_OCL); \
return __VA_ARGS__; \
}
#endif
#else

View File

@ -254,6 +254,9 @@ static inline IppDataType ippiGetDataType(int depth)
# define IPP_VERSION_X100 0
#endif
#define CV_IPP_CHECK_COND (cv::ipp::useIPP())
#define CV_IPP_CHECK() if(CV_IPP_CHECK_COND)
#ifndef IPPI_CALL
# define IPPI_CALL(func) CV_Assert((func) >= 0)
#endif

View File

@ -53,6 +53,30 @@
namespace cv
{
#ifdef CV_COLLECT_IMPL_DATA
CV_EXPORTS void setImpl(int flags); // set implementation flags and reset storage arrays
CV_EXPORTS void addImpl(int flag, const char* func = 0); // add implementation and function name to storage arrays
// Get stored implementation flags and fucntions names arrays
// Each implementation entry correspond to function name entry, so you can find which implementation was executed in which fucntion
CV_EXPORTS int getImpl(std::vector<int> &impl, std::vector<String> &funName);
CV_EXPORTS bool useCollection(); // return implementation colelction state
CV_EXPORTS void setUseCollection(bool flag); // set implementation collection state
#define CV_IMPL_PLAIN 0x01 // native CPU OpenCV implementation
#define CV_IMPL_OCL 0x02 // OpenCL implementation
#define CV_IMPL_IPP 0x04 // IPP implementation
#define CV_IMPL_MT 0x10 // multithreaded implementation
#define CV_IMPL_ADD(impl) \
if(cv::useCollection()) \
{ \
cv::addImpl(impl, CV_Func); \
}
#else
#define CV_IMPL_ADD(impl)
#endif
/*!
Automatically Allocated Buffer Class

View File

@ -562,10 +562,16 @@ static void add8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<uchar, OpAdd<uchar>, IF_SIMD(VAdd<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -582,10 +588,16 @@ static void add16u( const ushort* src1, size_t step1,
ushort* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<ushort, OpAdd<ushort>, IF_SIMD(VAdd<ushort>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -595,10 +607,16 @@ static void add16s( const short* src1, size_t step1,
short* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<short, OpAdd<short>, IF_SIMD(VAdd<short>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -615,10 +633,16 @@ static void add32f( const float* src1, size_t step1,
float* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAdd_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp32<float, OpAdd<float>, IF_SIMD(VAdd<float>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -635,10 +659,16 @@ static void sub8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_8u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_8u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<uchar, OpSub<uchar>, IF_SIMD(VSub<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -655,10 +685,16 @@ static void sub16u( const ushort* src1, size_t step1,
ushort* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_16u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_16u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<ushort, OpSub<ushort>, IF_SIMD(VSub<ushort>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -668,10 +704,16 @@ static void sub16s( const short* src1, size_t step1,
short* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_16s_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_16s_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<short, OpSub<short>, IF_SIMD(VSub<short>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -688,10 +730,16 @@ static void sub32f( const float* src1, size_t step1,
float* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_32f_C1R(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz)))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiSub_32f_C1R(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz)))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp32<float, OpSub<float>, IF_SIMD(VSub<float>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -711,22 +759,28 @@ static void max8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
uchar* s1 = (uchar*)src1;
uchar* s2 = (uchar*)src2;
uchar* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
CV_IPP_CHECK()
{
if (0 > ippsMaxEvery_8u(s1, s2, d, sz.width))
break;
s1 += step1;
s2 += step2;
d += step;
uchar* s1 = (uchar*)src1;
uchar* s2 = (uchar*)src2;
uchar* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
{
if (0 > ippsMaxEvery_8u(s1, s2, d, sz.width))
break;
s1 += step1;
s2 += step2;
d += step;
}
if (i == sz.height)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp<uchar, OpMax<uchar>, IF_SIMD(VMax<uchar>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -743,22 +797,28 @@ static void max16u( const ushort* src1, size_t step1,
ushort* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
ushort* s1 = (ushort*)src1;
ushort* s2 = (ushort*)src2;
ushort* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
CV_IPP_CHECK()
{
if (0 > ippsMaxEvery_16u(s1, s2, d, sz.width))
break;
s1 = (ushort*)((uchar*)s1 + step1);
s2 = (ushort*)((uchar*)s2 + step2);
d = (ushort*)((uchar*)d + step);
ushort* s1 = (ushort*)src1;
ushort* s2 = (ushort*)src2;
ushort* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
{
if (0 > ippsMaxEvery_16u(s1, s2, d, sz.width))
break;
s1 = (ushort*)((uchar*)s1 + step1);
s2 = (ushort*)((uchar*)s2 + step2);
d = (ushort*)((uchar*)d + step);
}
if (i == sz.height)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp<ushort, OpMax<ushort>, IF_SIMD(VMax<ushort>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -782,22 +842,28 @@ static void max32f( const float* src1, size_t step1,
float* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
float* s1 = (float*)src1;
float* s2 = (float*)src2;
float* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
CV_IPP_CHECK()
{
if (0 > ippsMaxEvery_32f(s1, s2, d, sz.width))
break;
s1 = (float*)((uchar*)s1 + step1);
s2 = (float*)((uchar*)s2 + step2);
d = (float*)((uchar*)d + step);
float* s1 = (float*)src1;
float* s2 = (float*)src2;
float* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
{
if (0 > ippsMaxEvery_32f(s1, s2, d, sz.width))
break;
s1 = (float*)((uchar*)s1 + step1);
s2 = (float*)((uchar*)s2 + step2);
d = (float*)((uchar*)d + step);
}
if (i == sz.height)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp32<float, OpMax<float>, IF_SIMD(VMax<float>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -807,22 +873,28 @@ static void max64f( const double* src1, size_t step1,
double* dst, size_t step, Size sz, void* )
{
#if ARITHM_USE_IPP == 1
double* s1 = (double*)src1;
double* s2 = (double*)src2;
double* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
CV_IPP_CHECK()
{
if (0 > ippsMaxEvery_64f(s1, s2, d, sz.width))
break;
s1 = (double*)((uchar*)s1 + step1);
s2 = (double*)((uchar*)s2 + step2);
d = (double*)((uchar*)d + step);
double* s1 = (double*)src1;
double* s2 = (double*)src2;
double* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
{
if (0 > ippsMaxEvery_64f(s1, s2, d, sz.width))
break;
s1 = (double*)((uchar*)s1 + step1);
s2 = (double*)((uchar*)s2 + step2);
d = (double*)((uchar*)d + step);
}
if (i == sz.height)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp64<double, OpMax<double>, IF_SIMD(VMax<double>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -832,22 +904,28 @@ static void min8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
uchar* s1 = (uchar*)src1;
uchar* s2 = (uchar*)src2;
uchar* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
CV_IPP_CHECK()
{
if (0 > ippsMinEvery_8u(s1, s2, d, sz.width))
break;
s1 += step1;
s2 += step2;
d += step;
uchar* s1 = (uchar*)src1;
uchar* s2 = (uchar*)src2;
uchar* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
{
if (0 > ippsMinEvery_8u(s1, s2, d, sz.width))
break;
s1 += step1;
s2 += step2;
d += step;
}
if (i == sz.height)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp<uchar, OpMin<uchar>, IF_SIMD(VMin<uchar>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -864,22 +942,28 @@ static void min16u( const ushort* src1, size_t step1,
ushort* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
ushort* s1 = (ushort*)src1;
ushort* s2 = (ushort*)src2;
ushort* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
CV_IPP_CHECK()
{
if (0 > ippsMinEvery_16u(s1, s2, d, sz.width))
break;
s1 = (ushort*)((uchar*)s1 + step1);
s2 = (ushort*)((uchar*)s2 + step2);
d = (ushort*)((uchar*)d + step);
ushort* s1 = (ushort*)src1;
ushort* s2 = (ushort*)src2;
ushort* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
{
if (0 > ippsMinEvery_16u(s1, s2, d, sz.width))
break;
s1 = (ushort*)((uchar*)s1 + step1);
s2 = (ushort*)((uchar*)s2 + step2);
d = (ushort*)((uchar*)d + step);
}
if (i == sz.height)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp<ushort, OpMin<ushort>, IF_SIMD(VMin<ushort>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -903,22 +987,28 @@ static void min32f( const float* src1, size_t step1,
float* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
float* s1 = (float*)src1;
float* s2 = (float*)src2;
float* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
CV_IPP_CHECK()
{
if (0 > ippsMinEvery_32f(s1, s2, d, sz.width))
break;
s1 = (float*)((uchar*)s1 + step1);
s2 = (float*)((uchar*)s2 + step2);
d = (float*)((uchar*)d + step);
float* s1 = (float*)src1;
float* s2 = (float*)src2;
float* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
{
if (0 > ippsMinEvery_32f(s1, s2, d, sz.width))
break;
s1 = (float*)((uchar*)s1 + step1);
s2 = (float*)((uchar*)s2 + step2);
d = (float*)((uchar*)d + step);
}
if (i == sz.height)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp32<float, OpMin<float>, IF_SIMD(VMin<float>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -928,22 +1018,28 @@ static void min64f( const double* src1, size_t step1,
double* dst, size_t step, Size sz, void* )
{
#if ARITHM_USE_IPP == 1
double* s1 = (double*)src1;
double* s2 = (double*)src2;
double* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
CV_IPP_CHECK()
{
if (0 > ippsMinEvery_64f(s1, s2, d, sz.width))
break;
s1 = (double*)((uchar*)s1 + step1);
s2 = (double*)((uchar*)s2 + step2);
d = (double*)((uchar*)d + step);
double* s1 = (double*)src1;
double* s2 = (double*)src2;
double* d = dst;
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
int i = 0;
for(; i < sz.height; i++)
{
if (0 > ippsMinEvery_64f(s1, s2, d, sz.width))
break;
s1 = (double*)((uchar*)s1 + step1);
s2 = (double*)((uchar*)s2 + step2);
d = (double*)((uchar*)d + step);
}
if (i == sz.height)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp64<double, OpMin<double>, IF_SIMD(VMin<double>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -953,10 +1049,16 @@ static void absdiff8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAbsDiff_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAbsDiff_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<uchar, OpAbsDiff<uchar>, IF_SIMD(VAbsDiff<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -973,10 +1075,16 @@ static void absdiff16u( const ushort* src1, size_t step1,
ushort* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAbsDiff_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAbsDiff_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<ushort, OpAbsDiff<ushort>, IF_SIMD(VAbsDiff<ushort>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -1000,10 +1108,16 @@ static void absdiff32f( const float* src1, size_t step1,
float* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAbsDiff_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAbsDiff_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp32<float, OpAbsDiff<float>, IF_SIMD(VAbsDiff<float>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -1021,10 +1135,16 @@ static void and8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAnd_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiAnd_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<uchar, OpAnd<uchar>, IF_SIMD(VAnd<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -1034,10 +1154,16 @@ static void or8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiOr_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiOr_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<uchar, OpOr<uchar>, IF_SIMD(VOr<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -1047,10 +1173,16 @@ static void xor8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiXor_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiXor_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<uchar, OpXor<uchar>, IF_SIMD(VXor<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -1060,10 +1192,16 @@ static void not8u( const uchar* src1, size_t step1,
uchar* dst, size_t step, Size sz, void* )
{
#if (ARITHM_USE_IPP == 1)
fixSteps(sz, sizeof(dst[0]), step1, step2, step); (void)src2;
if (0 <= ippiNot_8u_C1R(src1, (int)step1, dst, (int)step, ippiSize(sz)))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
fixSteps(sz, sizeof(dst[0]), step1, step2, step); (void)src2;
if (0 <= ippiNot_8u_C1R(src1, (int)step1, dst, (int)step, ippiSize(sz)))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
(vBinOp<uchar, OpNot<uchar>, IF_SIMD(VNot<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -2376,11 +2514,17 @@ static void mul8u( const uchar* src1, size_t step1, const uchar* src2, size_t st
{
float fscale = (float)*(const double*)scale;
#if defined HAVE_IPP
if (std::fabs(fscale - 1) <= FLT_EPSILON)
CV_IPP_CHECK()
{
if (ippiMul_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0)
return;
setIppErrorStatus();
if (std::fabs(fscale - 1) <= FLT_EPSILON)
{
if (ippiMul_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
mul_(src1, step1, src2, step2, dst, step, sz, fscale);
@ -2397,11 +2541,17 @@ static void mul16u( const ushort* src1, size_t step1, const ushort* src2, size_t
{
float fscale = (float)*(const double*)scale;
#if defined HAVE_IPP
if (std::fabs(fscale - 1) <= FLT_EPSILON)
CV_IPP_CHECK()
{
if (ippiMul_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0)
return;
setIppErrorStatus();
if (std::fabs(fscale - 1) <= FLT_EPSILON)
{
if (ippiMul_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
mul_(src1, step1, src2, step2, dst, step, sz, fscale);
@ -2412,11 +2562,17 @@ static void mul16s( const short* src1, size_t step1, const short* src2, size_t s
{
float fscale = (float)*(const double*)scale;
#if defined HAVE_IPP
if (std::fabs(fscale - 1) <= FLT_EPSILON)
CV_IPP_CHECK()
{
if (ippiMul_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0)
return;
setIppErrorStatus();
if (std::fabs(fscale - 1) <= FLT_EPSILON)
{
if (ippiMul_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
mul_(src1, step1, src2, step2, dst, step, sz, fscale);
@ -2433,11 +2589,17 @@ static void mul32f( const float* src1, size_t step1, const float* src2, size_t s
{
float fscale = (float)*(const double*)scale;
#if defined HAVE_IPP
if (std::fabs(fscale - 1) <= FLT_EPSILON)
CV_IPP_CHECK()
{
if (ippiMul_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)) >= 0)
return;
setIppErrorStatus();
if (std::fabs(fscale - 1) <= FLT_EPSILON)
{
if (ippiMul_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz)) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
mul_(src1, step1, src2, step2, dst, step, sz, fscale);
@ -3185,13 +3347,19 @@ static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t ste
uchar* dst, size_t step, Size size, void* _cmpop)
{
#if ARITHM_USE_IPP
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op >= 0 )
CV_IPP_CHECK()
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
return;
setIppErrorStatus();
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op >= 0 )
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
//vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -3284,13 +3452,19 @@ static void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t
uchar* dst, size_t step, Size size, void* _cmpop)
{
#if ARITHM_USE_IPP
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op >= 0 )
CV_IPP_CHECK()
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
return;
setIppErrorStatus();
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op >= 0 )
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -3300,13 +3474,19 @@ static void cmp16s(const short* src1, size_t step1, const short* src2, size_t st
uchar* dst, size_t step, Size size, void* _cmpop)
{
#if ARITHM_USE_IPP
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op > 0 )
CV_IPP_CHECK()
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_16s_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
return;
setIppErrorStatus();
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op > 0 )
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_16s_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
//vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -3438,13 +3618,19 @@ static void cmp32f(const float* src1, size_t step1, const float* src2, size_t st
uchar* dst, size_t step, Size size, void* _cmpop)
{
#if ARITHM_USE_IPP
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op >= 0 )
CV_IPP_CHECK()
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
return;
setIppErrorStatus();
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op >= 0 )
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if (0 <= ippiCompare_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);

View File

@ -2989,11 +2989,17 @@ dtype* dst, size_t dstep, Size size, double* scale) \
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
dtype* dst, size_t dstep, Size size, double*) \
{ \
if (src && dst)\
CV_IPP_CHECK()\
{\
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0) \
return; \
setIppErrorStatus(); \
if (src && dst)\
{\
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0) \
{\
CV_IMPL_ADD(CV_IMPL_IPP)\
return; \
}\
setIppErrorStatus(); \
}\
}\
cvt_(src, sstep, dst, dstep, size); \
}
@ -3002,11 +3008,17 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
dtype* dst, size_t dstep, Size size, double*) \
{ \
if (src && dst)\
CV_IPP_CHECK()\
{\
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0) \
return; \
setIppErrorStatus(); \
if (src && dst)\
{\
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0) \
{\
CV_IMPL_ADD(CV_IMPL_IPP)\
return; \
}\
setIppErrorStatus(); \
}\
}\
cvt_(src, sstep, dst, dstep, size); \
}
@ -3524,6 +3536,7 @@ public:
setIppErrorStatus();
*ok = false;
}
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
}
private:
IppLUTParallelBody_LUTC1(const IppLUTParallelBody_LUTC1&);
@ -3567,6 +3580,7 @@ public:
setIppErrorStatus();
return;
}
CV_IMPL_ADD(CV_IMPL_IPP);
}
else if (lutcn == 4)
{
@ -3576,6 +3590,7 @@ public:
setIppErrorStatus();
return;
}
CV_IMPL_ADD(CV_IMPL_IPP);
}
*ok = true;
@ -3605,14 +3620,20 @@ public:
if (ippiLUTPalette_8u_C3R(
src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0],
ippiSize(dst.size()), lutTable, 8) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
return;
}
}
else if (lutcn == 4)
{
if (ippiLUTPalette_8u_C4R(
src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0],
ippiSize(dst.size()), lutTable, 8) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
return;
}
}
setIppErrorStatus();
*ok = false;
@ -3690,19 +3711,22 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
bool ok = false;
Ptr<ParallelLoopBody> body;
#if defined(HAVE_IPP)
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
CV_IPP_CHECK()
{
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
#if 0 // there are no performance benefits (PR #2653)
if (lutcn == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
body.reset(p);
}
else
if (lutcn == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
body.reset(p);
}
else
#endif
if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
body.reset(p);
if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
{
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
body.reset(p);
}
}
#endif
if (body == NULL || ok == false)

View File

@ -82,9 +82,15 @@ template<> void
copyMask_<uchar>(const uchar* _src, size_t sstep, const uchar* mask, size_t mstep, uchar* _dst, size_t dstep, Size size)
{
#if defined HAVE_IPP
if (ippiCopy_8u_C1MR(_src, (int)sstep, _dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0)
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (ippiCopy_8u_C1MR(_src, (int)sstep, _dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
for( ; size.height--; mask += mstep, _src += sstep, _dst += dstep )
@ -126,9 +132,15 @@ template<> void
copyMask_<ushort>(const uchar* _src, size_t sstep, const uchar* mask, size_t mstep, uchar* _dst, size_t dstep, Size size)
{
#if defined HAVE_IPP
if (ippiCopy_16u_C1MR((const Ipp16u *)_src, (int)sstep, (Ipp16u *)_dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0)
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (ippiCopy_16u_C1MR((const Ipp16u *)_src, (int)sstep, (Ipp16u *)_dst, (int)dstep, ippiSize(size), mask, (int)mstep) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
for( ; size.height--; mask += mstep, _src += sstep, _dst += dstep )
@ -201,9 +213,15 @@ static void copyMask##suffix(const uchar* src, size_t sstep, const uchar* mask,
static void copyMask##suffix(const uchar* src, size_t sstep, const uchar* mask, size_t mstep, \
uchar* dst, size_t dstep, Size size, void*) \
{ \
if (ippiCopy_##ippfavor((const ipptype *)src, (int)sstep, (ipptype *)dst, (int)dstep, ippiSize(size), (const Ipp8u *)mask, (int)mstep) >= 0) \
return; \
setIppErrorStatus(); \
CV_IPP_CHECK()\
{\
if (ippiCopy_##ippfavor((const ipptype *)src, (int)sstep, (ipptype *)dst, (int)dstep, ippiSize(size), (const Ipp8u *)mask, (int)mstep) >= 0) \
{\
CV_IMPL_ADD(CV_IMPL_IPP);\
return;\
}\
setIppErrorStatus(); \
}\
copyMask_<type>(src, sstep, mask, mstep, dst, dstep, size); \
}
#else
@ -301,9 +319,15 @@ void Mat::copyTo( OutputArray _dst ) const
size_t len = sz.width*elemSize();
#if defined HAVE_IPP
if (ippiCopy_8u_C1R(sptr, (int)step, dptr, (int)dst.step, ippiSize((int)len, sz.height)) >= 0)
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (ippiCopy_8u_C1R(sptr, (int)step, dptr, (int)dst.step, ippiSize((int)len, sz.height)) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP)
return;
}
setIppErrorStatus();
}
#endif
for( ; sz.height--; sptr += step, dptr += dst.step )
@ -380,23 +404,32 @@ Mat& Mat::operator = (const Scalar& s)
if( is[0] == 0 && is[1] == 0 && is[2] == 0 && is[3] == 0 )
{
#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY && 0
if (dims <= 2 || isContinuous())
CV_IPP_CHECK()
{
IppiSize roisize = { cols, rows };
if (isContinuous())
if (dims <= 2 || isContinuous())
{
roisize.width = (int)total();
roisize.height = 1;
IppiSize roisize = { cols, rows };
if (isContinuous())
{
roisize.width = (int)total();
roisize.height = 1;
if (ippsZero_8u(data, static_cast<int>(roisize.width * elemSize())) >= 0)
if (ippsZero_8u(data, static_cast<int>(roisize.width * elemSize())) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP)
return *this;
}
setIppErrorStatus();
}
roisize.width *= (int)elemSize();
if (ippiSet_8u_C1R(0, data, (int)step, roisize) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP)
return *this;
}
setIppErrorStatus();
}
roisize.width *= (int)elemSize();
if (ippiSet_8u_C1R(0, data, (int)step, roisize) >= 0)
return *this;
setIppErrorStatus();
}
#endif
@ -439,77 +472,83 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
CV_Assert( mask.empty() || (mask.type() == CV_8U && size == mask.size) );
#if defined HAVE_IPP
int cn = channels(), depth0 = depth();
if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous())) &&
(/*depth0 == CV_8U ||*/ depth0 == CV_16U || depth0 == CV_16S || depth0 == CV_32S || depth0 == CV_32F) &&
(cn == 1 || cn == 3 || cn == 4))
CV_IPP_CHECK()
{
uchar _buf[32];
void * buf = _buf;
convertAndUnrollScalar( value, type(), _buf, 1 );
int cn = channels(), depth0 = depth();
IppStatus status = (IppStatus)-1;
IppiSize roisize = { cols, rows };
int mstep = (int)mask.step[0], dstep = (int)step[0];
if (!mask.empty() && (dims <= 2 || (isContinuous() && mask.isContinuous())) &&
(/*depth0 == CV_8U ||*/ depth0 == CV_16U || depth0 == CV_16S || depth0 == CV_32S || depth0 == CV_32F) &&
(cn == 1 || cn == 3 || cn == 4))
{
uchar _buf[32];
void * buf = _buf;
convertAndUnrollScalar( value, type(), _buf, 1 );
if (isContinuous() && mask.isContinuous())
{
roisize.width = (int)total();
roisize.height = 1;
}
IppStatus status = (IppStatus)-1;
IppiSize roisize = { cols, rows };
int mstep = (int)mask.step[0], dstep = (int)step[0];
if (cn == 1)
{
/*if (depth0 == CV_8U)
status = ippiSet_8u_C1MR(*(Ipp8u *)buf, (Ipp8u *)data, dstep, roisize, mask.data, mstep);
else*/ if (depth0 == CV_16U)
status = ippiSet_16u_C1MR(*(Ipp16u *)buf, (Ipp16u *)data, dstep, roisize, mask.data, mstep);
else if (depth0 == CV_16S)
status = ippiSet_16s_C1MR(*(Ipp16s *)buf, (Ipp16s *)data, dstep, roisize, mask.data, mstep);
else if (depth0 == CV_32S)
status = ippiSet_32s_C1MR(*(Ipp32s *)buf, (Ipp32s *)data, dstep, roisize, mask.data, mstep);
else if (depth0 == CV_32F)
status = ippiSet_32f_C1MR(*(Ipp32f *)buf, (Ipp32f *)data, dstep, roisize, mask.data, mstep);
}
else if (cn == 3 || cn == 4)
{
if (isContinuous() && mask.isContinuous())
{
roisize.width = (int)total();
roisize.height = 1;
}
if (cn == 1)
{
/*if (depth0 == CV_8U)
status = ippiSet_8u_C1MR(*(Ipp8u *)buf, (Ipp8u *)data, dstep, roisize, mask.data, mstep);
else*/ if (depth0 == CV_16U)
status = ippiSet_16u_C1MR(*(Ipp16u *)buf, (Ipp16u *)data, dstep, roisize, mask.data, mstep);
else if (depth0 == CV_16S)
status = ippiSet_16s_C1MR(*(Ipp16s *)buf, (Ipp16s *)data, dstep, roisize, mask.data, mstep);
else if (depth0 == CV_32S)
status = ippiSet_32s_C1MR(*(Ipp32s *)buf, (Ipp32s *)data, dstep, roisize, mask.data, mstep);
else if (depth0 == CV_32F)
status = ippiSet_32f_C1MR(*(Ipp32f *)buf, (Ipp32f *)data, dstep, roisize, mask.data, mstep);
}
else if (cn == 3 || cn == 4)
{
#define IPP_SET(ippfavor, ippcn) \
do \
{ \
typedef Ipp##ippfavor ipptype; \
ipptype ippvalue[4] = { ((ipptype *)buf)[0], ((ipptype *)buf)[1], ((ipptype *)buf)[2], ((ipptype *)buf)[3] }; \
status = ippiSet_##ippfavor##_C##ippcn##MR(ippvalue, (ipptype *)data, dstep, roisize, mask.data, mstep); \
} while ((void)0, 0)
do \
{ \
typedef Ipp##ippfavor ipptype; \
ipptype ippvalue[4] = { ((ipptype *)buf)[0], ((ipptype *)buf)[1], ((ipptype *)buf)[2], ((ipptype *)buf)[3] }; \
status = ippiSet_##ippfavor##_C##ippcn##MR(ippvalue, (ipptype *)data, dstep, roisize, mask.data, mstep); \
} while ((void)0, 0)
#define IPP_SET_CN(ippcn) \
do \
{ \
if (cn == ippcn) \
do \
{ \
/*if (depth0 == CV_8U) \
IPP_SET(8u, ippcn); \
else*/ if (depth0 == CV_16U) \
IPP_SET(16u, ippcn); \
else if (depth0 == CV_16S) \
IPP_SET(16s, ippcn); \
else if (depth0 == CV_32S) \
IPP_SET(32s, ippcn); \
else if (depth0 == CV_32F) \
IPP_SET(32f, ippcn); \
} \
} while ((void)0, 0)
if (cn == ippcn) \
{ \
/*if (depth0 == CV_8U) \
IPP_SET(8u, ippcn); \
else*/ if (depth0 == CV_16U) \
IPP_SET(16u, ippcn); \
else if (depth0 == CV_16S) \
IPP_SET(16s, ippcn); \
else if (depth0 == CV_32S) \
IPP_SET(32s, ippcn); \
else if (depth0 == CV_32F) \
IPP_SET(32f, ippcn); \
} \
} while ((void)0, 0)
IPP_SET_CN(3);
IPP_SET_CN(4);
IPP_SET_CN(3);
IPP_SET_CN(4);
#undef IPP_SET_CN
#undef IPP_SET
}
}
if (status >= 0)
return *this;
setIppErrorStatus();
if (status >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return *this;
}
setIppErrorStatus();
}
}
#endif
@ -714,66 +753,75 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode )
size_t esz = CV_ELEM_SIZE(type);
#if defined HAVE_IPP
typedef IppStatus (CV_STDCALL * ippiMirror)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize, IppiAxis flip);
typedef IppStatus (CV_STDCALL * ippiMirrorI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize, IppiAxis flip);
ippiMirror ippFunc = 0;
ippiMirrorI ippFuncI = 0;
CV_IPP_CHECK()
{
typedef IppStatus (CV_STDCALL * ippiMirror)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize, IppiAxis flip);
typedef IppStatus (CV_STDCALL * ippiMirrorI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize, IppiAxis flip);
ippiMirror ippFunc = 0;
ippiMirrorI ippFuncI = 0;
if (src.data == dst.data)
{
CV_SUPPRESS_DEPRECATED_START
ippFuncI =
type == CV_8UC1 ? (ippiMirrorI)ippiMirror_8u_C1IR :
type == CV_8UC3 ? (ippiMirrorI)ippiMirror_8u_C3IR :
type == CV_8UC4 ? (ippiMirrorI)ippiMirror_8u_C4IR :
type == CV_16UC1 ? (ippiMirrorI)ippiMirror_16u_C1IR :
type == CV_16UC3 ? (ippiMirrorI)ippiMirror_16u_C3IR :
type == CV_16UC4 ? (ippiMirrorI)ippiMirror_16u_C4IR :
type == CV_16SC1 ? (ippiMirrorI)ippiMirror_16s_C1IR :
type == CV_16SC3 ? (ippiMirrorI)ippiMirror_16s_C3IR :
type == CV_16SC4 ? (ippiMirrorI)ippiMirror_16s_C4IR :
type == CV_32SC1 ? (ippiMirrorI)ippiMirror_32s_C1IR :
type == CV_32SC3 ? (ippiMirrorI)ippiMirror_32s_C3IR :
type == CV_32SC4 ? (ippiMirrorI)ippiMirror_32s_C4IR :
type == CV_32FC1 ? (ippiMirrorI)ippiMirror_32f_C1IR :
type == CV_32FC3 ? (ippiMirrorI)ippiMirror_32f_C3IR :
type == CV_32FC4 ? (ippiMirrorI)ippiMirror_32f_C4IR : 0;
CV_SUPPRESS_DEPRECATED_END
}
else
{
ippFunc =
type == CV_8UC1 ? (ippiMirror)ippiMirror_8u_C1R :
type == CV_8UC3 ? (ippiMirror)ippiMirror_8u_C3R :
type == CV_8UC4 ? (ippiMirror)ippiMirror_8u_C4R :
type == CV_16UC1 ? (ippiMirror)ippiMirror_16u_C1R :
type == CV_16UC3 ? (ippiMirror)ippiMirror_16u_C3R :
type == CV_16UC4 ? (ippiMirror)ippiMirror_16u_C4R :
type == CV_16SC1 ? (ippiMirror)ippiMirror_16s_C1R :
type == CV_16SC3 ? (ippiMirror)ippiMirror_16s_C3R :
type == CV_16SC4 ? (ippiMirror)ippiMirror_16s_C4R :
type == CV_32SC1 ? (ippiMirror)ippiMirror_32s_C1R :
type == CV_32SC3 ? (ippiMirror)ippiMirror_32s_C3R :
type == CV_32SC4 ? (ippiMirror)ippiMirror_32s_C4R :
type == CV_32FC1 ? (ippiMirror)ippiMirror_32f_C1R :
type == CV_32FC3 ? (ippiMirror)ippiMirror_32f_C3R :
type == CV_32FC4 ? (ippiMirror)ippiMirror_32f_C4R : 0;
}
IppiAxis axis = flip_mode == 0 ? ippAxsHorizontal :
flip_mode > 0 ? ippAxsVertical : ippAxsBoth;
IppiSize roisize = { dst.cols, dst.rows };
if (src.data == dst.data)
{
CV_SUPPRESS_DEPRECATED_START
ippFuncI =
type == CV_8UC1 ? (ippiMirrorI)ippiMirror_8u_C1IR :
type == CV_8UC3 ? (ippiMirrorI)ippiMirror_8u_C3IR :
type == CV_8UC4 ? (ippiMirrorI)ippiMirror_8u_C4IR :
type == CV_16UC1 ? (ippiMirrorI)ippiMirror_16u_C1IR :
type == CV_16UC3 ? (ippiMirrorI)ippiMirror_16u_C3IR :
type == CV_16UC4 ? (ippiMirrorI)ippiMirror_16u_C4IR :
type == CV_16SC1 ? (ippiMirrorI)ippiMirror_16s_C1IR :
type == CV_16SC3 ? (ippiMirrorI)ippiMirror_16s_C3IR :
type == CV_16SC4 ? (ippiMirrorI)ippiMirror_16s_C4IR :
type == CV_32SC1 ? (ippiMirrorI)ippiMirror_32s_C1IR :
type == CV_32SC3 ? (ippiMirrorI)ippiMirror_32s_C3IR :
type == CV_32SC4 ? (ippiMirrorI)ippiMirror_32s_C4IR :
type == CV_32FC1 ? (ippiMirrorI)ippiMirror_32f_C1IR :
type == CV_32FC3 ? (ippiMirrorI)ippiMirror_32f_C3IR :
type == CV_32FC4 ? (ippiMirrorI)ippiMirror_32f_C4IR : 0;
CV_SUPPRESS_DEPRECATED_END
}
else
{
ippFunc =
type == CV_8UC1 ? (ippiMirror)ippiMirror_8u_C1R :
type == CV_8UC3 ? (ippiMirror)ippiMirror_8u_C3R :
type == CV_8UC4 ? (ippiMirror)ippiMirror_8u_C4R :
type == CV_16UC1 ? (ippiMirror)ippiMirror_16u_C1R :
type == CV_16UC3 ? (ippiMirror)ippiMirror_16u_C3R :
type == CV_16UC4 ? (ippiMirror)ippiMirror_16u_C4R :
type == CV_16SC1 ? (ippiMirror)ippiMirror_16s_C1R :
type == CV_16SC3 ? (ippiMirror)ippiMirror_16s_C3R :
type == CV_16SC4 ? (ippiMirror)ippiMirror_16s_C4R :
type == CV_32SC1 ? (ippiMirror)ippiMirror_32s_C1R :
type == CV_32SC3 ? (ippiMirror)ippiMirror_32s_C3R :
type == CV_32SC4 ? (ippiMirror)ippiMirror_32s_C4R :
type == CV_32FC1 ? (ippiMirror)ippiMirror_32f_C1R :
type == CV_32FC3 ? (ippiMirror)ippiMirror_32f_C3R :
type == CV_32FC4 ? (ippiMirror)ippiMirror_32f_C4R : 0;
}
IppiAxis axis = flip_mode == 0 ? ippAxsHorizontal :
flip_mode > 0 ? ippAxsVertical : ippAxsBoth;
IppiSize roisize = { dst.cols, dst.rows };
if (ippFunc != 0)
{
if (ippFunc(src.ptr(), (int)src.step, dst.ptr(), (int)dst.step, ippiSize(src.cols, src.rows), axis) >= 0)
return;
setIppErrorStatus();
}
else if (ippFuncI != 0)
{
if (ippFuncI(dst.ptr(), (int)dst.step, roisize, axis) >= 0)
return;
setIppErrorStatus();
if (ippFunc != 0)
{
if (ippFunc(src.ptr(), (int)src.step, dst.ptr(), (int)dst.step, ippiSize(src.cols, src.rows), axis) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
else if (ippFuncI != 0)
{
if (ippFuncI(dst.ptr(), (int)dst.step, roisize, axis) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
@ -1135,111 +1183,117 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
borderType &= ~BORDER_ISOLATED;
#if defined HAVE_IPP && 0
typedef IppStatus (CV_STDCALL * ippiCopyMakeBorder)(const void * pSrc, int srcStep, IppiSize srcRoiSize, void * pDst,
int dstStep, IppiSize dstRoiSize, int topBorderHeight, int leftBorderWidth);
typedef IppStatus (CV_STDCALL * ippiCopyMakeBorderI)(const void * pSrc, int srcDstStep, IppiSize srcRoiSize, IppiSize dstRoiSize,
int topBorderHeight, int leftborderwidth);
typedef IppStatus (CV_STDCALL * ippiCopyConstBorder)(const void * pSrc, int srcStep, IppiSize srcRoiSize, void * pDst, int dstStep,
IppiSize dstRoiSize, int topBorderHeight, int leftBorderWidth, void * value);
IppiSize srcRoiSize = { src.cols, src.rows }, dstRoiSize = { dst.cols, dst.rows };
ippiCopyMakeBorder ippFunc = 0;
ippiCopyMakeBorderI ippFuncI = 0;
ippiCopyConstBorder ippFuncConst = 0;
bool inplace = dst.datastart == src.datastart;
if (borderType == BORDER_CONSTANT)
CV_IPP_CHECK()
{
ippFuncConst =
// type == CV_8UC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C1R : bug in IPP 8.1
type == CV_16UC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C1R :
// type == CV_16SC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C1R : bug in IPP 8.1
// type == CV_32SC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C1R : bug in IPP 8.1
// type == CV_32FC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C1R : bug in IPP 8.1
type == CV_8UC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C3R :
type == CV_16UC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C3R :
type == CV_16SC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C3R :
type == CV_32SC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C3R :
type == CV_32FC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C3R :
type == CV_8UC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C4R :
type == CV_16UC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C4R :
type == CV_16SC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C4R :
type == CV_32SC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C4R :
type == CV_32FC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C4R : 0;
}
else if (borderType == BORDER_WRAP)
{
if (inplace)
{
CV_SUPPRESS_DEPRECATED_START
ippFuncI =
type == CV_32SC1 ? (ippiCopyMakeBorderI)ippiCopyWrapBorder_32s_C1IR :
type == CV_32FC1 ? (ippiCopyMakeBorderI)ippiCopyWrapBorder_32s_C1IR : 0;
CV_SUPPRESS_DEPRECATED_END
}
else
{
ippFunc =
type == CV_32SC1 ? (ippiCopyMakeBorder)ippiCopyWrapBorder_32s_C1R :
type == CV_32FC1 ? (ippiCopyMakeBorder)ippiCopyWrapBorder_32s_C1R : 0;
}
}
else if (borderType == BORDER_REPLICATE)
{
if (inplace)
{
CV_SUPPRESS_DEPRECATED_START
ippFuncI =
type == CV_8UC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C1IR :
type == CV_16UC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C1IR :
type == CV_16SC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C1IR :
type == CV_32SC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C1IR :
type == CV_32FC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C1IR :
type == CV_8UC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C3IR :
type == CV_16UC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C3IR :
type == CV_16SC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C3IR :
type == CV_32SC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C3IR :
type == CV_32FC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C3IR :
type == CV_8UC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C4IR :
type == CV_16UC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C4IR :
type == CV_16SC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C4IR :
type == CV_32SC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C4IR :
type == CV_32FC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C4IR : 0;
CV_SUPPRESS_DEPRECATED_END
}
else
{
ippFunc =
type == CV_8UC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C1R :
type == CV_16UC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C1R :
type == CV_16SC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C1R :
type == CV_32SC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C1R :
type == CV_32FC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C1R :
type == CV_8UC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C3R :
type == CV_16UC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C3R :
type == CV_16SC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C3R :
type == CV_32SC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C3R :
type == CV_32FC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C3R :
type == CV_8UC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C4R :
type == CV_16UC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C4R :
type == CV_16SC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C4R :
type == CV_32SC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C4R :
type == CV_32FC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C4R : 0;
}
}
typedef IppStatus (CV_STDCALL * ippiCopyMakeBorder)(const void * pSrc, int srcStep, IppiSize srcRoiSize, void * pDst,
int dstStep, IppiSize dstRoiSize, int topBorderHeight, int leftBorderWidth);
typedef IppStatus (CV_STDCALL * ippiCopyMakeBorderI)(const void * pSrc, int srcDstStep, IppiSize srcRoiSize, IppiSize dstRoiSize,
int topBorderHeight, int leftborderwidth);
typedef IppStatus (CV_STDCALL * ippiCopyConstBorder)(const void * pSrc, int srcStep, IppiSize srcRoiSize, void * pDst, int dstStep,
IppiSize dstRoiSize, int topBorderHeight, int leftBorderWidth, void * value);
if (ippFunc || ippFuncI || ippFuncConst)
{
uchar scbuf[32];
scalarToRawData(value, scbuf, type);
IppiSize srcRoiSize = { src.cols, src.rows }, dstRoiSize = { dst.cols, dst.rows };
ippiCopyMakeBorder ippFunc = 0;
ippiCopyMakeBorderI ippFuncI = 0;
ippiCopyConstBorder ippFuncConst = 0;
bool inplace = dst.datastart == src.datastart;
if ( (ippFunc && ippFunc(src.data, (int)src.step, srcRoiSize, dst.data, (int)dst.step, dstRoiSize, top, left) >= 0) ||
(ippFuncI && ippFuncI(src.data, (int)src.step, srcRoiSize, dstRoiSize, top, left) >= 0) ||
(ippFuncConst && ippFuncConst(src.data, (int)src.step, srcRoiSize, dst.data, (int)dst.step,
dstRoiSize, top, left, scbuf) >= 0))
return;
if (borderType == BORDER_CONSTANT)
{
ippFuncConst =
// type == CV_8UC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C1R : bug in IPP 8.1
type == CV_16UC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C1R :
// type == CV_16SC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C1R : bug in IPP 8.1
// type == CV_32SC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C1R : bug in IPP 8.1
// type == CV_32FC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C1R : bug in IPP 8.1
type == CV_8UC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C3R :
type == CV_16UC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C3R :
type == CV_16SC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C3R :
type == CV_32SC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C3R :
type == CV_32FC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C3R :
type == CV_8UC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C4R :
type == CV_16UC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C4R :
type == CV_16SC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C4R :
type == CV_32SC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C4R :
type == CV_32FC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C4R : 0;
}
else if (borderType == BORDER_WRAP)
{
if (inplace)
{
CV_SUPPRESS_DEPRECATED_START
ippFuncI =
type == CV_32SC1 ? (ippiCopyMakeBorderI)ippiCopyWrapBorder_32s_C1IR :
type == CV_32FC1 ? (ippiCopyMakeBorderI)ippiCopyWrapBorder_32s_C1IR : 0;
CV_SUPPRESS_DEPRECATED_END
}
else
{
ippFunc =
type == CV_32SC1 ? (ippiCopyMakeBorder)ippiCopyWrapBorder_32s_C1R :
type == CV_32FC1 ? (ippiCopyMakeBorder)ippiCopyWrapBorder_32s_C1R : 0;
}
}
else if (borderType == BORDER_REPLICATE)
{
if (inplace)
{
CV_SUPPRESS_DEPRECATED_START
ippFuncI =
type == CV_8UC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C1IR :
type == CV_16UC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C1IR :
type == CV_16SC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C1IR :
type == CV_32SC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C1IR :
type == CV_32FC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C1IR :
type == CV_8UC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C3IR :
type == CV_16UC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C3IR :
type == CV_16SC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C3IR :
type == CV_32SC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C3IR :
type == CV_32FC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C3IR :
type == CV_8UC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C4IR :
type == CV_16UC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C4IR :
type == CV_16SC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C4IR :
type == CV_32SC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C4IR :
type == CV_32FC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C4IR : 0;
CV_SUPPRESS_DEPRECATED_END
}
else
{
ippFunc =
type == CV_8UC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C1R :
type == CV_16UC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C1R :
type == CV_16SC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C1R :
type == CV_32SC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C1R :
type == CV_32FC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C1R :
type == CV_8UC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C3R :
type == CV_16UC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C3R :
type == CV_16SC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C3R :
type == CV_32SC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C3R :
type == CV_32FC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C3R :
type == CV_8UC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C4R :
type == CV_16UC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C4R :
type == CV_16SC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C4R :
type == CV_32SC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C4R :
type == CV_32FC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C4R : 0;
}
}
setIppErrorStatus();
if (ippFunc || ippFuncI || ippFuncConst)
{
uchar scbuf[32];
scalarToRawData(value, scbuf, type);
if ( (ippFunc && ippFunc(src.data, (int)src.step, srcRoiSize, dst.data, (int)dst.step, dstRoiSize, top, left) >= 0) ||
(ippFuncI && ippFuncI(src.data, (int)src.step, srcRoiSize, dstRoiSize, top, left) >= 0) ||
(ippFuncConst && ippFuncConst(src.data, (int)src.step, srcRoiSize, dst.data, (int)dst.step,
dstRoiSize, top, left, scbuf) >= 0))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif

View File

@ -554,12 +554,18 @@ DFT( const Complex<T>* src, Complex<T>* dst, int n,
if( !inv )
{
if (ippsDFTFwd_CToC( src, dst, spec, (uchar*)buf ) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
}
else
{
if (ippsDFTInv_CToC( src, dst, spec, (uchar*)buf ) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
}
setIppErrorStatus();
}
@ -997,6 +1003,7 @@ RealDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab,
if( (n & 1) == 0 )
dst[n] = 0;
}
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
@ -1124,7 +1131,12 @@ CCSIDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab,
if( spec )
{
if (ippsDFTInv_PackToR( src, dst, spec, (uchar*)buf ) >=0)
goto finalize;
{
if( complex_input )
((T*)src)[0] = (T)save_s1;
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
@ -1249,10 +1261,6 @@ CCSIDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab,
dst[j+1] = t1;
}
}
#ifdef USE_IPP_DFT
finalize:
#endif
if( complex_input )
((T*)src)[0] = (T)save_s1;
}
@ -1556,6 +1564,7 @@ public:
ippFree( pBuffer );
ippFree( pDFTSpec );
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
}
private:
@ -1629,6 +1638,7 @@ public:
ippFree( pBuffer );
ippFree( pDFTSpec );
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
}
private:
@ -1727,8 +1737,13 @@ static bool ippi_DFT_C_32F(const Mat& src, Mat& dst, bool inv, int norm_flag)
ippFree( pDFTSpec );
return status >= 0;
if(status >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return true;
}
return false;
}
static bool ippi_DFT_R_32F(const Mat& src, Mat& dst, bool inv, int norm_flag)
{
@ -1776,7 +1791,12 @@ static bool ippi_DFT_R_32F(const Mat& src, Mat& dst, bool inv, int norm_flag)
ippFree( pDFTSpec );
return status >= 0;
if(status >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return true;
}
return false;
}
#endif
@ -2455,39 +2475,53 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows )
Mat dst = _dst.getMat();
#if defined USE_IPP_DFT
if ((src.depth() == CV_32F) && (src.total()>(int)(1<<6)) && nonzero_rows == 0)
CV_IPP_CHECK()
{
if ((flags & DFT_ROWS) == 0)
if ((src.depth() == CV_32F) && (src.total()>(int)(1<<6)) && nonzero_rows == 0)
{
if (src.channels() == 2 && !(inv && (flags & DFT_REAL_OUTPUT)))
if ((flags & DFT_ROWS) == 0)
{
if (ippi_DFT_C_32F(src, dst, inv, ipp_norm_flag))
return;
setIppErrorStatus();
if (src.channels() == 2 && !(inv && (flags & DFT_REAL_OUTPUT)))
{
if (ippi_DFT_C_32F(src, dst, inv, ipp_norm_flag))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
if (src.channels() == 1 && (inv || !(flags & DFT_COMPLEX_OUTPUT)))
{
if (ippi_DFT_R_32F(src, dst, inv, ipp_norm_flag))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
if (src.channels() == 1 && (inv || !(flags & DFT_COMPLEX_OUTPUT)))
else
{
if (ippi_DFT_R_32F(src, dst, inv, ipp_norm_flag))
return;
setIppErrorStatus();
}
}
else
{
if (src.channels() == 2 && !(inv && (flags & DFT_REAL_OUTPUT)))
{
ippiDFT_C_Func ippiFunc = inv ? (ippiDFT_C_Func)ippiDFTInv_CToC_32fc_C1R : (ippiDFT_C_Func)ippiDFTFwd_CToC_32fc_C1R;
if (Dft_C_IPPLoop(src, dst, IPPDFT_C_Functor(ippiFunc),ipp_norm_flag))
return;
setIppErrorStatus();
}
if (src.channels() == 1 && (inv || !(flags & DFT_COMPLEX_OUTPUT)))
{
ippiDFT_R_Func ippiFunc = inv ? (ippiDFT_R_Func)ippiDFTInv_PackToR_32f_C1R : (ippiDFT_R_Func)ippiDFTFwd_RToPack_32f_C1R;
if (Dft_R_IPPLoop(src, dst, IPPDFT_R_Functor(ippiFunc),ipp_norm_flag))
return;
setIppErrorStatus();
if (src.channels() == 2 && !(inv && (flags & DFT_REAL_OUTPUT)))
{
ippiDFT_C_Func ippiFunc = inv ? (ippiDFT_C_Func)ippiDFTInv_CToC_32fc_C1R : (ippiDFT_C_Func)ippiDFTFwd_CToC_32fc_C1R;
if (Dft_C_IPPLoop(src, dst, IPPDFT_C_Functor(ippiFunc),ipp_norm_flag))
{
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
return;
}
setIppErrorStatus();
}
if (src.channels() == 1 && (inv || !(flags & DFT_COMPLEX_OUTPUT)))
{
ippiDFT_R_Func ippiFunc = inv ? (ippiDFT_R_Func)ippiDFTInv_PackToR_32f_C1R : (ippiDFT_R_Func)ippiDFTFwd_RToPack_32f_C1R;
if (Dft_R_IPPLoop(src, dst, IPPDFT_R_Functor(ippiFunc),ipp_norm_flag))
{
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
return;
}
setIppErrorStatus();
}
}
}
}
@ -2538,7 +2572,7 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows )
spec = 0;
#ifdef USE_IPP_DFT
if( len*count >= 64 ) // use IPP DFT if available
if( CV_IPP_CHECK_COND && (len*count >= 64) ) // use IPP DFT if available
{
int specsize=0, initsize=0, worksize=0;
IppDFTGetSizeFunc getSizeFunc = 0;
@ -3432,12 +3466,18 @@ void cv::dct( InputArray _src0, OutputArray _dst, int flags )
Mat dst = _dst.getMat();
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
bool row = (flags & DCT_ROWS) != 0;
if (src.type() == CV_32F)
CV_IPP_CHECK()
{
if(ippi_DCT_32f(src,dst,inv, row))
return;
setIppErrorStatus();
bool row = (flags & DCT_ROWS) != 0;
if (src.type() == CV_32F)
{
if(ippi_DCT_32f(src,dst,inv, row))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif

View File

@ -240,10 +240,16 @@ float cubeRoot( float value )
static void Magnitude_32f(const float* x, const float* y, float* mag, int len)
{
#if defined HAVE_IPP && 0
IppStatus status = ippsMagnitude_32f(x, y, mag, len);
if (status >= 0)
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
IppStatus status = ippsMagnitude_32f(x, y, mag, len);
if (status >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
int i = 0;
@ -286,10 +292,16 @@ static void Magnitude_32f(const float* x, const float* y, float* mag, int len)
static void Magnitude_64f(const double* x, const double* y, double* mag, int len)
{
#if defined(HAVE_IPP)
IppStatus status = ippsMagnitude_64f(x, y, mag, len);
if (status >= 0)
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
IppStatus status = ippsMagnitude_64f(x, y, mag, len);
if (status >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
int i = 0;
@ -320,9 +332,15 @@ static void Magnitude_64f(const double* x, const double* y, double* mag, int len
static void InvSqrt_32f(const float* src, float* dst, int len)
{
#if defined(HAVE_IPP)
if (ippsInvSqrt_32f_A21(src, dst, len) >= 0)
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (ippsInvSqrt_32f_A21(src, dst, len) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
int i = 0;
@ -380,9 +398,15 @@ static void InvSqrt_64f(const double* src, double* dst, int len)
static void Sqrt_32f(const float* src, float* dst, int len)
{
#if defined(HAVE_IPP)
if (ippsSqrt_32f_A21(src, dst, len) >= 0)
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (ippsSqrt_32f_A21(src, dst, len) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
int i = 0;
@ -414,9 +438,15 @@ static void Sqrt_32f(const float* src, float* dst, int len)
static void Sqrt_64f(const double* src, double* dst, int len)
{
#if defined(HAVE_IPP)
if (ippsSqrt_64f_A50(src, dst, len) >= 0)
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (ippsSqrt_64f_A50(src, dst, len) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
#endif
int i = 0;
@ -790,19 +820,25 @@ void polarToCart( InputArray src1, InputArray src2,
Mat X = dst1.getMat(), Y = dst2.getMat();
#if defined(HAVE_IPP)
if (Mag.isContinuous() && Angle.isContinuous() && X.isContinuous() && Y.isContinuous() && !angleInDegrees)
CV_IPP_CHECK()
{
typedef IppStatus (CV_STDCALL * ippsPolarToCart)(const void * pSrcMagn, const void * pSrcPhase,
void * pDstRe, void * pDstIm, int len);
ippsPolarToCart ippFunc =
depth == CV_32F ? (ippsPolarToCart)ippsPolarToCart_32f :
depth == CV_64F ? (ippsPolarToCart)ippsPolarToCart_64f : 0;
CV_Assert(ippFunc != 0);
if (Mag.isContinuous() && Angle.isContinuous() && X.isContinuous() && Y.isContinuous() && !angleInDegrees)
{
typedef IppStatus (CV_STDCALL * ippsPolarToCart)(const void * pSrcMagn, const void * pSrcPhase,
void * pDstRe, void * pDstIm, int len);
ippsPolarToCart ippFunc =
depth == CV_32F ? (ippsPolarToCart)ippsPolarToCart_32f :
depth == CV_64F ? (ippsPolarToCart)ippsPolarToCart_64f : 0;
CV_Assert(ippFunc != 0);
IppStatus status = ippFunc(Mag.ptr(), Angle.ptr(), X.ptr(), Y.ptr(), static_cast<int>(cn * X.total()));
if (status >= 0)
return;
setIppErrorStatus();
IppStatus status = ippFunc(Mag.ptr(), Angle.ptr(), X.ptr(), Y.ptr(), static_cast<int>(cn * X.total()));
if (status >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
@ -1353,17 +1389,29 @@ static void Exp_64f( const double *_x, double *y, int n )
#ifdef HAVE_IPP
static void Exp_32f_ipp(const float *x, float *y, int n)
{
if (0 <= ippsExp_32f_A21(x, y, n))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (0 <= ippsExp_32f_A21(x, y, n))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
Exp_32f(x, y, n);
}
static void Exp_64f_ipp(const double *x, double *y, int n)
{
if (0 <= ippsExp_64f_A50(x, y, n))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (0 <= ippsExp_64f_A50(x, y, n))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
Exp_64f(x, y, n);
}
@ -2013,17 +2061,29 @@ static void Log_64f( const double *x, double *y, int n )
#ifdef HAVE_IPP
static void Log_32f_ipp(const float *x, float *y, int n)
{
if (0 <= ippsLn_32f_A21(x, y, n))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (0 <= ippsLn_32f_A21(x, y, n))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
Log_32f(x, y, n);
}
static void Log_64f_ipp(const double *x, double *y, int n)
{
if (0 <= ippsLn_64f_A50(x, y, n))
return;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (0 <= ippsLn_64f_A50(x, y, n))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
Log_64f(x, y, n);
}
@ -2216,28 +2276,34 @@ void pow( InputArray _src, double power, OutputArray _dst )
return;
case 2:
#if defined(HAVE_IPP)
if (depth == CV_32F && !same && ( (_src.dims() <= 2 && !ocl::useOpenCL()) ||
(_src.dims() > 2 && _src.isContinuous() && _dst.isContinuous()) ))
CV_IPP_CHECK()
{
Mat src = _src.getMat();
_dst.create( src.dims, src.size, type );
Mat dst = _dst.getMat();
Size size = src.size();
int srcstep = (int)src.step, dststep = (int)dst.step, esz = CV_ELEM_SIZE(type);
if (src.isContinuous() && dst.isContinuous())
if (depth == CV_32F && !same && ( (_src.dims() <= 2 && !ocl::useOpenCL()) ||
(_src.dims() > 2 && _src.isContinuous() && _dst.isContinuous()) ))
{
size.width = (int)src.total();
size.height = 1;
srcstep = dststep = (int)src.total() * esz;
Mat src = _src.getMat();
_dst.create( src.dims, src.size, type );
Mat dst = _dst.getMat();
Size size = src.size();
int srcstep = (int)src.step, dststep = (int)dst.step, esz = CV_ELEM_SIZE(type);
if (src.isContinuous() && dst.isContinuous())
{
size.width = (int)src.total();
size.height = 1;
srcstep = dststep = (int)src.total() * esz;
}
size.width *= cn;
IppStatus status = ippiSqr_32f_C1R(src.ptr<Ipp32f>(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
if (status >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
size.width *= cn;
IppStatus status = ippiSqr_32f_C1R(src.ptr<Ipp32f>(), srcstep, dst.ptr<Ipp32f>(), dststep, ippiSize(size.width, size.height));
if (status >= 0)
return;
setIppErrorStatus();
}
#endif
if (same)
@ -2288,15 +2354,21 @@ void pow( InputArray _src, double power, OutputArray _dst )
else
{
#if defined(HAVE_IPP)
if (src.isContinuous() && dst.isContinuous())
CV_IPP_CHECK()
{
IppStatus status = depth == CV_32F ?
ippsPowx_32f_A21(src.ptr<Ipp32f>(), (Ipp32f)power, dst.ptr<Ipp32f>(), (Ipp32s)(src.total() * cn)) :
ippsPowx_64f_A50(src.ptr<Ipp64f>(), power, dst.ptr<Ipp64f>(), (Ipp32s)(src.total() * cn));
if (src.isContinuous() && dst.isContinuous())
{
IppStatus status = depth == CV_32F ?
ippsPowx_32f_A21(src.ptr<Ipp32f>(), (Ipp32f)power, dst.ptr<Ipp32f>(), (Ipp32s)(src.total() * cn)) :
ippsPowx_64f_A50(src.ptr<Ipp64f>(), power, dst.ptr<Ipp64f>(), (Ipp32s)(src.total() * cn));
if (status >= 0)
return;
setIppErrorStatus();
if (status >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif

View File

@ -2821,11 +2821,17 @@ static double dotProd_8u(const uchar* src1, const uchar* src2, int len)
{
double r = 0;
#if ARITHM_USE_IPP && 0
if (0 <= ippiDotProd_8u64f_C1R(src1, (int)(len*sizeof(src1[0])),
src2, (int)(len*sizeof(src2[0])),
ippiSize(len, 1), &r))
return r;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (0 <= ippiDotProd_8u64f_C1R(src1, (int)(len*sizeof(src1[0])),
src2, (int)(len*sizeof(src2[0])),
ippiSize(len, 1), &r))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return r;
}
setIppErrorStatus();
}
#endif
int i = 0;
@ -2968,10 +2974,16 @@ static double dotProd_8s(const schar* src1, const schar* src2, int len)
static double dotProd_16u(const ushort* src1, const ushort* src2, int len)
{
#if (ARITHM_USE_IPP == 1)
double r = 0;
if (0 <= ippiDotProd_16u64f_C1R(src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r))
return r;
setIppErrorStatus();
CV_IPP_CHECK()
{
double r = 0;
if (0 <= ippiDotProd_16u64f_C1R(src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return r;
}
setIppErrorStatus();
}
#endif
return dotProd_(src1, src2, len);
}
@ -2979,10 +2991,16 @@ static double dotProd_16u(const ushort* src1, const ushort* src2, int len)
static double dotProd_16s(const short* src1, const short* src2, int len)
{
#if (ARITHM_USE_IPP == 1)
double r = 0;
if (0 <= ippiDotProd_16s64f_C1R(src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r))
return r;
setIppErrorStatus();
CV_IPP_CHECK()
{
double r = 0;
if (0 <= ippiDotProd_16s64f_C1R(src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return r;
}
setIppErrorStatus();
}
#endif
return dotProd_(src1, src2, len);
}
@ -2990,10 +3008,16 @@ static double dotProd_16s(const short* src1, const short* src2, int len)
static double dotProd_32s(const int* src1, const int* src2, int len)
{
#if (ARITHM_USE_IPP == 1)
double r = 0;
if (0 <= ippiDotProd_32s64f_C1R(src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r))
return r;
setIppErrorStatus();
CV_IPP_CHECK()
{
double r = 0;
if (0 <= ippiDotProd_32s64f_C1R(src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return r;
}
setIppErrorStatus();
}
#endif
return dotProd_(src1, src2, len);
}
@ -3004,9 +3028,15 @@ static double dotProd_32f(const float* src1, const float* src2, int len)
int i = 0;
#if (ARITHM_USE_IPP == 1)
if (0 <= ippsDotProd_32f64f(src1, src2, len, &r))
return r;
setIppErrorStatus();
CV_IPP_CHECK()
{
if (0 <= ippsDotProd_32f64f(src1, src2, len, &r))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return r;
}
setIppErrorStatus();
}
#elif CV_NEON
int len0 = len & -4, blockSize0 = (1 << 13), blockSize;
float32x4_t v_zero = vdupq_n_f32(0.0f);
@ -3035,10 +3065,16 @@ static double dotProd_32f(const float* src1, const float* src2, int len)
static double dotProd_64f(const double* src1, const double* src2, int len)
{
#if (ARITHM_USE_IPP == 1)
double r = 0;
if (0 <= ippsDotProd_64f(src1, src2, len, &r))
return r;
setIppErrorStatus();
CV_IPP_CHECK()
{
double r = 0;
if (0 <= ippsDotProd_64f(src1, src2, len, &r))
{
CV_IMPL_ADD(CV_IMPL_IPP);
return r;
}
setIppErrorStatus();
}
#endif
return dotProd_(src1, src2, len);
}

View File

@ -3066,64 +3066,73 @@ void cv::transpose( InputArray _src, OutputArray _dst )
}
#if defined HAVE_IPP
typedef IppStatus (CV_STDCALL * ippiTranspose)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize);
typedef IppStatus (CV_STDCALL * ippiTransposeI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize);
ippiTranspose ippFunc = 0;
ippiTransposeI ippFuncI = 0;
CV_IPP_CHECK()
{
typedef IppStatus (CV_STDCALL * ippiTranspose)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize);
typedef IppStatus (CV_STDCALL * ippiTransposeI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize);
ippiTranspose ippFunc = 0;
ippiTransposeI ippFuncI = 0;
if (dst.data == src.data && dst.cols == dst.rows)
{
CV_SUPPRESS_DEPRECATED_START
ippFuncI =
type == CV_8UC1 ? (ippiTransposeI)ippiTranspose_8u_C1IR :
type == CV_8UC3 ? (ippiTransposeI)ippiTranspose_8u_C3IR :
type == CV_8UC4 ? (ippiTransposeI)ippiTranspose_8u_C4IR :
type == CV_16UC1 ? (ippiTransposeI)ippiTranspose_16u_C1IR :
type == CV_16UC3 ? (ippiTransposeI)ippiTranspose_16u_C3IR :
type == CV_16UC4 ? (ippiTransposeI)ippiTranspose_16u_C4IR :
type == CV_16SC1 ? (ippiTransposeI)ippiTranspose_16s_C1IR :
type == CV_16SC3 ? (ippiTransposeI)ippiTranspose_16s_C3IR :
type == CV_16SC4 ? (ippiTransposeI)ippiTranspose_16s_C4IR :
type == CV_32SC1 ? (ippiTransposeI)ippiTranspose_32s_C1IR :
type == CV_32SC3 ? (ippiTransposeI)ippiTranspose_32s_C3IR :
type == CV_32SC4 ? (ippiTransposeI)ippiTranspose_32s_C4IR :
type == CV_32FC1 ? (ippiTransposeI)ippiTranspose_32f_C1IR :
type == CV_32FC3 ? (ippiTransposeI)ippiTranspose_32f_C3IR :
type == CV_32FC4 ? (ippiTransposeI)ippiTranspose_32f_C4IR : 0;
CV_SUPPRESS_DEPRECATED_END
}
else
{
ippFunc =
type == CV_8UC1 ? (ippiTranspose)ippiTranspose_8u_C1R :
type == CV_8UC3 ? (ippiTranspose)ippiTranspose_8u_C3R :
type == CV_8UC4 ? (ippiTranspose)ippiTranspose_8u_C4R :
type == CV_16UC1 ? (ippiTranspose)ippiTranspose_16u_C1R :
type == CV_16UC3 ? (ippiTranspose)ippiTranspose_16u_C3R :
type == CV_16UC4 ? (ippiTranspose)ippiTranspose_16u_C4R :
type == CV_16SC1 ? (ippiTranspose)ippiTranspose_16s_C1R :
type == CV_16SC3 ? (ippiTranspose)ippiTranspose_16s_C3R :
type == CV_16SC4 ? (ippiTranspose)ippiTranspose_16s_C4R :
type == CV_32SC1 ? (ippiTranspose)ippiTranspose_32s_C1R :
type == CV_32SC3 ? (ippiTranspose)ippiTranspose_32s_C3R :
type == CV_32SC4 ? (ippiTranspose)ippiTranspose_32s_C4R :
type == CV_32FC1 ? (ippiTranspose)ippiTranspose_32f_C1R :
type == CV_32FC3 ? (ippiTranspose)ippiTranspose_32f_C3R :
type == CV_32FC4 ? (ippiTranspose)ippiTranspose_32f_C4R : 0;
}
if (dst.data == src.data && dst.cols == dst.rows)
{
CV_SUPPRESS_DEPRECATED_START
ippFuncI =
type == CV_8UC1 ? (ippiTransposeI)ippiTranspose_8u_C1IR :
type == CV_8UC3 ? (ippiTransposeI)ippiTranspose_8u_C3IR :
type == CV_8UC4 ? (ippiTransposeI)ippiTranspose_8u_C4IR :
type == CV_16UC1 ? (ippiTransposeI)ippiTranspose_16u_C1IR :
type == CV_16UC3 ? (ippiTransposeI)ippiTranspose_16u_C3IR :
type == CV_16UC4 ? (ippiTransposeI)ippiTranspose_16u_C4IR :
type == CV_16SC1 ? (ippiTransposeI)ippiTranspose_16s_C1IR :
type == CV_16SC3 ? (ippiTransposeI)ippiTranspose_16s_C3IR :
type == CV_16SC4 ? (ippiTransposeI)ippiTranspose_16s_C4IR :
type == CV_32SC1 ? (ippiTransposeI)ippiTranspose_32s_C1IR :
type == CV_32SC3 ? (ippiTransposeI)ippiTranspose_32s_C3IR :
type == CV_32SC4 ? (ippiTransposeI)ippiTranspose_32s_C4IR :
type == CV_32FC1 ? (ippiTransposeI)ippiTranspose_32f_C1IR :
type == CV_32FC3 ? (ippiTransposeI)ippiTranspose_32f_C3IR :
type == CV_32FC4 ? (ippiTransposeI)ippiTranspose_32f_C4IR : 0;
CV_SUPPRESS_DEPRECATED_END
}
else
{
ippFunc =
type == CV_8UC1 ? (ippiTranspose)ippiTranspose_8u_C1R :
type == CV_8UC3 ? (ippiTranspose)ippiTranspose_8u_C3R :
type == CV_8UC4 ? (ippiTranspose)ippiTranspose_8u_C4R :
type == CV_16UC1 ? (ippiTranspose)ippiTranspose_16u_C1R :
type == CV_16UC3 ? (ippiTranspose)ippiTranspose_16u_C3R :
type == CV_16UC4 ? (ippiTranspose)ippiTranspose_16u_C4R :
type == CV_16SC1 ? (ippiTranspose)ippiTranspose_16s_C1R :
type == CV_16SC3 ? (ippiTranspose)ippiTranspose_16s_C3R :
type == CV_16SC4 ? (ippiTranspose)ippiTranspose_16s_C4R :
type == CV_32SC1 ? (ippiTranspose)ippiTranspose_32s_C1R :
type == CV_32SC3 ? (ippiTranspose)ippiTranspose_32s_C3R :
type == CV_32SC4 ? (ippiTranspose)ippiTranspose_32s_C4R :
type == CV_32FC1 ? (ippiTranspose)ippiTranspose_32f_C1R :
type == CV_32FC3 ? (ippiTranspose)ippiTranspose_32f_C3R :
type == CV_32FC4 ? (ippiTranspose)ippiTranspose_32f_C4R : 0;
}
IppiSize roiSize = { src.cols, src.rows };
if (ippFunc != 0)
{
if (ippFunc(src.ptr(), (int)src.step, dst.ptr(), (int)dst.step, roiSize) >= 0)
return;
setIppErrorStatus();
}
else if (ippFuncI != 0)
{
if (ippFuncI(dst.ptr(), (int)dst.step, roiSize) >= 0)
return;
setIppErrorStatus();
IppiSize roiSize = { src.cols, src.rows };
if (ippFunc != 0)
{
if (ippFunc(src.ptr(), (int)src.step, dst.ptr(), (int)dst.step, roiSize) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
else if (ippFuncI != 0)
{
if (ippFuncI(dst.ptr(), (int)dst.step, roiSize) >= 0)
{
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
setIppErrorStatus();
}
}
#endif
@ -3353,27 +3362,32 @@ static inline void reduceSumC_8u16u16s32f_64f(const cv::Mat& srcmat, cv::Mat& ds
}
CV_Assert(!(ippFunc && ippFuncHint) && func);
if (ippFunc)
CV_IPP_CHECK()
{
for (int y = 0; y < size.height; ++y)
if (ippFunc(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y)) < 0)
{
setIppErrorStatus();
cv::Mat dstroi = dstmat.rowRange(y, y + 1);
func(srcmat.rowRange(y, y + 1), dstroi);
}
return;
}
else if (ippFuncHint)
{
for (int y = 0; y < size.height; ++y)
if (ippFuncHint(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y), ippAlgHintAccurate) < 0)
{
setIppErrorStatus();
cv::Mat dstroi = dstmat.rowRange(y, y + 1);
func(srcmat.rowRange(y, y + 1), dstroi);
}
return;
if (ippFunc)
{
for (int y = 0; y < size.height; ++y)
if (ippFunc(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y)) < 0)
{
setIppErrorStatus();
cv::Mat dstroi = dstmat.rowRange(y, y + 1);
func(srcmat.rowRange(y, y + 1), dstroi);
}
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
else if (ippFuncHint)
{
for (int y = 0; y < size.height; ++y)
if (ippFuncHint(srcmat.ptr(y), sstep, roisize, dstmat.ptr<Ipp64f>(y), ippAlgHintAccurate) < 0)
{
setIppErrorStatus();
cv::Mat dstroi = dstmat.rowRange(y, y + 1);
func(srcmat.rowRange(y, y + 1), dstroi);
}
CV_IMPL_ADD(CV_IMPL_IPP);
return;
}
}
func(srcmat, dstmat);
@ -3409,7 +3423,7 @@ static inline void reduce##optype##C##favor(const cv::Mat& srcmat, cv::Mat& dstm
IppiSize roisize = ippiSize(size.width, 1);\
int sstep = (int)srcmat.step; \
\
if (srcmat.channels() == 1) \
if (CV_IPP_CHECK_COND && (srcmat.channels() == 1)) \
{ \
for (int y = 0; y < size.height; ++y) \
if (ippi##optype##_##favor##_C1R(srcmat.ptr<IppType>(y), sstep, roisize, dstmat.ptr<IppType>(y)) < 0) \
@ -3418,6 +3432,10 @@ static inline void reduce##optype##C##favor(const cv::Mat& srcmat, cv::Mat& dstm
cv::Mat dstroi = dstmat.rowRange(y, y + 1); \
cv::reduceC_ < type1, type2, cv::Op##optype < type2 > >(srcmat.rowRange(y, y + 1), dstroi); \
} \
else \
{ \
CV_IMPL_ADD(CV_IMPL_IPP);\
} \
return; \
} \
cv::reduceC_ < type1, type2, cv::Op##optype < type2 > >(srcmat, dstmat); \
@ -3768,8 +3786,13 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
#ifdef USE_IPP_SORT
int depth = src.depth();
IppSortFunc ippSortFunc = getSortFunc(depth, sortDescending);
IppFlipFunc ippFlipFunc = getFlipFunc(depth);
IppSortFunc ippSortFunc = 0;
IppFlipFunc ippFlipFunc = 0;
CV_IPP_CHECK()
{
ippSortFunc = getSortFunc(depth, sortDescending);
ippFlipFunc = getFlipFunc(depth);
}
#endif
for( i = 0; i < n; i++ )
@ -3812,8 +3835,20 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
for( j = 0; j < len/2; j++ )
std::swap(ptr[j], ptr[len-1-j]);
}
#ifdef USE_IPP_SORT
else
{
CV_IMPL_ADD(CV_IMPL_IPP);
}
#endif
}
}
#ifdef USE_IPP_SORT
else
{
CV_IMPL_ADD(CV_IMPL_IPP);
}
#endif
if( !sortRows )
for( j = 0; j < len; j++ )
@ -3878,8 +3913,13 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
#if defined USE_IPP_SORT && 0
int depth = src.depth();
IppSortIndexFunc ippFunc = getSortIndexFunc(depth, sortDescending);
IppFlipFunc ippFlipFunc = getFlipFunc(depth);
IppSortIndexFunc ippFunc = 0;
IppFlipFunc ippFlipFunc = 0;
CV_IPP_CHECK()
{
ippFunc = getSortIndexFunc(depth, sortDescending);
ippFlipFunc = getFlipFunc(depth);
}
#endif
for( i = 0; i < n; i++ )
@ -3920,8 +3960,20 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
for( j = 0; j < len/2; j++ )
std::swap(iptr[j], iptr[len-1-j]);
}
#if defined USE_IPP_SORT && 0
else
{
CV_IMPL_ADD(CV_IMPL_IPP);
}
#endif
}
}
#if defined USE_IPP_SORT && 0
else
{
CV_IMPL_ADD(CV_IMPL_IPP);
}
#endif
if( !sortRows )
for( j = 0; j < len; j++ )

View File

@ -2893,6 +2893,9 @@ bool Kernel::create(const char* kname, const Program& prog)
p->release();
p = 0;
}
#ifdef CV_OPENCL_RUN_ASSERT // check kernel compilation fails
CV_Assert(p);
#endif
return p != 0;
}
@ -3523,6 +3526,10 @@ protected:
entry.clBuffer_ = clCreateBuffer((cl_context)ctx.ptr(), CL_MEM_READ_WRITE, entry.capacity_, 0, &retval);
CV_Assert(retval == CL_SUCCESS);
CV_Assert(entry.clBuffer_ != NULL);
if(retval == CL_SUCCESS)
{
CV_IMPL_ADD(CV_IMPL_OCL);
}
LOG_BUFFER_POOL("OpenCL allocate %lld (0x%llx) bytes: %p\n",
(long long)entry.capacity_, (long long)entry.capacity_, entry.clBuffer_);
}
@ -3747,6 +3754,7 @@ public:
CL_MEM_READ_WRITE|createFlags, total, 0, &retval);
if( !handle || retval != CL_SUCCESS )
return defaultAllocate(dims, sizes, type, data, step, flags, usageFlags);
CV_IMPL_ADD(CV_IMPL_OCL)
}
UMatData* u = new UMatData(this);
u->data = 0;
@ -4187,20 +4195,24 @@ public:
CV_Assert(dst->refcount == 0);
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
cl_int retval;
if( iscontinuous )
{
CV_Assert( clEnqueueCopyBuffer(q, (cl_mem)src->handle, (cl_mem)dst->handle,
srcrawofs, dstrawofs, total, 0, 0, 0) == CL_SUCCESS );
CV_Assert( (retval = clEnqueueCopyBuffer(q, (cl_mem)src->handle, (cl_mem)dst->handle,
srcrawofs, dstrawofs, total, 0, 0, 0)) == CL_SUCCESS );
}
else
{
cl_int retval;
CV_Assert( (retval = clEnqueueCopyBufferRect(q, (cl_mem)src->handle, (cl_mem)dst->handle,
new_srcofs, new_dstofs, new_sz,
new_srcstep[0], new_srcstep[1],
new_dststep[0], new_dststep[1],
0, 0, 0)) == CL_SUCCESS );
}
if(retval == CL_SUCCESS)
{
CV_IMPL_ADD(CV_IMPL_OCL)
}
dst->markHostCopyObsolete(true);
dst->markDeviceCopyObsolete(false);

View File

@ -233,13 +233,25 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl
struct CoreTLSData
{
CoreTLSData() : device(0), useOpenCL(-1)
{}
CoreTLSData() : device(0), useOpenCL(-1), useIPP(-1), useCollection(false)
{
#ifdef CV_COLLECT_IMPL_DATA
implFlags = 0;
#endif
}
RNG rng;
int device;
ocl::Queue oclQueue;
int useOpenCL; // 1 - use, 0 - do not use, -1 - auto/not initialized
int useIPP; // 1 - use, 0 - do not use, -1 - auto/not initialized
bool useCollection; // enable/disable impl data collection
#ifdef CV_COLLECT_IMPL_DATA
int implFlags;
std::vector<int> implCode;
std::vector<String> implFun;
#endif
};
extern TLSData<CoreTLSData> coreTlsData;

File diff suppressed because it is too large Load Diff

View File

@ -1059,6 +1059,51 @@ TLSStorage::~TLSStorage()
TLSData<CoreTLSData> coreTlsData;
#ifdef CV_COLLECT_IMPL_DATA
void setImpl(int flags)
{
CoreTLSData* data = coreTlsData.get();
data->implFlags = flags;
data->implCode.clear();
data->implFun.clear();
}
void addImpl(int flag, const char* func)
{
CoreTLSData* data = coreTlsData.get();
data->implFlags |= flag;
if(func) // use lazy collection if name was not specified
{
size_t index = data->implCode.size();
if(!index || (data->implCode[index-1] != flag || data->implFun[index-1].compare(func))) // avoid duplicates
{
data->implCode.push_back(flag);
data->implFun.push_back(func);
}
}
}
int getImpl(std::vector<int> &impl, std::vector<String> &funName)
{
CoreTLSData* data = coreTlsData.get();
impl = data->implCode;
funName = data->implFun;
return data->implFlags; // return actual flags for lazy collection
}
bool useCollection()
{
CoreTLSData* data = coreTlsData.get();
return data->useCollection;
}
void setUseCollection(bool flag)
{
CoreTLSData* data = coreTlsData.get();
data->useCollection = flag;
}
#endif
namespace ipp
{
@ -1084,6 +1129,35 @@ String getIppErrorLocation()
return format("%s:%d %s", filename ? filename : "", linen, funcname ? funcname : "");
}
bool useIPP()
{
#ifdef HAVE_IPP
CoreTLSData* data = coreTlsData.get();
if(data->useIPP < 0)
{
const char* pIppEnv = getenv("OPENCV_IPP");
if(pIppEnv && (cv::String(pIppEnv) == "disabled"))
data->useIPP = false;
else
data->useIPP = true;
}
return (data->useIPP > 0);
#else
return false;
#endif
}
void setUseIPP(bool flag)
{
CoreTLSData* data = coreTlsData.get();
#ifdef HAVE_IPP
data->useIPP = flag;
#else
(void)flag;
data->useIPP = false;
#endif
}
} // namespace ipp
} // namespace cv

View File

@ -697,7 +697,10 @@ void UMat::copyTo(OutputArray _dst, InputArray _mask) const
size_t globalsize[2] = { cols, rows };
if (k.run(2, globalsize, NULL, false))
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
}
}
#endif
@ -753,7 +756,10 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con
size_t globalsize[2] = { dst.cols * cn, (dst.rows + rowsPerWI - 1) / rowsPerWI };
if (k.run(2, globalsize, NULL, false))
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
}
}
#endif
@ -802,7 +808,10 @@ UMat& UMat::setTo(InputArray _value, InputArray _mask)
size_t globalsize[] = { cols, (rows + rowsPerWI - 1) / rowsPerWI };
if( setK.run(2, globalsize, NULL, false) )
{
CV_IMPL_ADD(CV_IMPL_OCL);
return *this;
}
}
}
#endif

View File

@ -332,7 +332,10 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
{
if( ocl::useOpenCL() && _img.isUMat() && type == FastFeatureDetector::TYPE_9_16 &&
ocl_FAST(_img, keypoints, threshold, nonmax_suppression, 10000))
return;
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
switch(type) {
case FastFeatureDetector::TYPE_5_8:

View File

@ -943,12 +943,18 @@ void BFMatcher::knnMatchImpl( InputArray _queryDescriptors, std::vector<std::vec
if(trainDescCollection.empty())
{
if(ocl_match(_queryDescriptors, utrainDescCollection[0], matches, normType))
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
}
else
{
if(ocl_match(_queryDescriptors, trainDescCollection[0], matches, normType))
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
}
}
else
@ -956,12 +962,18 @@ void BFMatcher::knnMatchImpl( InputArray _queryDescriptors, std::vector<std::vec
if(trainDescCollection.empty())
{
if(ocl_knnMatch(_queryDescriptors, utrainDescCollection[0], matches, knn, normType, compactResult) )
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
}
else
{
if(ocl_knnMatch(_queryDescriptors, trainDescCollection[0], matches, knn, normType, compactResult) )
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
}
}
}
@ -1073,12 +1085,18 @@ void BFMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vector<std::
if (trainDescCollection.empty())
{
if(ocl_radiusMatch(_queryDescriptors, utrainDescCollection[0], matches, maxDistance, normType, compactResult) )
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
}
else
{
if (ocl_radiusMatch(_queryDescriptors, trainDescCollection[0], matches, maxDistance, normType, compactResult) )
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
}
}

View File

@ -823,6 +823,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
uresponses, nkeypoints, 7, HARRIS_K );
if( useOCL )
{
CV_IMPL_ADD(CV_IMPL_OCL);
uresponses.copyTo(responses);
for( i = 0; i < nkeypoints; i++ )
allKeypoints[i].response = responses.at<float>(i);
@ -867,6 +868,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
if( useOCL )
{
CV_IMPL_ADD(CV_IMPL_OCL);
uresponses.copyTo(responses);
for( i = 0; i < nkeypoints; i++ )
allKeypoints[i].angle = responses.at<float>(i);
@ -1110,6 +1112,10 @@ void ORB::operator()( InputArray _image, InputArray _mask, std::vector<KeyPoint>
useOCL = ocl_computeOrbDescriptors(uimagePyramid, ulayerInfo,
ukeypoints, udescriptors, upattern,
nkeypoints, dsize, WTA_K);
if(useOCL)
{
CV_IMPL_ADD(CV_IMPL_OCL);
}
}
if( !useOCL )

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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 );

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -1213,6 +1213,7 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
if( maxObjectSize.height == 0 || maxObjectSize.width == 0 )
maxObjectSize = imgsz;
#ifdef HAVE_OPENCL
bool use_ocl = tryOpenCL && ocl::useOpenCL() &&
featureEvaluator->getLocalSize().area() > 0 &&
ocl::Device::getDefault().type() != ocl::Device::TYPE_CPU &&
@ -1220,6 +1221,7 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
!isOldFormatCascade() &&
maskGenerator.empty() &&
!outputRejectLevels;
#endif
/*if( use_ocl )
{
@ -1262,8 +1264,8 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
return;
// OpenCL code
if( use_ocl && ocl_detectMultiScaleNoGrouping( scales, candidates ))
return;
CV_OCL_RUN(use_ocl, ocl_detectMultiScaleNoGrouping( scales, candidates ))
tryOpenCL = false;
// CPU code

View File

@ -159,7 +159,7 @@ icvReleaseHidHaarClassifierCascade( CvHidHaarClassifierCascade** _cascade )
{
#ifdef HAVE_IPP
CvHidHaarClassifierCascade* cascade = *_cascade;
if( cascade->ipp_stages )
if( CV_IPP_CHECK_COND && cascade->ipp_stages )
{
int i;
for( i = 0; i < cascade->count; i++ )
@ -338,7 +338,7 @@ icvCreateHidHaarClassifierCascade( CvHaarClassifierCascade* cascade )
}
/*
#ifdef HAVE_IPP
int can_use_ipp = !out->has_tilted_features && !out->is_tree && out->isStumpBased;
int can_use_ipp = CV_IPP_CHECK_COND && (!out->has_tilted_features && !out->is_tree && out->isStumpBased);
if( can_use_ipp )
{
@ -1315,7 +1315,7 @@ public:
int x, y, ystep = factor > 2 ? 1 : 2;
#ifdef HAVE_IPP
if( cascade->hid_cascade->ipp_stages )
if(CV_IPP_CHECK_COND && cascade->hid_cascade->ipp_stages )
{
IppiRect iequRect = {equRect.x, equRect.y, equRect.width, equRect.height};
ippiRectStdDev_32f_C1R(sum1.ptr<float>(y1), (int)sum1.step,
@ -1351,6 +1351,7 @@ public:
if( positive <= 0 )
break;
}
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
if( positive > 0 )
for( y = y1; y < y2; y += ystep )
@ -1561,7 +1562,7 @@ cvHaarDetectObjectsForROC( const CvArr* _img,
{
CvSize winSize0 = cascade->orig_window_size;
#ifdef HAVE_IPP
int use_ipp = cascade->hid_cascade->ipp_stages != 0;
int use_ipp = CV_IPP_CHECK_COND && (cascade->hid_cascade->ipp_stages != 0);
if( use_ipp )
normImg.reset(cvCreateMat( img->rows, img->cols, CV_32FC1));

View File

@ -414,6 +414,12 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
}
}
}
#ifdef HAVE_OPENCL
else
{
CV_IMPL_ADD(CV_IMPL_OCL);
}
#endif
x_tl /= 2; y_tl /= 2;
x_br /= 2; y_br /= 2;
@ -476,8 +482,8 @@ void normalizeUsingWeightMap(InputArray _weight, InputOutputArray _src)
#endif
#ifdef HAVE_OPENCL
if ( !cv::ocl::useOpenCL() ||
!ocl_normalizeUsingWeightMap(_weight, _src) )
if ( !cv::ocl::useOpenCL() ||
!ocl_normalizeUsingWeightMap(_weight, _src) )
#endif
{
Mat weight = _weight.getMat();
@ -519,6 +525,12 @@ void normalizeUsingWeightMap(InputArray _weight, InputOutputArray _src)
}
}
}
#ifdef HAVE_OPENCL
else
{
CV_IMPL_ADD(CV_IMPL_OCL);
}
#endif
}

View File

@ -114,7 +114,10 @@ Rect PlaneWarper::buildMaps(Size src_size, InputArray K, InputArray R, InputArra
size_t globalsize[2] = { dsize.width, (dsize.height + rowsPerWI - 1) / rowsPerWI };
if (k.run(2, globalsize, NULL, true))
{
CV_IMPL_ADD(CV_IMPL_OCL);
return Rect(dst_tl, dst_br);
}
}
}
@ -389,7 +392,10 @@ Rect SphericalWarper::buildMaps(Size src_size, InputArray K, InputArray R, Outpu
size_t globalsize[2] = { dsize.width, (dsize.height + rowsPerWI - 1) / rowsPerWI };
if (k.run(2, globalsize, NULL, true))
{
CV_IMPL_ADD(CV_IMPL_OCL);
return Rect(dst_tl, dst_br);
}
}
}
@ -435,7 +441,10 @@ Rect CylindricalWarper::buildMaps(Size src_size, InputArray K, InputArray R, Out
size_t globalsize[2] = { dsize.width, (dsize.height + rowsPerWI - 1) / rowsPerWI };
if (k.run(2, globalsize, NULL, true))
{
CV_IMPL_ADD(CV_IMPL_OCL);
return Rect(dst_tl, dst_br);
}
}
}

View File

@ -265,6 +265,95 @@ enum PERF_STRATEGY
/*****************************************************************************************\
* Base fixture for performance tests *
\*****************************************************************************************/
#ifdef CV_COLLECT_IMPL_DATA
// Implementation collection processing class.
// Accumulates and shapes implementation data.
typedef struct ImplData
{
bool ipp;
bool icv;
bool ipp_mt;
bool ocl;
bool plain;
std::vector<int> implCode;
std::vector<cv::String> funName;
ImplData()
{
Reset();
}
void Reset()
{
cv::setImpl(0);
ipp = icv = ocl = ipp_mt = false;
implCode.clear();
funName.clear();
}
void GetImpl()
{
flagsToVars(cv::getImpl(implCode, funName));
}
std::vector<cv::String> GetCallsForImpl(int impl)
{
std::vector<cv::String> out;
for(int i = 0; i < implCode.size(); i++)
{
if(impl == implCode[i])
out.push_back(funName[i]);
}
return out;
}
// Remove duplicate entries
void ShapeUp()
{
std::vector<int> savedCode;
std::vector<cv::String> savedName;
for(int i = 0; i < implCode.size(); i++)
{
bool match = false;
for(int j = 0; j < savedCode.size(); j++)
{
if(implCode[i] == savedCode[j] && !funName[i].compare(savedName[j]))
{
match = true;
break;
}
}
if(!match)
{
savedCode.push_back(implCode[i]);
savedName.push_back(funName[i]);
}
}
implCode = savedCode;
funName = savedName;
}
// convert flags register to more handy variables
void flagsToVars(int flags)
{
#if defined(HAVE_IPP_ICV_ONLY)
ipp = 0;
icv = ((flags&CV_IMPL_IPP) > 0);
#else
ipp = ((flags&CV_IMPL_IPP) > 0);
icv = 0;
#endif
ipp_mt = ((flags&CV_IMPL_MT) > 0);
ocl = ((flags&CV_IMPL_OCL) > 0);
plain = (flags == 0);
}
} ImplData;
#endif
class CV_EXPORTS TestBase: public ::testing::Test
{
public:
@ -308,6 +397,10 @@ protected:
performance_metrics& calcMetrics();
void RunPerfTestBody();
#ifdef CV_COLLECT_IMPL_DATA
ImplData implConf;
#endif
private:
typedef std::vector<std::pair<int, cv::Size> > SizeVector;
typedef std::vector<int64> TimeVector;

View File

@ -31,6 +31,9 @@ static double param_time_limit;
static int param_threads;
static bool param_write_sanity;
static bool param_verify_sanity;
#ifdef CV_COLLECT_IMPL_DATA
static bool param_collect_impl;
#endif
extern bool test_ipp_check;
#ifdef HAVE_CUDA
static int param_cuda_device;
@ -673,6 +676,9 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
"{ perf_max_deviation |1.0 |}"
#ifdef HAVE_IPP
"{ perf_ipp_check |false |check whether IPP works without failures}"
#endif
#ifdef CV_COLLECT_IMPL_DATA
"{ perf_collect_impl |false |collect info about executed implementations}"
#endif
"{ help h |false |print help info}"
#ifdef HAVE_CUDA
@ -719,6 +725,9 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
param_verify_sanity = args.has("perf_verify_sanity");
test_ipp_check = !args.has("perf_ipp_check") ? getenv("OPENCV_IPP_CHECK") != NULL : true;
param_threads = args.get<int>("perf_threads");
#ifdef CV_COLLECT_IMPL_DATA
param_collect_impl = args.has("perf_collect_impl");
#endif
#ifdef ANDROID
param_affinity_mask = args.get<int>("perf_affinity_mask");
log_power_checkpoints = args.has("perf_log_power_checkpoints");
@ -743,6 +752,13 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
exit(1);
}
#ifdef CV_COLLECT_IMPL_DATA
if(param_collect_impl)
cv::setUseCollection(1);
else
cv::setUseCollection(0);
#endif
#ifdef HAVE_CUDA
bool printOnly = args.has("perf_cuda_info_only");
@ -1242,6 +1258,28 @@ void TestBase::reportMetrics(bool toJUnitXML)
RecordProperty("gstddev", cv::format("%.6f", m.gstddev).c_str());
RecordProperty("mean", cv::format("%.0f", m.mean).c_str());
RecordProperty("stddev", cv::format("%.0f", m.stddev).c_str());
#ifdef CV_COLLECT_IMPL_DATA
if(param_collect_impl)
{
RecordProperty("impl_ipp", (int)(implConf.ipp || implConf.icv));
RecordProperty("impl_ocl", (int)implConf.ocl);
RecordProperty("impl_plain", (int)implConf.plain);
std::string rec_line;
std::vector<cv::String> rec;
rec_line.clear();
rec = implConf.GetCallsForImpl(CV_IMPL_IPP|CV_IMPL_MT);
for(int i=0; i<rec.size();i++ ){rec_line += rec[i].c_str(); rec_line += " ";}
rec = implConf.GetCallsForImpl(CV_IMPL_IPP);
for(int i=0; i<rec.size();i++ ){rec_line += rec[i].c_str(); rec_line += " ";}
RecordProperty("impl_rec_ipp", rec_line.c_str());
rec_line.clear();
rec = implConf.GetCallsForImpl(CV_IMPL_OCL);
for(int i=0; i<rec.size();i++ ){rec_line += rec[i].c_str(); rec_line += " ";}
RecordProperty("impl_rec_ocl", rec_line.c_str());
}
#endif
}
else
{
@ -1276,6 +1314,29 @@ void TestBase::reportMetrics(bool toJUnitXML)
break;
};
#ifdef CV_COLLECT_IMPL_DATA
if(param_collect_impl)
{
LOGD("impl_ipp =%11d", (int)(implConf.ipp || implConf.icv));
LOGD("impl_ocl =%11d", (int)implConf.ocl);
LOGD("impl_plain =%11d", (int)implConf.plain);
std::string rec_line;
std::vector<cv::String> rec;
rec_line.clear();
rec = implConf.GetCallsForImpl(CV_IMPL_IPP|CV_IMPL_MT);
for(int i=0; i<rec.size();i++ ){rec_line += rec[i].c_str(); rec_line += " ";}
rec = implConf.GetCallsForImpl(CV_IMPL_IPP);
for(int i=0; i<rec.size();i++ ){rec_line += rec[i].c_str(); rec_line += " ";}
LOGD("impl_rec_ipp =%s", rec_line.c_str());
rec_line.clear();
rec = implConf.GetCallsForImpl(CV_IMPL_OCL);
for(int i=0; i<rec.size();i++ ){rec_line += rec[i].c_str(); rec_line += " ";}
LOGD("impl_rec_ocl =%s", rec_line.c_str());
}
#endif
LOGD("bytesIn =%11lu", (unsigned long)m.bytesIn);
LOGD("bytesOut =%11lu", (unsigned long)m.bytesOut);
if (nIters == (unsigned int)-1 || m.terminationReason == performance_metrics::TERM_ITERATIONS)
@ -1343,6 +1404,30 @@ void TestBase::TearDown()
const char* value_param = test_info->value_param();
if (value_param) printf("[ VALUE ] \t%s\n", value_param), fflush(stdout);
if (type_param) printf("[ TYPE ] \t%s\n", type_param), fflush(stdout);
#ifdef CV_COLLECT_IMPL_DATA
if(param_collect_impl)
{
implConf.ShapeUp();
printf("[ I. FLAGS ] \t");
if(implConf.ipp_mt)
{
if(implConf.icv) {printf("ICV_MT "); std::vector<cv::String> fun = implConf.GetCallsForImpl(CV_IMPL_IPP|CV_IMPL_MT); printf("("); for(int i=0; i<fun.size();i++ ){printf("%s ", fun[i].c_str());} printf(") "); }
if(implConf.ipp) {printf("IPP_MT "); std::vector<cv::String> fun = implConf.GetCallsForImpl(CV_IMPL_IPP|CV_IMPL_MT); printf("("); for(int i=0; i<fun.size();i++ ){printf("%s ", fun[i].c_str());} printf(") "); }
}
else
{
if(implConf.icv) {printf("ICV "); std::vector<cv::String> fun = implConf.GetCallsForImpl(CV_IMPL_IPP); printf("("); for(int i=0; i<fun.size();i++ ){printf("%s ", fun[i].c_str());} printf(") "); }
if(implConf.ipp) {printf("IPP "); std::vector<cv::String> fun = implConf.GetCallsForImpl(CV_IMPL_IPP); printf("("); for(int i=0; i<fun.size();i++ ){printf("%s ", fun[i].c_str());} printf(") "); }
}
if(implConf.ocl) {printf("OCL "); std::vector<cv::String> fun = implConf.GetCallsForImpl(CV_IMPL_OCL); printf("("); for(int i=0; i<fun.size();i++ ){printf("%s ", fun[i].c_str());} printf(") "); }
if(implConf.plain) printf("PLAIN ");
if(!(implConf.ipp_mt || implConf.icv || implConf.ipp || implConf.ocl || implConf.plain))
printf("ERROR ");
printf("\n");
fflush(stdout);
}
#endif
reportMetrics(true);
}
@ -1391,7 +1476,15 @@ void TestBase::RunPerfTestBody()
{
try
{
#ifdef CV_COLLECT_IMPL_DATA
if(param_collect_impl)
implConf.Reset();
#endif
this->PerfTestBody();
#ifdef CV_COLLECT_IMPL_DATA
if(param_collect_impl)
implConf.GetImpl();
#endif
}
catch(PerfSkipTestException&)
{

View File

@ -1096,7 +1096,10 @@ void cv::calcOpticalFlowPyrLK( InputArray _prevImg, InputArray _nextImg,
(_prevImg.isUMat() || _nextImg.isUMat()) &&
ocl::Image2D::isFormatSupported(CV_32F, 1, false);
if ( use_opencl && ocl_calcOpticalFlowPyrLK(_prevImg, _nextImg, _prevPts, _nextPts, _status, _err, winSize, maxLevel, criteria, flags/*, minEigThreshold*/))
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
Mat prevPtsMat = _prevPts.getMat();
const int derivDepth = DataType<cv::detail::deriv_type>::depth;

View File

@ -1081,7 +1081,10 @@ void cv::calcOpticalFlowFarneback( InputArray _prev0, InputArray _next0,
{
bool use_opencl = ocl::useOpenCL() && _flow0.isUMat();
if( use_opencl && ocl_calcOpticalFlowFarneback(_prev0, _next0, _flow0, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags))
{
CV_IMPL_ADD(CV_IMPL_OCL);
return;
}
Mat prev0 = _prev0.getMat(), next0 = _next0.getMat();
const int min_size = 32;