fixed some errors

This commit is contained in:
Ilya Lavrenov 2014-04-16 19:45:35 +04:00
parent ce0941160e
commit 6f9ca3d77c
3 changed files with 53 additions and 61 deletions

View File

@ -939,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); int scn = (int)sc.total(), cn = CV_MAT_CN(buftype);
size_t esz = CV_ELEM_SIZE(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 // unroll the scalar
if( scn < cn ) if( scn < cn )
{ {
@ -1628,33 +1628,33 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
uchar* dptr = ptrs[2]; uchar* dptr = ptrs[2];
if( cvtsrc1 ) if( cvtsrc1 )
{ {
cvtsrc1( sptr1, 0, 0, 0, buf1, 0, bszn, 0 ); cvtsrc1( sptr1, 1, 0, 1, buf1, 1, bszn, 0 );
sptr1 = buf1; sptr1 = buf1;
} }
if( ptrs[0] == ptrs[1] ) if( ptrs[0] == ptrs[1] )
sptr2 = sptr1; sptr2 = sptr1;
else if( cvtsrc2 ) else if( cvtsrc2 )
{ {
cvtsrc2( sptr2, 0, 0, 0, buf2, 0, bszn, 0 ); cvtsrc2( sptr2, 1, 0, 1, buf2, 1, bszn, 0 );
sptr2 = buf2; sptr2 = buf2;
} }
if( !haveMask && !cvtdst ) if( !haveMask && !cvtdst )
func( sptr1, 0, sptr2, 0, dptr, 0, bszn, usrdata ); func( sptr1, 1, sptr2, 1, dptr, 1, bszn, usrdata );
else else
{ {
func( sptr1, 0, sptr2, 0, wbuf, 0, bszn, usrdata ); func( sptr1, 1, sptr2, 1, wbuf, 0, bszn, usrdata );
if( !haveMask ) if( !haveMask )
cvtdst( wbuf, 0, 0, 0, dptr, 0, bszn, 0 ); cvtdst( wbuf, 1, 0, 1, dptr, 1, bszn, 0 );
else if( !cvtdst ) 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; ptrs[3] += bsz;
} }
else else
{ {
cvtdst( wbuf, 0, 0, 0, maskbuf, 0, bszn, 0 ); cvtdst( wbuf, 1, 0, 1, maskbuf, 1, bszn, 0 );
copymask( maskbuf, 0, ptrs[3], 0, dptr, 0, Size(bsz, 1), &dsz ); copymask( maskbuf, 1, ptrs[3], 1, dptr, 1, Size(bsz, 1), &dsz );
ptrs[3] += bsz; ptrs[3] += bsz;
} }
} }
@ -1695,7 +1695,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
if( cvtsrc1 ) if( cvtsrc1 )
{ {
cvtsrc1( sptr1, 0, 0, 0, buf1, 0, bszn, 0 ); cvtsrc1( sptr1, 1, 0, 1, buf1, 1, bszn, 0 );
sptr1 = buf1; sptr1 = buf1;
} }
@ -1703,21 +1703,21 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
std::swap(sptr1, sptr2); std::swap(sptr1, sptr2);
if( !haveMask && !cvtdst ) if( !haveMask && !cvtdst )
func( sptr1, 0, sptr2, 0, dptr, 0, bszn, usrdata ); func( sptr1, 1, sptr2, 1, dptr, 1, bszn, usrdata );
else else
{ {
func( sptr1, 0, sptr2, 0, wbuf, 0, bszn, usrdata ); func( sptr1, 1, sptr2, 1, wbuf, 1, bszn, usrdata );
if( !haveMask ) if( !haveMask )
cvtdst( wbuf, 0, 0, 0, dptr, 0, bszn, 0 ); cvtdst( wbuf, 1, 0, 1, dptr, 1, bszn, 0 );
else if( !cvtdst ) 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; ptrs[2] += bsz;
} }
else else
{ {
cvtdst( wbuf, 0, 0, 0, maskbuf, 0, bszn, 0 ); cvtdst( wbuf, 1, 0, 1, maskbuf, 1, bszn, 0 );
copymask( maskbuf, 0, ptrs[2], 0, dptr, 0, Size(bsz, 1), &dsz ); copymask( maskbuf, 1, ptrs[2], 1, dptr, 1, Size(bsz, 1), &dsz );
ptrs[2] += bsz; ptrs[2] += bsz;
} }
} }
@ -2712,7 +2712,7 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in
else else
{ {
double fval = 0; 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) ) if( fval < getMinVal(depth1) )
return dst.setTo(Scalar::all(op == CMP_GT || op == CMP_GE || op == CMP_NE ? 255 : 0)), true; return dst.setTo(Scalar::all(op == CMP_GT || op == CMP_GE || op == CMP_NE ? 255 : 0)), true;
@ -2833,7 +2833,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
else else
{ {
double fval=0; 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) ) if( fval < getMinVal(depth1) )
{ {
dst = Scalar::all(op == CMP_GT || op == CMP_GE || op == CMP_NE ? 255 : 0); dst = Scalar::all(op == CMP_GT || op == CMP_GE || op == CMP_NE ? 255 : 0);
@ -3060,8 +3060,8 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb,
int* iubuf = ilbuf + cn; int* iubuf = ilbuf + cn;
BinaryFunc sccvtfunc = getConvertFunc(ldepth, CV_32S); BinaryFunc sccvtfunc = getConvertFunc(ldepth, CV_32S);
sccvtfunc(lscalar.data, 0, 0, 0, (uchar*)ilbuf, 0, Size(cn, 1), 0); sccvtfunc(lscalar.data, 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0);
sccvtfunc(uscalar.data, 0, 0, 0, (uchar*)iubuf, 0, 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)); int minval = cvRound(getMinVal(sdepth)), maxval = cvRound(getMaxVal(sdepth));
for( int k = 0; k < cn; k++ ) for( int k = 0; k < cn; k++ )
@ -3171,8 +3171,8 @@ void cv::inRange(InputArray _src, InputArray _lowerb,
int* iubuf = ilbuf + cn; int* iubuf = ilbuf + cn;
BinaryFunc sccvtfunc = getConvertFunc(scdepth, CV_32S); BinaryFunc sccvtfunc = getConvertFunc(scdepth, CV_32S);
sccvtfunc(lb.data, 0, 0, 0, (uchar*)ilbuf, 0, Size(cn, 1), 0); sccvtfunc(lb.data, 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0);
sccvtfunc(ub.data, 0, 0, 0, (uchar*)iubuf, 0, 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)); int minval = cvRound(getMinVal(depth)), maxval = cvRound(getMaxVal(depth));
for( int k = 0; k < cn; k++ ) for( int k = 0; k < cn; k++ )

View File

@ -2223,14 +2223,6 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray
if (src1.isContinuous() && src2.isContinuous() && dst.isContinuous()) if (src1.isContinuous() && src2.isContinuous() && dst.isContinuous())
{ {
size_t len = src1.total()*cn; 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;
setIppErrorStatus();
#endif
func(src1.data, src2.data, dst.data, (int)len, palpha); func(src1.data, src2.data, dst.data, (int)len, palpha);
return; return;
} }

View File

@ -201,7 +201,7 @@ static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy,
switch(src.type()) switch(src.type())
{ {
case CV_8U: case CV_8UC1:
{ {
if(scale != 1) if(scale != 1)
return false; return false;
@ -232,14 +232,14 @@ static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy,
return false; return false;
} }
} }
case CV_32F: case CV_32FC1:
#if defined(HAVE_IPP_ICV_ONLY) // N/A: ippiMulC_32f_C1R #if defined(HAVE_IPP_ICV_ONLY) // N/A: ippiMulC_32f_C1R
return false; return false;
#else #else
{ {
switch(dst.type()) switch(dst.type())
{ {
case CV_32F: case CV_32FC1:
{ {
if ((dx == 1) && (dy == 0)) 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) 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; cv::AutoBuffer<char> buffer;
if (ksize == 3 || ksize == 5) if (ksize == 3 || ksize == 5)
{ {
if ( ddepth < 0 ) if (stype == CV_8UC1 && dtype == CV_16SC1 && scale == 1)
ddepth = src.depth();
if (src.type() == CV_8U && dst.type() == CV_16S && 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)) if (0 > ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false; return false;
buffer.allocate(bufSize); 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), (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)) if (0 > ippiFilterSobelHorizGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false; return false;
buffer.allocate(bufSize); 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), (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)) if (0 > ippiFilterSobelVertSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false; return false;
buffer.allocate(bufSize); 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), (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)) if (0 > ippiFilterSobelHorizSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false; return false;
buffer.allocate(bufSize); 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), (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 #if defined(HAVE_IPP_ICV_ONLY) // N/A: ippiMulC_32f_C1R
return false; return false;
#else #else
#if 0 #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)) if (0 > ippiFilterSobelNegVertGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), &bufSize))
return false; return false;
@ -366,7 +363,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
return true; 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)) if (0 > ippiFilterSobelHorizGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false; return false;
@ -384,7 +381,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
} }
#endif #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)) if (0 > ippiFilterSobelVertSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false; return false;
@ -401,7 +398,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
return true; 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)) if (0 > ippiFilterSobelHorizSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize))
return false; 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 IPPDerivScharr(src, dst, ddepth, dx, dy, scale);
return false; 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); int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype);
if (ddepth < 0) if (ddepth < 0)
ddepth = sdepth; 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 #ifdef HAVE_TEGRA_OPTIMIZATION
if (scale == 1.0 && delta == 0) if (scale == 1.0 && delta == 0)
@ -451,12 +449,12 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
#endif #endif
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #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(); Mat src = _src.getMat(), dst = _dst.getMat();
if (IPPDeriv(src, dst, ddepth, dx, dy, ksize,scale)) if (IPPDeriv(src, dst, ddepth, dx, dy, ksize,scale))
return; return;
setIppErrorStatus();
} }
#endif #endif
int ktype = std::max(CV_32F, std::max(ddepth, sdepth)); int ktype = std::max(CV_32F, std::max(ddepth, sdepth));
@ -482,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); int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype);
if (ddepth < 0) if (ddepth < 0)
ddepth = sdepth; 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 #ifdef HAVE_TEGRA_OPTIMIZATION
if (scale == 1.0 && delta == 0) if (scale == 1.0 && delta == 0)
@ -494,7 +493,8 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
#endif #endif
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) #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(); Mat src = _src.getMat(), dst = _dst.getMat();
if(IPPDerivScharr(src, dst, ddepth, dx, dy, scale)) if(IPPDerivScharr(src, dst, ddepth, dx, dy, scale))