Merge pull request #2628 from ilya-lavrenov:ipp_error_handling

This commit is contained in:
Andrey Pavlenko 2014-04-18 13:37:34 +04:00 committed by OpenCV Buildbot
commit cb8743f9aa
31 changed files with 562 additions and 209 deletions

View File

@ -560,6 +560,14 @@ namespace cudev
template <typename _Tp> class GpuMat_;
}
namespace ipp
{
CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
int line = 0);
CV_EXPORTS int getIppStatus();
CV_EXPORTS String getIppErrorLocation();
} // ipp
} // cv
#endif //__OPENCV_CORE_BASE_HPP__

View File

@ -218,6 +218,8 @@ CV_EXPORTS void scalarToRawData(const cv::Scalar& s, void* buf, int type, int un
# endif
# define IPP_VERSION_X100 (IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR)
#define setIppErrorStatus() cv::ipp::setIppStatus(-1, CV_Func, __FILE__, __LINE__)
static inline IppiSize ippiSize(int width, int height)
{
IppiSize size = { width, height };

View File

@ -464,6 +464,7 @@ static void add8u( const uchar* src1, size_t step1,
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();
#endif
(vBinOp<uchar, OpAdd<uchar>, IF_SIMD(VAdd<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -483,6 +484,7 @@ static void add16u( const ushort* src1, size_t step1,
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();
#endif
(vBinOp<ushort, OpAdd<ushort>, IF_SIMD(VAdd<ushort>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -495,6 +497,7 @@ static void add16s( const short* src1, size_t step1,
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();
#endif
(vBinOp<short, OpAdd<short>, IF_SIMD(VAdd<short>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -514,6 +517,7 @@ static void add32f( const float* src1, size_t step1,
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();
#endif
(vBinOp32<float, OpAdd<float>, IF_SIMD(VAdd<float>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -533,6 +537,7 @@ static void sub8u( const uchar* src1, size_t step1,
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();
#endif
(vBinOp<uchar, OpSub<uchar>, IF_SIMD(VSub<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -552,6 +557,7 @@ static void sub16u( const ushort* src1, size_t step1,
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();
#endif
(vBinOp<ushort, OpSub<ushort>, IF_SIMD(VSub<ushort>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -564,6 +570,7 @@ static void sub16s( const short* src1, size_t step1,
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();
#endif
(vBinOp<short, OpSub<short>, IF_SIMD(VSub<short>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -583,6 +590,7 @@ static void sub32f( const float* src1, size_t step1,
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();
#endif
(vBinOp32<float, OpSub<float>, IF_SIMD(VSub<float>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -617,6 +625,7 @@ static void max8u( const uchar* src1, size_t step1,
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp<uchar, OpMax<uchar>, IF_SIMD(VMax<uchar>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -648,6 +657,7 @@ static void max16u( const ushort* src1, size_t step1,
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp<ushort, OpMax<ushort>, IF_SIMD(VMax<ushort>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -686,6 +696,7 @@ static void max32f( const float* src1, size_t step1,
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp32<float, OpMax<float>, IF_SIMD(VMax<float>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -717,6 +728,7 @@ static void min8u( const uchar* src1, size_t step1,
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp<uchar, OpMin<uchar>, IF_SIMD(VMin<uchar>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -748,6 +760,7 @@ static void min16u( const ushort* src1, size_t step1,
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp<ushort, OpMin<ushort>, IF_SIMD(VMin<ushort>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -786,6 +799,7 @@ static void min32f( const float* src1, size_t step1,
}
if (i == sz.height)
return;
setIppErrorStatus();
#endif
vBinOp32<float, OpMin<float>, IF_SIMD(VMin<float>)>(src1, step1, src2, step2, dst, step, sz);
}
@ -805,6 +819,7 @@ static void absdiff8u( const uchar* src1, size_t step1,
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();
#endif
(vBinOp<uchar, OpAbsDiff<uchar>, IF_SIMD(VAbsDiff<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -824,6 +839,7 @@ static void absdiff16u( const ushort* src1, size_t step1,
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();
#endif
(vBinOp<ushort, OpAbsDiff<ushort>, IF_SIMD(VAbsDiff<ushort>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -850,6 +866,7 @@ static void absdiff32f( const float* src1, size_t step1,
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();
#endif
(vBinOp32<float, OpAbsDiff<float>, IF_SIMD(VAbsDiff<float>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -870,6 +887,7 @@ static void and8u( const uchar* src1, size_t step1,
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();
#endif
(vBinOp<uchar, OpAnd<uchar>, IF_SIMD(VAnd<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -882,6 +900,7 @@ static void or8u( const uchar* src1, size_t step1,
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();
#endif
(vBinOp<uchar, OpOr<uchar>, IF_SIMD(VOr<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -894,6 +913,7 @@ static void xor8u( const uchar* src1, size_t step1,
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();
#endif
(vBinOp<uchar, OpXor<uchar>, IF_SIMD(VXor<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -906,6 +926,7 @@ static void not8u( const uchar* src1, size_t step1,
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();
#endif
(vBinOp<uchar, OpNot<uchar>, IF_SIMD(VNot<uchar>)>(src1, step1, src2, step2, dst, step, sz));
}
@ -918,7 +939,7 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl
{
int scn = (int)sc.total(), cn = CV_MAT_CN(buftype);
size_t esz = CV_ELEM_SIZE(buftype);
getConvertFunc(sc.depth(), buftype)(sc.data, 0, 0, 0, scbuf, 0, Size(std::min(cn, scn), 1), 0);
getConvertFunc(sc.depth(), buftype)(sc.data, 1, 0, 1, scbuf, 1, Size(std::min(cn, scn), 1), 0);
// unroll the scalar
if( scn < cn )
{
@ -1607,33 +1628,33 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
uchar* dptr = ptrs[2];
if( cvtsrc1 )
{
cvtsrc1( sptr1, 0, 0, 0, buf1, 0, bszn, 0 );
cvtsrc1( sptr1, 1, 0, 1, buf1, 1, bszn, 0 );
sptr1 = buf1;
}
if( ptrs[0] == ptrs[1] )
sptr2 = sptr1;
else if( cvtsrc2 )
{
cvtsrc2( sptr2, 0, 0, 0, buf2, 0, bszn, 0 );
cvtsrc2( sptr2, 1, 0, 1, buf2, 1, bszn, 0 );
sptr2 = buf2;
}
if( !haveMask && !cvtdst )
func( sptr1, 0, sptr2, 0, dptr, 0, bszn, usrdata );
func( sptr1, 1, sptr2, 1, dptr, 1, bszn, usrdata );
else
{
func( sptr1, 0, sptr2, 0, wbuf, 0, bszn, usrdata );
func( sptr1, 1, sptr2, 1, wbuf, 0, bszn, usrdata );
if( !haveMask )
cvtdst( wbuf, 0, 0, 0, dptr, 0, bszn, 0 );
cvtdst( wbuf, 1, 0, 1, dptr, 1, bszn, 0 );
else if( !cvtdst )
{
copymask( wbuf, 0, ptrs[3], 0, dptr, 0, Size(bsz, 1), &dsz );
copymask( wbuf, 1, ptrs[3], 1, dptr, 1, Size(bsz, 1), &dsz );
ptrs[3] += bsz;
}
else
{
cvtdst( wbuf, 0, 0, 0, maskbuf, 0, bszn, 0 );
copymask( maskbuf, 0, ptrs[3], 0, dptr, 0, Size(bsz, 1), &dsz );
cvtdst( wbuf, 1, 0, 1, maskbuf, 1, bszn, 0 );
copymask( maskbuf, 1, ptrs[3], 1, dptr, 1, Size(bsz, 1), &dsz );
ptrs[3] += bsz;
}
}
@ -1674,7 +1695,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
if( cvtsrc1 )
{
cvtsrc1( sptr1, 0, 0, 0, buf1, 0, bszn, 0 );
cvtsrc1( sptr1, 1, 0, 1, buf1, 1, bszn, 0 );
sptr1 = buf1;
}
@ -1682,21 +1703,21 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
std::swap(sptr1, sptr2);
if( !haveMask && !cvtdst )
func( sptr1, 0, sptr2, 0, dptr, 0, bszn, usrdata );
func( sptr1, 1, sptr2, 1, dptr, 1, bszn, usrdata );
else
{
func( sptr1, 0, sptr2, 0, wbuf, 0, bszn, usrdata );
func( sptr1, 1, sptr2, 1, wbuf, 1, bszn, usrdata );
if( !haveMask )
cvtdst( wbuf, 0, 0, 0, dptr, 0, bszn, 0 );
cvtdst( wbuf, 1, 0, 1, dptr, 1, bszn, 0 );
else if( !cvtdst )
{
copymask( wbuf, 0, ptrs[2], 0, dptr, 0, Size(bsz, 1), &dsz );
copymask( wbuf, 1, ptrs[2], 1, dptr, 1, Size(bsz, 1), &dsz );
ptrs[2] += bsz;
}
else
{
cvtdst( wbuf, 0, 0, 0, maskbuf, 0, bszn, 0 );
copymask( maskbuf, 0, ptrs[2], 0, dptr, 0, Size(bsz, 1), &dsz );
cvtdst( wbuf, 1, 0, 1, maskbuf, 1, bszn, 0 );
copymask( maskbuf, 1, ptrs[2], 1, dptr, 1, Size(bsz, 1), &dsz );
ptrs[2] += bsz;
}
}
@ -2390,6 +2411,7 @@ static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t ste
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();
}
#endif
//vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -2473,6 +2495,7 @@ static void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t
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();
}
#endif
cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -2488,6 +2511,7 @@ static void cmp16s(const short* src1, size_t step1, const short* src2, size_t st
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();
}
#endif
//vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -2594,6 +2618,7 @@ static void cmp32f(const float* src1, size_t step1, const float* src2, size_t st
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();
}
#endif
cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
@ -2687,7 +2712,7 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in
else
{
double fval = 0;
getConvertFunc(depth2, CV_64F)(src2.data, 0, 0, 0, (uchar *)&fval, 0, Size(1, 1), 0);
getConvertFunc(depth2, CV_64F)(src2.data, 1, 0, 1, (uchar *)&fval, 1, Size(1, 1), 0);
if( fval < getMinVal(depth1) )
return dst.setTo(Scalar::all(op == CMP_GT || op == CMP_GE || op == CMP_NE ? 255 : 0)), true;
@ -2808,7 +2833,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
else
{
double fval=0;
getConvertFunc(depth2, CV_64F)(src2.data, 0, 0, 0, (uchar*)&fval, 0, Size(1,1), 0);
getConvertFunc(depth2, CV_64F)(src2.data, 1, 0, 1, (uchar*)&fval, 1, Size(1,1), 0);
if( fval < getMinVal(depth1) )
{
dst = Scalar::all(op == CMP_GT || op == CMP_GE || op == CMP_NE ? 255 : 0);
@ -3035,8 +3060,8 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb,
int* iubuf = ilbuf + cn;
BinaryFunc sccvtfunc = getConvertFunc(ldepth, CV_32S);
sccvtfunc(lscalar.data, 0, 0, 0, (uchar*)ilbuf, 0, Size(cn, 1), 0);
sccvtfunc(uscalar.data, 0, 0, 0, (uchar*)iubuf, 0, Size(cn, 1), 0);
sccvtfunc(lscalar.data, 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0);
sccvtfunc(uscalar.data, 1, 0, 1, (uchar*)iubuf, 1, Size(cn, 1), 0);
int minval = cvRound(getMinVal(sdepth)), maxval = cvRound(getMaxVal(sdepth));
for( int k = 0; k < cn; k++ )
@ -3146,8 +3171,8 @@ void cv::inRange(InputArray _src, InputArray _lowerb,
int* iubuf = ilbuf + cn;
BinaryFunc sccvtfunc = getConvertFunc(scdepth, CV_32S);
sccvtfunc(lb.data, 0, 0, 0, (uchar*)ilbuf, 0, Size(cn, 1), 0);
sccvtfunc(ub.data, 0, 0, 0, (uchar*)iubuf, 0, Size(cn, 1), 0);
sccvtfunc(lb.data, 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0);
sccvtfunc(ub.data, 1, 0, 1, (uchar*)iubuf, 1, Size(cn, 1), 0);
int minval = cvRound(getMinVal(depth)), maxval = cvRound(getMaxVal(depth));
for( int k = 0; k < cn; k++ )

View File

@ -1086,6 +1086,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
{ \
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0) \
return; \
setIppErrorStatus(); \
cvt_(src, sstep, dst, dstep, size); \
}
@ -1095,6 +1096,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
{ \
if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0) \
return; \
setIppErrorStatus(); \
cvt_(src, sstep, dst, dstep, size); \
}
#else

View File

@ -574,6 +574,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode )
IppStatus status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, ippiSize(src.cols, src.rows), axis);
if (status >= 0)
return;
setIppErrorStatus();
}
#endif

View File

@ -241,6 +241,7 @@ static void Magnitude_32f(const float* x, const float* y, float* mag, int len)
IppStatus status = ippsMagnitude_32f(x, y, mag, len);
if (status >= 0)
return;
setIppErrorStatus();
#endif
int i = 0;
@ -273,6 +274,7 @@ static void Magnitude_64f(const double* x, const double* y, double* mag, int len
IppStatus status = ippsMagnitude_64f(x, y, mag, len);
if (status >= 0)
return;
setIppErrorStatus();
#endif
int i = 0;
@ -305,6 +307,7 @@ static void InvSqrt_32f(const float* src, float* dst, int len)
#if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY)
if (ippsInvSqrt_32f_A21(src, dst, len) >= 0)
return;
setIppErrorStatus();
#endif
int i = 0;
@ -353,6 +356,7 @@ static void Sqrt_32f(const float* src, float* dst, int len)
#if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY)
if (ippsSqrt_32f_A21(src, dst, len) >= 0)
return;
setIppErrorStatus();
#endif
int i = 0;
@ -386,6 +390,7 @@ static void Sqrt_64f(const double* src, double* dst, int len)
#if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY)
if (ippsSqrt_64f_A50(src, dst, len) >= 0)
return;
setIppErrorStatus();
#endif
int i = 0;
@ -767,6 +772,7 @@ void polarToCart( InputArray src1, InputArray src2,
IppStatus status = ippFunc(Mag.data, Angle.data, X.data, Y.data, static_cast<int>(cn * X.total()));
if (status >= 0)
return;
setIppErrorStatus();
}
#endif
@ -1319,6 +1325,7 @@ static void Exp_32f_ipp(const float *x, float *y, int n)
{
if (0 <= ippsExp_32f_A21(x, y, n))
return;
setIppErrorStatus();
Exp_32f(x, y, n);
}
@ -1326,6 +1333,7 @@ static void Exp_64f_ipp(const double *x, double *y, int n)
{
if (0 <= ippsExp_64f_A50(x, y, n))
return;
setIppErrorStatus();
Exp_64f(x, y, n);
}
@ -1977,6 +1985,7 @@ static void Log_32f_ipp(const float *x, float *y, int n)
{
if (0 <= ippsLn_32f_A21(x, y, n))
return;
setIppErrorStatus();
Log_32f(x, y, n);
}
@ -1984,6 +1993,7 @@ static void Log_64f_ipp(const double *x, double *y, int n)
{
if (0 <= ippsLn_64f_A50(x, y, n))
return;
setIppErrorStatus();
Log_64f(x, y, n);
}
@ -2181,6 +2191,7 @@ void pow( InputArray _src, double power, OutputArray _dst )
if (status >= 0)
return;
setIppErrorStatus();
}
#endif
if (same)
@ -2241,6 +2252,7 @@ void pow( InputArray _src, double power, OutputArray _dst )
if (status >= 0)
return;
setIppErrorStatus();
}
#endif

View File

@ -2223,13 +2223,6 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray
if (src1.isContinuous() && src2.isContinuous() && dst.isContinuous())
{
size_t len = src1.total()*cn;
#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY
if (depth == CV_32F &&
ippmSaxpy_vava_32f((const Ipp32f *)src1.data, (int)src1.step, sizeof(Ipp32f), falpha,
(const Ipp32f *)src2.data, (int)src2.step, sizeof(Ipp32f),
(Ipp32f *)dst.data, (int)dst.step, sizeof(Ipp32f), (int)len, 1) >= 0)
return;
#endif
func(src1.data, src2.data, dst.data, (int)len, palpha);
return;
}
@ -2810,6 +2803,7 @@ static double dotProd_8u(const uchar* src1, const uchar* src2, int len)
src2, (int)(len*sizeof(src2[0])),
ippiSize(len, 1), &r))
return r;
setIppErrorStatus();
#endif
int i = 0;
@ -2870,6 +2864,7 @@ static double dotProd_16u(const ushort* src1, const ushort* src2, int len)
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();
#endif
return dotProd_(src1, src2, len);
}
@ -2880,6 +2875,7 @@ static double dotProd_16s(const short* src1, const short* src2, int len)
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();
#endif
return dotProd_(src1, src2, len);
}
@ -2890,6 +2886,7 @@ static double dotProd_32s(const int* src1, const int* src2, int len)
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();
#endif
return dotProd_(src1, src2, len);
}
@ -2900,6 +2897,7 @@ static double dotProd_32f(const float* src1, const float* src2, int len)
double r = 0;
if (0 <= ippsDotProd_32f64f(src1, src2, len, &r))
return r;
setIppErrorStatus();
#endif
return dotProd_(src1, src2, len);
}
@ -2910,6 +2908,7 @@ static double dotProd_64f(const double* src1, const double* src2, int len)
double r = 0;
if (0 <= ippsDotProd_64f(src1, src2, len, &r))
return r;
setIppErrorStatus();
#endif
return dotProd_(src1, src2, len);
}

View File

@ -3039,8 +3039,12 @@ void cv::transpose( InputArray _src, OutputArray _dst )
type == CV_32FC4 ? (ippiTranspose)ippiTranspose_32f_C4R : 0;
IppiSize roiSize = { src.cols, src.rows };
if (ippFunc != 0 && ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, roiSize) >= 0)
return;
if (ippFunc != 0)
{
if (ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, roiSize) >= 0)
return;
setIppErrorStatus();
}
#endif
if( dst.data == src.data )

View File

@ -579,11 +579,10 @@ cv::Scalar cv::sum( InputArray _src )
{
Scalar sc;
for( int i = 0; i < cn; i++ )
{
sc[i] = res[i];
}
return sc;
}
setIppErrorStatus();
}
}
#endif
@ -714,6 +713,7 @@ int cv::countNonZero( InputArray _src )
if (status >= 0)
return (Ipp32s)src.total() - count;
setIppErrorStatus();
}
#endif
@ -757,9 +757,8 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
{
Ipp64f res;
if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, &res) >= 0 )
{
return Scalar(res);
}
setIppErrorStatus();
}
typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *);
ippiMaskMeanFuncC3 ippFuncC3 =
@ -776,6 +775,7 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
{
return Scalar(res1, res2, res3);
}
setIppErrorStatus();
}
}
else
@ -809,11 +809,10 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
{
Scalar sc;
for( int i = 0; i < cn; i++ )
{
sc[i] = res[i];
}
return sc;
}
setIppErrorStatus();
}
}
}
@ -977,6 +976,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
{
if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, pmean, pstddev) >= 0 )
return;
setIppErrorStatus();
}
typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *, Ipp64f *);
ippiMaskMeanStdDevFuncC3 ippFuncC3 =
@ -990,6 +990,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 &&
ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0 )
return;
setIppErrorStatus();
}
}
else
@ -1006,6 +1007,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
{
if( ippFuncC1(src.data, (int)src.step[0], sz, pmean, pstddev) >= 0 )
return;
setIppErrorStatus();
}
typedef IppStatus (CV_STDCALL* ippiMeanStdDevFuncC3)(const void *, int, IppiSize, int, Ipp64f *, Ipp64f *);
ippiMeanStdDevFuncC3 ippFuncC3 =
@ -1019,6 +1021,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
ippFuncC3(src.data, (int)src.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 &&
ippFuncC3(src.data, (int)src.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0 )
return;
setIppErrorStatus();
}
}
}
@ -1404,6 +1407,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
}
return;
}
setIppErrorStatus();
}
}
else
@ -1436,6 +1440,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
}
return;
}
setIppErrorStatus();
}
}
}
@ -2076,9 +2081,9 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
{
Ipp64f norm;
if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, &norm) >= 0 )
{
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
}
setIppErrorStatus();
}
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
ippiMaskNormFuncC3 ippFuncC3 =
@ -2114,6 +2119,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
0;
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
}
setIppErrorStatus();
}
}
else
@ -2190,6 +2196,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
}
return normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm;
}
setIppErrorStatus();
}
}
}
@ -2430,6 +2437,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
Ipp64f norm;
if( ippFuncC1(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, &norm) >= 0 )
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
setIppErrorStatus();
}
}
else
@ -2459,6 +2467,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
Ipp64f norm;
if( ippFunc(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], sz, &norm, ippAlgHintAccurate) >= 0 )
return (double)norm;
setIppErrorStatus();
}
}
}
@ -2511,6 +2520,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
Ipp64f norm;
if( ippFuncC1(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, &norm) >= 0 )
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
setIppErrorStatus();
}
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC3)(const void *, int, const void *, int, const void *, int, IppiSize, int, Ipp64f *);
ippiMaskNormDiffFuncC3 ippFuncC3 =
@ -2546,6 +2556,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
0;
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
}
setIppErrorStatus();
}
}
else
@ -2622,6 +2633,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
}
return normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm;
}
setIppErrorStatus();
}
}
}

