1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

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
31 changed files with 562 additions and 209 deletions
+3
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
+13 -6
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));
+104 -30
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>());
}
+33 -30
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
+1
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;
+3
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
+1
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
+22 -23
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
*/
+46 -45
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
+8 -2
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
+7 -3
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 )
+12 -7
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
+1
View File
@@ -393,6 +393,7 @@ void cv::integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, Output
}
if (0 <= status)
return;
setIppErrorStatus();
}
#endif
+17 -12
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);
+9
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