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[] =
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
};
#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],
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)) )
#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)))
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;
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;
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;
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;
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;\
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
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)))
{
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();
#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);
-
- 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);
-
- ippiMomentFree_64f(moment);
- return m;
+ 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, 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;
+ }
+ setIppErrorStatus();
}
ippiMomentFree_64f(moment);
}
- setIppErrorStatus();
+ else
+ setIppErrorStatus();
CV_SUPPRESS_DEPRECATED_END
}
#endif
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;
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;
+
+ setIppErrorStatus();
+ return false;
}
#endif
#if IPP_VERSION_X100 >= 801
if( IPPMorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue) )
return;
- setIppErrorStatus();
#endif
if (iterations == 0 || kernel.rows*kernel.cols == 1)
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 \
{ \
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; \
} \
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};
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};
Size corrsize, int ctype,
Point anchor, double delta, int borderType )
{
-#if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7 && !defined HAVE_IPP_ICV_ONLY
- if (ipp_crossCorr(img, _templ, corr))
- return;
- setIppErrorStatus();
-#endif
-
const double blockScale = 4.5;
const int minBlockSize = 256;
std::vector<uchar> buf;
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)
#endif
#if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7 && !defined HAVE_IPP_ICV_ONLY
- if (method == CV_TM_SQDIFF)
+ if (method == CV_TM_SQDIFF && cn == 1)
{
if (ipp_sqrDistance(img, templ, result))
return;
}
#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);
// 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); }