View File

@ -1063,6 +1063,33 @@ TLSStorage::~TLSStorage()
TLSData<CoreTLSData> coreTlsData;
namespace ipp
{
static int ippStatus = 0; // 0 - all is ok, -1 - IPP functions failed
static const char * funcname = NULL, * filename = NULL;
static int linen = 0;
void setIppStatus(int status, const char * const _funcname, const char * const _filename, int _line)
{
ippStatus = status;
funcname = _funcname;
filename = _filename;
linen = _line;
}
int getIppStatus()
{
return ippStatus;
}
String getIppErrorLocation()
{
return format("%s:%d %s", filename ? filename : "", linen, funcname ? funcname : "");
}
} // namespace ipp
} // namespace cv
/* End of file. */

View File

@ -503,6 +503,7 @@ void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _m
if (status >= 0)
return;
setIppErrorStatus();
}
}
#endif
@ -584,6 +585,7 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2,
if (status >= 0)
return;
setIppErrorStatus();
}
}
#endif
@ -663,6 +665,7 @@ void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst,
if (status >= 0)
return;
setIppErrorStatus();
}
}
#endif

View File

@ -59,10 +59,14 @@ static bool ippCanny(const Mat& _src, Mat& _dst, float low, float high)
int size = 0, size1 = 0;
IppiSize roi = { _src.cols, _src.rows };
ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size);
ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1);
if (ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size) < 0)
return false;
if (ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1) < 0)
return false;
size = std::max(size, size1);
ippiCannyGetSize(roi, &size1);
if (ippiCannyGetSize(roi, &size1) < 0)
return false;
size = std::max(size, size1);
AutoBuffer<uchar> buf(size + 64);
@ -286,9 +290,12 @@ void cv::Canny( InputArray _src, OutputArray _dst,
#endif
#ifdef USE_IPP_CANNY
if( aperture_size == 3 && !L2gradient && 1 == cn &&
ippCanny(src, dst, (float)low_thresh, (float)high_thresh) )
return;
if( aperture_size == 3 && !L2gradient && 1 == cn )
{
if (ippCanny(src, dst, (float)low_thresh, (float)high_thresh))
return;
setIppErrorStatus();
}
#endif
Mat dx(src.rows, src.cols, CV_16SC(cn));

View File

@ -310,8 +310,8 @@ static ippiReorderFunc ippiSwapChannelsC4RTab[] =
static ippiColor2GrayFunc ippiColor2GrayC3Tab[] =
{
/*(ippiColor2GrayFunc)ippiColorToGray_8u_C3C1R*/ 0, 0, /*(ippiColor2GrayFunc)ippiColorToGray_16u_C3C1R*/ 0, 0,
0, /*(ippiColor2GrayFunc)ippiColorToGray_32f_C3C1R*/ 0, 0, 0
(ippiColor2GrayFunc)ippiColorToGray_8u_C3C1R, 0, (ippiColor2GrayFunc)ippiColorToGray_16u_C3C1R, 0,
0, (ippiColor2GrayFunc)ippiColorToGray_32f_C3C1R, 0, 0
};
static ippiColor2GrayFunc ippiColor2GrayC4Tab[] =
@ -341,18 +341,18 @@ static ippiGeneralFunc ippiCopyP3C3RTab[] =
static ippiGeneralFunc ippiRGB2XYZTab[] =
{
(ippiGeneralFunc)ippiRGBToXYZ_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToXYZ_16u_C3R, 0,
0, /*(ippiGeneralFunc)ippiRGBToXYZ_32f_C3R*/ 0, 0, 0
0, (ippiGeneralFunc)ippiRGBToXYZ_32f_C3R, 0, 0
};
static ippiGeneralFunc ippiXYZ2RGBTab[] =
{
(ippiGeneralFunc)ippiXYZToRGB_8u_C3R, 0, (ippiGeneralFunc)ippiXYZToRGB_16u_C3R, 0,
0, /*(ippiGeneralFunc)ippiXYZToRGB_32f_C3R*/ 0, 0, 0
0, (ippiGeneralFunc)ippiXYZToRGB_32f_C3R, 0, 0
};
static ippiGeneralFunc ippiRGB2HSVTab[] =
{
/*(ippiGeneralFunc)ippiRGBToHSV_8u_C3R*/ 0, 0, /*(ippiGeneralFunc)ippiRGBToHSV_16u_C3R*/ 0, 0,
(ippiGeneralFunc)ippiRGBToHSV_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToHSV_16u_C3R, 0,
0, 0, 0, 0
};
@ -374,7 +374,7 @@ static ippiGeneralFunc ippiHLS2RGBTab[] =
0, (ippiGeneralFunc)ippiHLSToRGB_32f_C3R, 0, 0
};
#if !defined(HAVE_IPP_ICV_ONLY)
#if !defined(HAVE_IPP_ICV_ONLY) && 0
static ippiGeneralFunc ippiRGBToLUVTab[] =
{
(ippiGeneralFunc)ippiRGBToLUV_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToLUV_16u_C3R, 0,
@ -3288,32 +3288,38 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
if ( CvtColorIPPLoop(src, dst, IPPReorderFunctor(ippiSwapChannelsC3C4RTab[depth], 0, 1, 2)) )
return;
setIppErrorStatus();
}
else if( code == CV_BGRA2BGR )
{
if ( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiCopyAC4C3RTab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_BGR2RGBA )
{
if( CvtColorIPPLoop(src, dst, IPPReorderFunctor(ippiSwapChannelsC3C4RTab[depth], 2, 1, 0)) )
return;
setIppErrorStatus();
}
else if( code == CV_RGBA2BGR )
{
if( CvtColorIPPLoop(src, dst, IPPReorderFunctor(ippiSwapChannelsC4C3RTab[depth], 2, 1, 0)) )
return;
setIppErrorStatus();
}
else if( code == CV_RGB2BGR )
{
if( CvtColorIPPLoopCopy(src, dst, IPPReorderFunctor(ippiSwapChannelsC3RTab[depth], 2, 1, 0)) )
return;
setIppErrorStatus();
}
#if !defined(HAVE_IPP_ICV_ONLY) && (IPP_VERSION_X100 >= 801)
else if( code == CV_RGBA2BGRA )
{
if( CvtColorIPPLoopCopy(src, dst, IPPReorderFunctor(ippiSwapChannelsC4RTab[depth], 2, 1, 0)) )
return;
setIppErrorStatus();
}
#endif
#endif
@ -3339,28 +3345,36 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
#if defined HAVE_IPP && !defined(HAVE_IPP_ICV_ONLY)
CV_SUPPRESS_DEPRECATED_START
#if 0
if (code == CV_BGR2BGR565 && scn == 3)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R)))
return;
setIppErrorStatus();
}
else if (code == CV_BGRA2BGR565)
else
#endif
if (code == CV_BGRA2BGR565 && scn == 4)
{
if (CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
(ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 0, 1, 2, depth)))
if (CvtColorIPPLoopCopy(src, dst,
IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
(ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 0, 1, 2, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_RGB2BGR565)
else if (code == CV_RGB2BGR565 && scn == 3)
{
if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
(ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if (code == CV_RGBA2BGR565)
else if (code == CV_RGBA2BGR565 && scn == 4)
{
if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
(ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
CV_SUPPRESS_DEPRECATED_END
#endif
@ -3388,28 +3402,32 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
#if defined HAVE_IPP && !defined(HAVE_IPP_ICV_ONLY)
CV_SUPPRESS_DEPRECATED_START
if (code == CV_BGR5652BGR)
if (code == CV_BGR5652BGR && dcn == 3)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R)))
return;
setIppErrorStatus();
}
else if (code == CV_BGR5652RGB)
else if (code == CV_BGR5652RGB && dcn == 3)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R,
ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
if (code == CV_BGR5652BGRA)
else if (code == CV_BGR5652BGRA && dcn == 4)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R,
ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_BGR5652RGBA)
else if (code == CV_BGR5652RGBA && dcn == 4)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R,
ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
CV_SUPPRESS_DEPRECATED_END
#endif
@ -3428,25 +3446,29 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
dst = _dst.getMat();
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if( code == CV_BGR2GRAY )
if( code == CV_BGR2GRAY && depth == CV_32F )
{
if( CvtColorIPPLoop(src, dst, IPPColor2GrayFunctor(ippiColor2GrayC3Tab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_RGB2GRAY )
else if( code == CV_RGB2GRAY && depth == CV_32F )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGB2GrayC3Tab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_BGRA2GRAY )
else if( code == CV_BGRA2GRAY && depth == CV_32F )
{
if( CvtColorIPPLoop(src, dst, IPPColor2GrayFunctor(ippiColor2GrayC4Tab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_RGBA2GRAY )
else if( code == CV_RGBA2GRAY && depth == CV_32F )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGB2GrayC4Tab[depth])) )
return;
setIppErrorStatus();
}
#endif
@ -3484,11 +3506,13 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
if( CvtColorIPPLoop(src, dst, IPPGray2BGRFunctor(ippiCopyP3C3RTab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_GRAY2BGRA )
{
if( CvtColorIPPLoop(src, dst, IPPGray2BGRAFunctor(ippiCopyP3C3RTab[depth], ippiSwapChannelsC3C4RTab[depth], depth)) )
return;
setIppErrorStatus();
}
#endif
@ -3532,24 +3556,28 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiRGBToYUV_8u_C3R)))
return;
setIppErrorStatus();
}
else if (code == CV_BGR2YUV && scn == 3 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
(ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_RGB2YUV && scn == 4 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
(ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 0, 1, 2, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_BGR2YUV && scn == 4 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
(ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
#endif
@ -3587,24 +3615,28 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R)))
return;
setIppErrorStatus();
}
else if (code == CV_YUV2BGR && dcn == 3 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R,
ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_YUV2RGB && dcn == 4 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R,
ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_YUV2BGR && dcn == 4 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R,
ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
#endif
@ -3625,25 +3657,29 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
dst = _dst.getMat();
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if( code == CV_BGR2XYZ && scn == 3 )
if( code == CV_BGR2XYZ && scn == 3 && depth != CV_32F )
{
if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_BGR2XYZ && scn == 4 )
else if( code == CV_BGR2XYZ && scn == 4 && depth != CV_32F )
{
if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_RGB2XYZ && scn == 3 )
else if( code == CV_RGB2XYZ && scn == 3 && depth != CV_32F )
{
if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiRGB2XYZTab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_RGB2XYZ && scn == 4 )
else if( code == CV_RGB2XYZ && scn == 4 && depth != CV_32F )
{
if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 0, 1, 2, depth)) )
return;
setIppErrorStatus();
}
#endif
@ -3664,25 +3700,29 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
dst = _dst.getMat();
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if( code == CV_XYZ2BGR && dcn == 3 )
if( code == CV_XYZ2BGR && dcn == 3 && depth != CV_32F )
{
if( CvtColorIPPLoopCopy(src, dst, IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_XYZ2BGR && dcn == 4 )
else if( code == CV_XYZ2BGR && dcn == 4 && depth != CV_32F )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
if( code == CV_XYZ2RGB && dcn == 3 )
if( code == CV_XYZ2RGB && dcn == 3 && depth != CV_32F )
{
if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiXYZ2RGBTab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_XYZ2RGB && dcn == 4 )
else if( code == CV_XYZ2RGB && dcn == 4 && depth != CV_32F )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
return;
setIppErrorStatus();
}
#endif
@ -3713,41 +3753,49 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2HSVTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_BGR2HSV_FULL && scn == 4 )
{
if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HSVTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_RGB2HSV_FULL && scn == 3 )
else if( code == CV_RGB2HSV_FULL && scn == 3 && depth == CV_16U )
{
if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiRGB2HSVTab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_RGB2HSV_FULL && scn == 4 )
{
if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HSVTab[depth], 0, 1, 2, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_BGR2HLS_FULL && scn == 3 )
{
if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2HLSTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_BGR2HLS_FULL && scn == 4 )
{
if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HLSTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_RGB2HLS_FULL && scn == 3 )
{
if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiRGB2HLSTab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_RGB2HLS_FULL && scn == 4 )
{
if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HLSTab[depth], 0, 1, 2, depth)) )
return;
setIppErrorStatus();
}
}
#endif
@ -3794,41 +3842,49 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
if( CvtColorIPPLoopCopy(src, dst, IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_HSV2BGR_FULL && dcn == 4 )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_HSV2RGB_FULL && dcn == 3 )
{
if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiHSV2RGBTab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_HSV2RGB_FULL && dcn == 4 )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_HLS2BGR_FULL && dcn == 3 )
{
if( CvtColorIPPLoopCopy(src, dst, IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_HLS2BGR_FULL && dcn == 4 )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_HLS2RGB_FULL && dcn == 3 )
{
if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiHLS2RGBTab[depth])) )
return;
setIppErrorStatus();
}
else if( code == CV_HLS2RGB_FULL && dcn == 4 )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
return;
setIppErrorStatus();
}
}
#endif
@ -3864,52 +3920,65 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
dst = _dst.getMat();
#if defined HAVE_IPP && !defined(HAVE_IPP_ICV_ONLY)
#if 0
if (code == CV_LBGR2Lab && scn == 3 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiBGRToLab_8u_C3R)))
return;
setIppErrorStatus();
}
else if (code == CV_LBGR2Lab && scn == 4 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
(ippiGeneralFunc)ippiBGRToLab_8u_C3R, 0, 1, 2, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_LRGB2Lab && scn == 3 && depth == CV_8U)
else
#endif
if (code == CV_LRGB2Lab && scn == 3 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
(ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_LRGB2Lab && scn == 4 && depth == CV_8U)
{
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
(ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
#if 0
else if (code == CV_LRGB2Luv && scn == 3)
{
if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGBToLUVTab[depth])))
return;
setIppErrorStatus();
}
else if (code == CV_LRGB2Luv && scn == 4)
{
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
ippiRGBToLUVTab[depth], 0, 1, 2, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_LBGR2Luv && scn == 3)
{
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth],
ippiRGBToLUVTab[depth], 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
else if (code == CV_LBGR2Luv && scn == 4)
{
if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth],
ippiRGBToLUVTab[depth], 2, 1, 0, depth)))
return;
setIppErrorStatus();
}
#endif
#endif
if( code == CV_BGR2Lab || code == CV_RGB2Lab ||
@ -3949,26 +4018,29 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R)) )
return;
setIppErrorStatus();
}
else if( code == CV_Lab2LBGR && dcn == 4 && depth == CV_8U )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R,
ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) )
return;
setIppErrorStatus();
}
if( code == CV_Lab2LRGB && dcn == 3 && depth == CV_8U )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R,
ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
else if( code == CV_Lab2LRGB && dcn == 4 && depth == CV_8U )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R,
ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
return;
setIppErrorStatus();
}
#endif
if( code == CV_Luv2LRGB && dcn == 3 )
{
if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiLUVToRGBTab[depth])) )
@ -3992,6 +4064,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) )
return;
}
#endif
#endif
if( code == CV_Lab2BGR || code == CV_Lab2RGB ||
@ -4194,6 +4267,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
#if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY)
if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiAlphaPremul_8u_AC4R)))
return;
setIppErrorStatus();
#endif
CvtColorLoop(src, dst, RGBA2mRGBA<uchar>());
}

