mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Imgproc_Hist_MinMaxVal.accuracy fix;
Some code style corrections;
This commit is contained in:
parent
a5a21019b2
commit
101607a7d0
@ -5194,10 +5194,7 @@ dtype* dst, size_t dstep, Size size, double* scale) \
|
||||
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
|
||||
dtype* dst, size_t dstep, Size size, double*) \
|
||||
{ \
|
||||
if (src && dst)\
|
||||
{\
|
||||
CV_IPP_RUN(true, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0)\
|
||||
}\
|
||||
CV_IPP_RUN(src && dst, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0)\
|
||||
cvt_(src, sstep, dst, dstep, size); \
|
||||
}
|
||||
|
||||
@ -5205,10 +5202,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
|
||||
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
|
||||
dtype* dst, size_t dstep, Size size, double*) \
|
||||
{ \
|
||||
if (src && dst)\
|
||||
{\
|
||||
CV_IPP_RUN(true, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0)\
|
||||
}\
|
||||
CV_IPP_RUN(src && dst, ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0)\
|
||||
cvt_(src, sstep, dst, dstep, size); \
|
||||
}
|
||||
#else
|
||||
@ -5844,6 +5838,46 @@ private:
|
||||
IppLUTParallelBody_LUTCN& operator=(const IppLUTParallelBody_LUTCN&);
|
||||
};
|
||||
} // namespace ipp
|
||||
|
||||
static bool ipp_lut(Mat &src, Mat &lut, Mat &dst)
|
||||
{
|
||||
int cn = src.channels();
|
||||
int lutcn = lut.channels();
|
||||
|
||||
if(src.dims > 2)
|
||||
return false;
|
||||
|
||||
bool ok = false;
|
||||
Ptr<ParallelLoopBody> body;
|
||||
|
||||
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
|
||||
#if 0 // there are no performance benefits (PR #2653)
|
||||
if (lutcn == 1)
|
||||
{
|
||||
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
|
||||
body.reset(p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
|
||||
{
|
||||
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
|
||||
body.reset(p);
|
||||
}
|
||||
|
||||
if (body != NULL && ok)
|
||||
{
|
||||
Range all(0, dst.rows);
|
||||
if (dst.total()>>18)
|
||||
parallel_for_(all, *body, (double)std::max((size_t)1, dst.total()>>16));
|
||||
else
|
||||
(*body)(all);
|
||||
if (ok)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif // IPP
|
||||
|
||||
class LUTParallelBody : public ParallelLoopBody
|
||||
@ -5891,55 +5925,6 @@ private:
|
||||
|
||||
}
|
||||
|
||||
namespace cv
|
||||
{
|
||||
#if defined(HAVE_IPP)
|
||||
static bool ipp_lut(InputArray _src, InputArray _lut, OutputArray _dst)
|
||||
{
|
||||
int cn = _src.channels();
|
||||
int lutcn = _lut.channels();
|
||||
|
||||
Mat src = _src.getMat(), lut = _lut.getMat();
|
||||
_dst.create(src.dims, src.size, CV_MAKETYPE(_lut.depth(), cn));
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
if (_src.dims() <= 2)
|
||||
{
|
||||
bool ok = false;
|
||||
Ptr<ParallelLoopBody> body;
|
||||
|
||||
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
|
||||
#if 0 // there are no performance benefits (PR #2653)
|
||||
if (lutcn == 1)
|
||||
{
|
||||
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
|
||||
body.reset(p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
|
||||
{
|
||||
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
|
||||
body.reset(p);
|
||||
}
|
||||
|
||||
if (body != NULL && ok)
|
||||
{
|
||||
Range all(0, dst.rows);
|
||||
if (dst.total()>>18)
|
||||
parallel_for_(all, *body, (double)std::max((size_t)1, dst.total()>>16));
|
||||
else
|
||||
(*body)(all);
|
||||
if (ok)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
|
||||
{
|
||||
int cn = _src.channels(), depth = _src.depth();
|
||||
@ -5952,18 +5937,17 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
|
||||
CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2,
|
||||
ocl_LUT(_src, _lut, _dst))
|
||||
|
||||
CV_IPP_RUN((_src.dims() <= 2 && ((lutcn == 1 || lutcn == 3 || lutcn == 4) && CV_ELEM_SIZE1(_dst.depth()) == 1) && lutcn != 1), //lutcn == 1 ipp implementation switched off
|
||||
ipp_lut(_src, _lut, _dst));
|
||||
|
||||
|
||||
Mat src = _src.getMat(), lut = _lut.getMat();
|
||||
_dst.create(src.dims, src.size, CV_MAKETYPE(_lut.depth(), cn));
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
CV_IPP_RUN(_src.dims() <= 2, ipp_lut(src, lut, dst));
|
||||
|
||||
if (_src.dims() <= 2)
|
||||
{
|
||||
bool ok = false;
|
||||
Ptr<ParallelLoopBody> body;
|
||||
|
||||
if (body == NULL || ok == false)
|
||||
{
|
||||
ok = false;
|
||||
|
@ -424,9 +424,8 @@ Mat& Mat::operator = (const Scalar& s)
|
||||
}
|
||||
|
||||
#if defined HAVE_IPP
|
||||
static bool ipp_Mat_setTo(Mat *src, InputArray _value, InputArray _mask)
|
||||
static bool ipp_Mat_setTo(Mat *src, Mat &value, Mat &mask)
|
||||
{
|
||||
Mat value = _value.getMat(), mask = _mask.getMat();
|
||||
int cn = src->channels(), depth0 = src->depth();
|
||||
|
||||
if (!mask.empty() && (src->dims <= 2 || (src->isContinuous() && mask.isContinuous())) &&
|
||||
@ -515,8 +514,7 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
|
||||
CV_Assert( checkScalar(value, type(), _value.kind(), _InputArray::MAT ));
|
||||
CV_Assert( mask.empty() || (mask.type() == CV_8U && size == mask.size) );
|
||||
|
||||
CV_IPP_RUN(true, ipp_Mat_setTo((cv::Mat*)this, _value, _mask), *this)
|
||||
|
||||
CV_IPP_RUN(true, ipp_Mat_setTo((cv::Mat*)this, value, mask), *this)
|
||||
|
||||
size_t esz = elemSize();
|
||||
BinaryFunc copymask = getCopyMaskFunc(esz);
|
||||
@ -691,13 +689,10 @@ static bool ocl_flip(InputArray _src, OutputArray _dst, int flipCode )
|
||||
#endif
|
||||
|
||||
#if defined HAVE_IPP
|
||||
static bool ipp_flip( InputArray _src, OutputArray _dst, int flip_mode )
|
||||
static bool ipp_flip( Mat &src, Mat &dst, int flip_mode )
|
||||
{
|
||||
Size size = _src.size();
|
||||
Mat src = _src.getMat();
|
||||
Size size = src.size();
|
||||
int type = src.type();
|
||||
_dst.create( size, type );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
typedef IppStatus (CV_STDCALL * ippiMirror)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize, IppiAxis flip);
|
||||
typedef IppStatus (CV_STDCALL * ippiMirrorI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize, IppiAxis flip);
|
||||
@ -786,13 +781,13 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode )
|
||||
|
||||
CV_OCL_RUN( _dst.isUMat(), ocl_flip(_src, _dst, flip_mode))
|
||||
|
||||
CV_IPP_RUN(true, ipp_flip(_src, _dst, flip_mode));
|
||||
|
||||
|
||||
Mat src = _src.getMat();
|
||||
int type = src.type();
|
||||
_dst.create( size, type );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
CV_IPP_RUN(true, ipp_flip(src, dst, flip_mode));
|
||||
|
||||
size_t esz = CV_ELEM_SIZE(type);
|
||||
|
||||
if( flip_mode <= 0 )
|
||||
|
@ -3088,19 +3088,15 @@ static bool ocl_transpose( InputArray _src, OutputArray _dst )
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_transpose( InputArray _src, OutputArray _dst )
|
||||
static bool ipp_transpose( Mat &src, Mat &dst )
|
||||
{
|
||||
int type = _src.type();
|
||||
int type = src.type();
|
||||
typedef IppStatus (CV_STDCALL * ippiTranspose)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize);
|
||||
typedef IppStatus (CV_STDCALL * ippiTransposeI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize);
|
||||
ippiTranspose ippFunc = 0;
|
||||
ippiTransposeI ippFuncI = 0;
|
||||
|
||||
Mat dst = _dst.getMat();
|
||||
Mat src = _src.getMat();
|
||||
|
||||
if (dst.data == src.data && dst.cols == dst.rows)
|
||||
{
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
@ -3186,8 +3182,7 @@ void cv::transpose( InputArray _src, OutputArray _dst )
|
||||
return;
|
||||
}
|
||||
|
||||
CV_IPP_RUN(true, ipp_transpose(_src, _dst))
|
||||
|
||||
CV_IPP_RUN(true, ipp_transpose(src, dst))
|
||||
|
||||
if( dst.data == src.data )
|
||||
{
|
||||
|
@ -72,7 +72,6 @@
|
||||
#define GET_OPTIMIZED(func) (func)
|
||||
#endif
|
||||
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3120,6 +3120,7 @@ static bool ipp_resize_mt( Mat src, Mat dst,
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
double inv_scale_x, double inv_scale_y, int interpolation )
|
||||
{
|
||||
@ -3482,7 +3483,6 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* General warping (affine, perspective, remap) *
|
||||
\****************************************************************************************/
|
||||
|
@ -1136,10 +1136,11 @@ private:
|
||||
Scalar borderValue;
|
||||
};
|
||||
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kernel,
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_MorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kernel,
|
||||
const Size& ksize, const Point &anchor, bool rectKernel)
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801
|
||||
int type = src.type();
|
||||
const Mat* _src = &src;
|
||||
Mat temp;
|
||||
@ -1257,10 +1258,13 @@ static bool IPPMorphReplicate(int op, const Mat &src, Mat &dst, const Mat &kerne
|
||||
}
|
||||
#undef IPP_MORPH_CASE
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(op); CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(kernel); CV_UNUSED(ksize); CV_UNUSED(anchor); CV_UNUSED(rectKernel);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
||||
static bool ipp_MorphOp(int op, InputArray _src, OutputArray _dst,
|
||||
const Mat& _kernel, Point anchor, int iterations,
|
||||
int borderType, const Scalar &borderValue)
|
||||
{
|
||||
@ -1331,7 +1335,7 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst,
|
||||
if( iterations > 1 )
|
||||
return false;
|
||||
|
||||
return IPPMorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel );
|
||||
return ipp_MorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel );
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1711,9 +1715,7 @@ static void morphOp( int op, InputArray _src, OutputArray _dst,
|
||||
iterations = 1;
|
||||
}
|
||||
|
||||
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 801, IPPMorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue))
|
||||
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 801, ipp_MorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue))
|
||||
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( src.size(), src.type() );
|
||||
|
@ -907,22 +907,22 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size size, unsigned char &thresh)
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 801 && !HAVE_ICV
|
||||
int ippStatus = -1;
|
||||
#if IPP_VERSION_X100 >= 801 && !defined(HAVE_IPP_ICV_ONLY)
|
||||
IppiSize srcSize = { size.width, size.height };
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippStatus = ippiComputeThreshold_Otsu_8u_C1R(_src, step, srcSize, &thresh);
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
|
||||
if(ippStatus >= 0)
|
||||
return true;
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(step); CV_UNUSED(size); CV_UNUSED(thresh);
|
||||
#endif
|
||||
if(ippStatus >= 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static double
|
||||
getThreshVal_Otsu_8u( const Mat& _src )
|
||||
{
|
||||
@ -937,9 +937,8 @@ getThreshVal_Otsu_8u( const Mat& _src )
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
unsigned char thresh;
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 801 && !HAVE_ICV, ipp_getThreshVal_Otsu_8u(_src.ptr(), step, size, thresh), thresh);
|
||||
#endif
|
||||
CV_IPP_RUN(true, ipp_getThreshVal_Otsu_8u(_src.ptr(), step, size, thresh), thresh);
|
||||
|
||||
|
||||
const int N = 256;
|
||||
int i, j, h[N] = {0};
|
||||
|
Loading…
Reference in New Issue
Block a user