View File

@ -201,7 +201,7 @@ static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy,
switch(src.type())
{
case CV_8U:
case CV_8UC1:
{
if(scale != 1)
return false;
@ -232,14 +232,14 @@ static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy,
return false;
}
}
case CV_32F:
case CV_32FC1:
#if defined(HAVE_IPP_ICV_ONLY) // N/A: ippiMulC_32f_C1R
return false;
#else
{
switch(dst.type())
{
case CV_32F:
case CV_32FC1:
{
if ((dx == 1) && (dy == 0))
{
@ -289,67 +289,64 @@ static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy,
static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int ksize, double scale)
{
int bufSize = 0;
int stype = src.type(), dtype = dst.type(), bufSize = 0;
cv::AutoBuffer<char> buffer;
if (ksize == 3 || ksize == 5)
{
if ( ddepth < 0 )
ddepth = src.depth();
if (src.type() == CV_8U && dst.type() == CV_16S && scale == 1)
if (stype == CV_8UC1 && dtype == CV_16SC1 && scale == 1)
{
if ((dx == 1) && (dy == 0))
if (dx == 1 && dy == 0)
{
if (0 > ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false;
buffer.allocate(bufSize);
return (0 <= ippiFilterSobelNegVertBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
return 0 <= ippiFilterSobelNegVertBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
(Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
ippBorderRepl, 0, (Ipp8u*)(char*)buffer);
}
if ((dx == 0) && (dy == 1))
if (dx == 0 && dy == 1)
{
if (0 > ippiFilterSobelHorizGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false;
buffer.allocate(bufSize);
return (0 <= ippiFilterSobelHorizBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
return 0 <= ippiFilterSobelHorizBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
(Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
ippBorderRepl, 0, (Ipp8u*)(char*)buffer);
}
if ((dx == 2) && (dy == 0))
if (dx == 2 && dy == 0)
{
if (0 > ippiFilterSobelVertSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false;
buffer.allocate(bufSize);
return (0 <= ippiFilterSobelVertSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
return 0 <= ippiFilterSobelVertSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
(Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
ippBorderRepl, 0, (Ipp8u*)(char*)buffer);
}
if ((dx == 0) && (dy == 2))
if (dx == 0 && dy == 2)
{
if (0 > ippiFilterSobelHorizSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false;
buffer.allocate(bufSize);
return (0 <= ippiFilterSobelHorizSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
return 0 <= ippiFilterSobelHorizSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step,
(Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),
ippBorderRepl, 0, (Ipp8u*)(char*)buffer));
ippBorderRepl, 0, (Ipp8u*)(char*)buffer);
}
}
if (src.type() == CV_32F && dst.type() == CV_32F)
if (stype == CV_32FC1 && dtype == CV_32FC1)
{
#if defined(HAVE_IPP_ICV_ONLY) // N/A: ippiMulC_32f_C1R
return false;
#else
#if 0
if ((dx == 1) && (dy == 0))
if (dx == 1 && dy == 0)
{
if (0 > ippiFilterSobelNegVertGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), &bufSize))
return false;
@ -366,7 +363,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
return true;
}
if ((dx == 0) && (dy == 1))
if (dx == 0 && dy == 1)
{
if (0 > ippiFilterSobelHorizGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false;
@ -384,7 +381,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
}
#endif
if((dx == 2) && (dy == 0))
if(dx == 2 && dy == 0)
{
if (0 > ippiFilterSobelVertSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false;
@ -401,7 +398,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
return true;
}
if((dx == 0) && (dy == 2))
if(dx == 0 && dy == 2)
{
if (0 > ippiFilterSobelHorizSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false;
@ -422,7 +419,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
}
}
if(ksize <= 0)
if (ksize <= 0)
return IPPDerivScharr(src, dst, ddepth, dx, dy, scale);
return false;
}
@ -437,7 +434,8 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype);
if (ddepth < 0)
ddepth = sdepth;
_dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) );
int dtype = CV_MAKE_TYPE(ddepth, cn);
_dst.create( _src.size(), dtype );
#ifdef HAVE_TEGRA_OPTIMIZATION
if (scale == 1.0 && delta == 0)
@ -451,7 +449,8 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
#endif
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if(dx < 3 && dy < 3 && cn == 1 && borderType == BORDER_REPLICATE)
if (dx < 3 && dy < 3 && cn == 1 && borderType == BORDER_REPLICATE &&
((stype == CV_8UC1 && dtype == CV_16SC1) || (stype == CV_32FC1 && dtype == CV_32FC1)))
{
Mat src = _src.getMat(), dst = _dst.getMat();
if (IPPDeriv(src, dst, ddepth, dx, dy, ksize,scale))
@ -481,7 +480,8 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype);
if (ddepth < 0)
ddepth = sdepth;
_dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) );
int dtype = CV_MAKETYPE(ddepth, cn);
_dst.create( _src.size(), dtype );
#ifdef HAVE_TEGRA_OPTIMIZATION
if (scale == 1.0 && delta == 0)
@ -493,11 +493,13 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
#endif
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if(dx < 2 && dy < 2 && _src.channels() == 1 && borderType == 1)
if(dx < 2 && dy < 2 && borderType == BORDER_REPLICATE &&
((stype == CV_8UC1 && dtype == CV_16SC1) || (stype == CV_32FC1 && dtype == CV_32FC1)))
{
Mat src = _src.getMat(), dst = _dst.getMat();
if(IPPDerivScharr(src, dst, ddepth, dx, dy, scale))
return;
setIppErrorStatus();
}
#endif
int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
@ -630,6 +632,7 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
if (status >= 0)
return;
setIppErrorStatus();
}
}
#undef IPP_FILTER_LAPLACIAN

View File

@ -752,6 +752,7 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe
src.ptr<uchar>(), (int)src.step,
dst.ptr<float>(), (int)dst.step, roi, _mask) >= 0 )
return;
setIppErrorStatus();
}
#endif
Mat zpix = src == 0;

View File

@ -1488,7 +1488,10 @@ private:
ippBorderRepl, borderValue[0], bufptr) < 0) ||
(cn == 3 && ippiFilterRowBorderPipeline_32f_C3R(src, step, &dst, roisz, _kx, _ksize, 0,
ippBorderRepl, borderValue, bufptr) < 0))
{
setIppErrorStatus();
return 0;
}
return width - _ksize + 1;
}
#endif

View File

@ -1255,6 +1255,7 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels,
ihist.convertTo(hist, CV_32F);
return;
}
setIppErrorStatus();
}
#endif

View File

@ -1876,19 +1876,18 @@ static int computeResizeAreaTab( int ssize, int dsize, int cn, double scale, Dec
return k;
}
#define CHECK_IPP_FUNC(FUNC) if( FUNC==0 ) { *ok = false; return;}
#define CHECK_IPP_STATUS(STATUS) if( STATUS!=ippStsNoErr ) { *ok = false; return;}
#define CHECK_IPP_STATUS(STATUS) if (STATUS != 0) { *ok = false; return; }
#define SET_IPP_RESIZE_LINEAR_FUNC_PTR(TYPE, CN) \
func = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; CHECK_IPP_FUNC(func);\
func = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; \
CHECK_IPP_STATUS(ippiResizeGetSize_##TYPE(srcSize, dstSize, (IppiInterpolationType)mode, 0, &specSize, &initSize));\
specBuf.allocate(specSize);\
pSpec = (uchar*)specBuf;\
CHECK_IPP_STATUS(ippiResizeLinearInit_##TYPE(srcSize, dstSize, (IppiResizeSpec_32f*)pSpec));
#define SET_IPP_RESIZE_LINEAR_FUNC_64_PTR(TYPE, CN) \
if (mode==(int)ippCubic) { *ok = false; return;}\
func = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; CHECK_IPP_FUNC(func);\
if (mode == (int)ippCubic) { *ok = false; return; } \
func = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; \
CHECK_IPP_STATUS(ippiResizeGetSize_##TYPE(srcSize, dstSize, (IppiInterpolationType)mode, 0, &specSize, &initSize));\
specBuf.allocate(specSize);\
pSpec = (uchar*)specBuf;\
@ -1897,19 +1896,19 @@ static int computeResizeAreaTab( int ssize, int dsize, int cn, double scale, Dec
getSrcOffsetFunc = (ippiResizeGetSrcOffset) ippiResizeGetBufferSize_##TYPE;
#define SET_IPP_RESIZE_CUBIC_FUNC_PTR(TYPE, CN) \
func = (ippiResizeFunc)ippiResizeCubic_##TYPE##_##CN##R; CHECK_IPP_FUNC(func);\
func = (ippiResizeFunc)ippiResizeCubic_##TYPE##_##CN##R; \
CHECK_IPP_STATUS(ippiResizeGetSize_##TYPE(srcSize, dstSize, (IppiInterpolationType)mode, 0, &specSize, &initSize));\
specBuf.allocate(specSize);\
pSpec = (uchar*)specBuf;\
AutoBuffer<uchar> buf(initSize);\
uchar* pInit = (uchar*)buf;\
CHECK_IPP_STATUS(ippiResizeCubicInit_##TYPE(srcSize, dstSize, 0.f, 0.75f, (IppiResizeSpec_32f*)pSpec, pInit));
CHECK_IPP_STATUS(ippiResizeCubicInit_##TYPE(srcSize, dstSize, 0.f, 0.75f, (IppiResizeSpec_32f*)pSpec, pInit));
#define SET_IPP_RESIZE_PTR(TYPE, CN) \
if (mode == (int)ippLinear) { SET_IPP_RESIZE_LINEAR_FUNC_PTR(TYPE, CN);}\
else if (mode == (int)ippCubic) { SET_IPP_RESIZE_CUBIC_FUNC_PTR(TYPE, CN);}\
else { *ok = false; return;}\
getBufferSizeFunc = (ippiResizeGetBufferSize)ippiResizeGetBufferSize_##TYPE;\
if (mode == (int)ippLinear) { SET_IPP_RESIZE_LINEAR_FUNC_PTR(TYPE, CN);} \
else if (mode == (int)ippCubic) { SET_IPP_RESIZE_CUBIC_FUNC_PTR(TYPE, CN);} \
else { *ok = false; return; } \
getBufferSizeFunc = (ippiResizeGetBufferSize)ippiResizeGetBufferSize_##TYPE; \
getSrcOffsetFunc = (ippiResizeGetSrcOffset)ippiResizeGetSrcOffset_##TYPE;
#if !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 701
@ -2392,29 +2391,26 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
return;
#endif
int depth = src.depth(), cn = src.channels();
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
double scale_x = 1./inv_scale_x, scale_y = 1./inv_scale_y;
int k, sx, sy, dx, dy;
#if !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 701
#define IPP_RESIZE_EPS 1.e-10
#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))
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))
{
int mode = 0;
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) &&
if( mode >= 0 && (cn == 1 || cn == 3 || cn == 4) &&
(depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F ||
(depth == CV_64F && mode == ippLinear)))
{
@ -2424,6 +2420,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
if( ok )
return;
setIppErrorStatus();
}
}
#undef IPP_RESIZE_EPS
@ -4281,6 +4278,7 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
if( ok )
return;
setIppErrorStatus();
}
#endif
*/
@ -4524,6 +4522,7 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
if( ok )
return;
setIppErrorStatus();
}
#endif
*/

View File

@ -444,19 +444,15 @@ cv::Moments cv::moments( InputArray _src, bool binary )
MomentsInTileFunc func = 0;
uchar nzbuf[TILE_SIZE*TILE_SIZE];
Moments m;
int type = _src.type();
int depth = CV_MAT_DEPTH( type );
int cn = CV_MAT_CN( type );
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
Size size = _src.size();
if( size.width <= 0 || size.height <= 0 )
return m;
#ifdef HAVE_OPENCL
if( ocl::useOpenCL() && type == CV_8UC1 && !binary &&
_src.isUMat() && ocl_moments(_src, m) )
;
else
if( !(ocl::useOpenCL() && type == CV_8UC1 && !binary &&
_src.isUMat() && ocl_moments(_src, m)) )
#endif
{
Mat mat = _src.getMat();
@ -469,56 +465,61 @@ cv::Moments cv::moments( InputArray _src, bool binary )
#if IPP_VERSION_X100 >= 801 && !defined HAVE_IPP_ICV_ONLY
if (!binary)
{
IppiSize roi = {mat.cols, mat.rows};
IppiMomentState_64f *moment;
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 (0 <= ippiMomentInitAlloc_64f(&moment, ippAlgHintAccurate))
if (ippiMomentInitAlloc_64f(&moment, ippAlgHintAccurate) >= 0)
{
IppStatus sts = (IppStatus)(-1);
if (depth == CV_8U)
sts = ippiMoments64f_8u_C1R((const Ipp8u *)mat.data, (int)mat.step, roi, moment);
else if( depth == CV_16U )
sts = ippiMoments64f_16u_C1R((const Ipp16u *)mat.data, (int)mat.step, roi, moment);
else if( depth == CV_32F )
sts = ippiMoments64f_32f_C1R((const Ipp32f *)mat.data, (int)mat.step, roi, moment);
if (0 <= sts)
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);
return m;
}
setIppErrorStatus();
}
ippiMomentFree_64f(moment);
}
else
setIppErrorStatus();
CV_SUPPRESS_DEPRECATED_END
}
#endif

View File

@ -1269,10 +1269,13 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
int borderType, const Scalar &borderValue)
{
Mat src = _src.getMat(), kernel = _kernel;
if( !( src.depth() == CV_8U || src.depth() == CV_32F ) || ( iterations > 1 ) ||
int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
if( !( depth == CV_8U || depth == CV_32F ) || !(cn == 1 || cn == 3 || cn == 4) ||
!( borderType == cv::BORDER_REPLICATE || (borderType == cv::BORDER_CONSTANT && borderValue == morphologyDefaultBorderValue()) )
|| !( op == MORPH_DILATE || op == MORPH_ERODE) )
return false;
if( borderType == cv::BORDER_CONSTANT && kernel.data )
{
int x, y;
@ -1331,7 +1334,10 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
if( iterations > 1 )
return false;
return IPPMorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel );
if (IPPMorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel ))
return true;
return false;
}
#endif

View File

@ -390,9 +390,13 @@ void cv::getRectSubPix( InputArray _image, Size patchSize, Point2f center,
srctype == CV_8UC1 && ddepth == CV_32F ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_8u32f_C1R :
srctype == CV_32FC1 && ddepth == CV_32F ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_32f_C1R : 0;
if( ippfunc && ippfunc(image.data, (int)image.step, src_size, patch.data,
(int)patch.step, win_size, icenter, &minpt, &maxpt) >= 0 )
return;
if( ippfunc)
{
if (ippfunc(image.data, (int)image.step, src_size, patch.data,
(int)patch.step, win_size, icenter, &minpt, &maxpt) >= 0 )
return;
setIppErrorStatus();
}
#endif
if( depth == CV_8U && ddepth == CV_8U )

View File

@ -867,11 +867,11 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
ippAnchor.y = ksize.height / 2 - (ksize.height % 2 == 0 ? 1 : 0);
if (normalize && !src.isSubmatrix() && ddepth == sdepth &&
(ippBorderType == BORDER_REPLICATE || ippBorderType == BORDER_CONSTANT) &&
ocvAnchor == ippAnchor )
(/*ippBorderType == BORDER_REPLICATE ||*/ /* returns ippStsStepErr: Step value is not valid */
ippBorderType == BORDER_CONSTANT) && ocvAnchor == ippAnchor )
{
Ipp32s bufSize;
IppiSize roiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize.width, ksize.height);
Ipp32s bufSize = 0;
IppiSize roiSize = { dst.cols, dst.rows }, maskSize = { ksize.width, ksize.height };
#define IPP_FILTER_BOX_BORDER(ippType, ippDataType, flavor) \
do \
@ -880,14 +880,16 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
{ \
Ipp8u * buffer = ippsMalloc_8u(bufSize); \
ippType borderValue[4] = { 0, 0, 0, 0 }; \
ippBorderType = ippBorderType == BORDER_CONSTANT ? ippBorderConst : ippBorderType == BORDER_REPLICATE ? ippBorderRepl : -1; \
CV_Assert(ippBorderType >= 0); \
IppStatus status = ippiFilterBoxBorder_##flavor((ippType *)src.data, (int)src.step, (ippType *)dst.data, (int)dst.step, roiSize, maskSize, \
ippBorderType = ippBorderType == BORDER_CONSTANT ? ippBorderConst : ippBorderRepl; \
IppStatus status = ippiFilterBoxBorder_##flavor((const ippType *)src.data, (int)src.step, (ippType *)dst.data, \
(int)dst.step, roiSize, maskSize, \
(IppiBorderType)ippBorderType, borderValue, buffer); \
ippsFree(buffer); \
printf("%s %d %d\n", ippGetStatusString(status), (int)src.step, (int)dst.step); \
if (status >= 0) \
return; \
} \
setIppErrorStatus(); \
} while ((void)0, 0)
if (stype == CV_8UC1)
@ -1193,6 +1195,7 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
return;
}
}
setIppErrorStatus();
}
#endif
@ -2033,6 +2036,7 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize )
if (status >= 0) \
return; \
} \
setIppErrorStatus(); \
} \
while ((void)0, 0)
@ -2433,6 +2437,7 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
parallel_for_(Range(0, dst.rows), body, dst.total()/(double)(1<<16));
if( ok )
return;
setIppErrorStatus();
}
#endif

View File

@ -393,6 +393,7 @@ void cv::integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, Output
}
if (0 <= status)
return;
setIppErrorStatus();
}
#endif

View File

@ -347,9 +347,6 @@ typedef IppStatus (CV_STDCALL * ippimatchTemplate)(const void*, int, IppiSize, c
static bool ipp_crossCorr(const Mat& src, const Mat& tpl, Mat& dst)
{
if (src.channels()!= 1)
return false;
IppStatus status;
IppiSize srcRoiSize = {src.cols,src.rows};
@ -383,9 +380,6 @@ static bool ipp_crossCorr(const Mat& src, const Mat& tpl, Mat& dst)
static bool ipp_sqrDistance(const Mat& src, const Mat& tpl, Mat& dst)
{
if (src.channels()!= 1)
return false;
IppStatus status;
IppiSize srcRoiSize = {src.cols,src.rows};
@ -607,8 +601,9 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, int method )
{
int type = _img.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
CV_Assert( CV_TM_SQDIFF <= method && method <= CV_TM_CCOEFF_NORMED );
CV_Assert( (_img.depth() == CV_8U || _img.depth() == CV_32F) && _img.type() == _templ.type() && _img.dims() <= 2 );
CV_Assert( (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 );
bool needswap = _img.size().height < _templ.size().height || _img.size().width < _templ.size().width;
if (needswap)
@ -639,14 +634,24 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
#endif
#if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7 && !defined HAVE_IPP_ICV_ONLY
if (method == CV_TM_SQDIFF && ipp_sqrDistance(img, templ, result))
return;
if (method == CV_TM_SQDIFF && cn == 1)
{
if (ipp_sqrDistance(img, templ, result))
return;
setIppErrorStatus();
}
#endif
int cn = img.channels();
#if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7 && !defined HAVE_IPP_ICV_ONLY
if (!ipp_crossCorr(img, templ, result))
if (cn == 1)
{
if (!ipp_crossCorr(img, templ, result))
{
setIppErrorStatus();
crossCorr( img, templ, result, result.size(), result.type(), Point(0,0), 0, 0);
}
}
else
#endif
crossCorr( img, templ, result, result.size(), result.type(), Point(0,0), 0, 0);

View File

@ -75,14 +75,17 @@ thresh_8u( const Mat& _src, Mat& _dst, uchar thresh, uchar maxval, int type )
case THRESH_TRUNC:
if (0 <= ippiThreshold_GT_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh))
return;
setIppErrorStatus();
break;
case THRESH_TOZERO:
if (0 <= ippiThreshold_LTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh+1, 0))
return;
setIppErrorStatus();
break;
case THRESH_TOZERO_INV:
if (0 <= ippiThreshold_GTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh, 0))
return;
setIppErrorStatus();
break;
}
#endif
@ -313,14 +316,17 @@ thresh_16s( const Mat& _src, Mat& _dst, short thresh, short maxval, int type )
case THRESH_TRUNC:
if (0 <= ippiThreshold_GT_16s_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_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh+1, 0))
return;
setIppErrorStatus();
break;
case THRESH_TOZERO_INV:
if (0 <= ippiThreshold_GTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0))
return;
setIppErrorStatus();
break;
}
#endif
@ -504,14 +510,17 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int 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))
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;
}
#endif

View File

@ -175,17 +175,25 @@ OCL_TEST_P(CvtColor, XYZ2BGRA) { performTest(3, 4, CVTCODE(XYZ2BGR), IPP_EPS); }
// RGB <-> HSV
#if IPP_VERSION_X100 > 0
#define IPP_EPS depth <= CV_32S ? 1 : 4e-5
#else
#define IPP_EPS 1e-3
#endif
typedef CvtColor CvtColor8u32f;
OCL_TEST_P(CvtColor8u32f, RGB2HSV) { performTest(3, 3, CVTCODE(RGB2HSV)); }
OCL_TEST_P(CvtColor8u32f, BGR2HSV) { performTest(3, 3, CVTCODE(BGR2HSV)); }
OCL_TEST_P(CvtColor8u32f, RGBA2HSV) { performTest(4, 3, CVTCODE(RGB2HSV)); }
OCL_TEST_P(CvtColor8u32f, BGRA2HSV) { performTest(4, 3, CVTCODE(BGR2HSV)); }
OCL_TEST_P(CvtColor8u32f, RGB2HSV) { performTest(3, 3, CVTCODE(RGB2HSV), IPP_EPS); }
OCL_TEST_P(CvtColor8u32f, BGR2HSV) { performTest(3, 3, CVTCODE(BGR2HSV), IPP_EPS); }
OCL_TEST_P(CvtColor8u32f, RGBA2HSV) { performTest(4, 3, CVTCODE(RGB2HSV), IPP_EPS); }
OCL_TEST_P(CvtColor8u32f, BGRA2HSV) { performTest(4, 3, CVTCODE(BGR2HSV), IPP_EPS); }
OCL_TEST_P(CvtColor8u32f, RGB2HSV_FULL) { performTest(3, 3, CVTCODE(RGB2HSV_FULL)); }
OCL_TEST_P(CvtColor8u32f, BGR2HSV_FULL) { performTest(3, 3, CVTCODE(BGR2HSV_FULL)); }
OCL_TEST_P(CvtColor8u32f, RGBA2HSV_FULL) { performTest(4, 3, CVTCODE(RGB2HSV_FULL)); }
OCL_TEST_P(CvtColor8u32f, BGRA2HSV_FULL) { performTest(4, 3, CVTCODE(BGR2HSV_FULL)); }
OCL_TEST_P(CvtColor8u32f, RGB2HSV_FULL) { performTest(3, 3, CVTCODE(RGB2HSV_FULL), IPP_EPS); }
OCL_TEST_P(CvtColor8u32f, BGR2HSV_FULL) { performTest(3, 3, CVTCODE(BGR2HSV_FULL), IPP_EPS); }
OCL_TEST_P(CvtColor8u32f, RGBA2HSV_FULL) { performTest(4, 3, CVTCODE(RGB2HSV_FULL), IPP_EPS); }
OCL_TEST_P(CvtColor8u32f, BGRA2HSV_FULL) { performTest(4, 3, CVTCODE(BGR2HSV_FULL), IPP_EPS); }
#undef IPP_EPS
OCL_TEST_P(CvtColor8u32f, HSV2RGB) { performTest(3, 3, CVTCODE(HSV2RGB), depth == CV_8U ? 1 : 4e-1); }
OCL_TEST_P(CvtColor8u32f, HSV2BGR) { performTest(3, 3, CVTCODE(HSV2BGR), depth == CV_8U ? 1 : 4e-1); }

View File

@ -25,6 +25,7 @@
#define GTEST_DONT_DEFINE_TEST 0
#include "opencv2/ts/ts_gtest.h"
#include "opencv2/ts/ts_ext.hpp"
#ifndef GTEST_USES_SIMPLE_RE
# define GTEST_USES_SIMPLE_RE 0
@ -553,15 +554,17 @@ CV_EXPORTS void printVersionInfo(bool useStdOut = true);
#endif
#endif
#if defined(HAVE_OPENCL) && !defined(CV_BUILD_OCL_MODULE)
#ifdef HAVE_OPENCL
namespace cvtest { namespace ocl {
void dumpOpenCLDevice();
}}
} }
#define TEST_DUMP_OCL_INFO cvtest::ocl::dumpOpenCLDevice();
#else
#define TEST_DUMP_OCL_INFO
#endif
void parseCustomOptions(int argc, char **argv);
#define CV_TEST_MAIN(resourcesubdir, ...) \
int main(int argc, char **argv) \
{ \
@ -570,6 +573,7 @@ int main(int argc, char **argv) \
cvtest::printVersionInfo(); \
__CV_TEST_EXEC_ARGS(__VA_ARGS__) \
TEST_DUMP_OCL_INFO \
parseCustomOptions(argc, argv); \
return RUN_ALL_TESTS(); \
}

View File

@ -0,0 +1,92 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2014, Intel, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
#ifndef __OPENCV_TS_EXT_HPP__
#define __OPENCV_TS_EXT_HPP__
void checkIppStatus();
#undef TEST
#define TEST(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public ::testing::Test {\
public:\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
private:\
virtual void TestBody();\
virtual void Body();\
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
};\
\
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\
::test_info_ =\
::testing::internal::MakeAndRegisterTestInfo(\
#test_case_name, #test_name, NULL, NULL, \
(::testing::internal::GetTestTypeId()), \
::testing::Test::SetUpTestCase, \
::testing::Test::TearDownTestCase, \
new ::testing::internal::TestFactoryImpl<\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { cv::ipp::setIppStatus(0); Body(); checkIppStatus(); } \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body()
#undef TEST_F
#define TEST_F(test_fixture, test_name)\
class GTEST_TEST_CLASS_NAME_(test_fixture, test_name) : public test_fixture {\
public:\
GTEST_TEST_CLASS_NAME_(test_fixture, test_name)() {}\
private:\
virtual void TestBody();\
virtual void Body(); \
static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_fixture, test_name));\
};\
\
::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_fixture, test_name)\
::test_info_ =\
::testing::internal::MakeAndRegisterTestInfo(\
#test_fixture, #test_name, NULL, NULL, \
(::testing::internal::GetTypeId<test_fixture>()), \
test_fixture::SetUpTestCase, \
test_fixture::TearDownTestCase, \
new ::testing::internal::TestFactoryImpl<\
GTEST_TEST_CLASS_NAME_(test_fixture, test_name)>);\
void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::TestBody() { cv::ipp::setIppStatus(0); Body(); checkIppStatus(); } \
void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::Body()
#undef TEST_P
#define TEST_P(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
: public test_case_name { \
public: \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \
private: \
virtual void Body(); \
virtual void TestBody(); \
static int AddToRegistry() { \
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
GetTestCasePatternHolder<test_case_name>(\
#test_case_name, __FILE__, __LINE__)->AddTestPattern(\
#test_case_name, \
#test_name, \
new ::testing::internal::TestMetaFactory< \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \
return 0; \
} \
static int gtest_registering_dummy_; \
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \
}; \
int GTEST_TEST_CLASS_NAME_(test_case_name, \
test_name)::gtest_registering_dummy_ = \
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { cv::ipp::setIppStatus(0); Body(); checkIppStatus(); } \
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body()
#endif // __OPENCV_TS_EXT_HPP__

View File

@ -3,6 +3,7 @@
#include "opencv2/core.hpp"
#include "ts_gtest.h"
#include "ts_ext.hpp"
#include <functional>
@ -512,7 +513,7 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os);
#endif
#endif
#if defined(HAVE_OPENCL) && !defined(CV_BUILD_OCL_MODULE)
#ifdef HAVE_OPENCL
namespace cvtest { namespace ocl {
void dumpOpenCLDevice();
}}

View File

@ -658,4 +658,33 @@ void smoothBorder(Mat& img, const Scalar& color, int delta)
} //namespace cvtest
bool test_ipp_check = false;
void checkIppStatus()
{
if (test_ipp_check)
{
int status = cv::ipp::getIppStatus();
EXPECT_LE(0, status) << cv::ipp::getIppErrorLocation().c_str();
}
}
void parseCustomOptions(int argc, char **argv)
{
const char * const command_line_keys =
"{ ipp test_ipp_check |false |check whether IPP works without failures }"
"{ h help |false |print help info }";
cv::CommandLineParser parser(argc, argv, command_line_keys);
if (parser.get<bool>("help"))
{
std::cout << "\nAvailable options besides google test option: \n";
parser.printMessage();
}
test_ipp_check = parser.get<bool>("test_ipp_check");
if (!test_ipp_check)
test_ipp_check = getenv("OPENCV_IPP_CHECK") != NULL;
}
/* End of file. */

View File

@ -31,6 +31,7 @@ static double param_time_limit;
static int param_threads;
static bool param_write_sanity;
static bool param_verify_sanity;
extern bool test_ipp_check;
#ifdef HAVE_CUDA
static int param_cuda_device;
#endif
@ -670,6 +671,9 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
"{ perf_time_limit |3.0 |default time limit for a single test (in seconds)}"
#endif
"{ perf_max_deviation |1.0 |}"
#ifdef HAVE_IPP
"{ perf_ipp_check |false |check whether IPP works without failures}"
#endif
"{ help h |false |print help info}"
#ifdef HAVE_CUDA
"{ perf_cuda_device |0 |run CUDA test suite onto specific CUDA capable device}"
@ -713,7 +717,8 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
param_force_samples = args.get<unsigned int>("perf_force_samples");
param_write_sanity = args.has("perf_write_sanity");
param_verify_sanity = args.has("perf_verify_sanity");
param_threads = args.get<int>("perf_threads");
test_ipp_check = !args.has("perf_ipp_check") ? getenv("OPENCV_IPP_CHECK") != NULL : true;
param_threads = args.get<int>("perf_threads");
#ifdef ANDROID
param_affinity_mask = args.get<int>("perf_affinity_mask");
log_power_checkpoints = args.has("perf_log_power_checkpoints");