Normalize line endings and whitespace

This commit is contained in:
OpenCV Buildbot
2012-10-17 11:12:04 +04:00
committed by Andrey Kamaev
parent 0442bca235
commit 81f826db2b
1511 changed files with 258678 additions and 258624 deletions

View File

@@ -49,18 +49,18 @@ template<typename T, typename AT> void
acc_( const T* src, AT* dst, const uchar* mask, int len, int cn )
{
int i = 0;
if( !mask )
{
len *= cn;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= len - 4; i += 4 )
{
AT t0, t1;
t0 = src[i] + dst[i];
t1 = src[i+1] + dst[i+1];
dst[i] = t0; dst[i+1] = t1;
t0 = src[i+2] + dst[i+2];
t1 = src[i+3] + dst[i+3];
dst[i+2] = t0; dst[i+3] = t1;
@@ -86,7 +86,7 @@ acc_( const T* src, AT* dst, const uchar* mask, int len, int cn )
AT t0 = src[0] + dst[0];
AT t1 = src[1] + dst[1];
AT t2 = src[2] + dst[2];
dst[0] = t0; dst[1] = t1; dst[2] = t2;
}
}
@@ -102,23 +102,23 @@ acc_( const T* src, AT* dst, const uchar* mask, int len, int cn )
}
}
template<typename T, typename AT> void
accSqr_( const T* src, AT* dst, const uchar* mask, int len, int cn )
{
int i = 0;
if( !mask )
{
len *= cn;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= len - 4; i += 4 )
{
AT t0, t1;
t0 = (AT)src[i]*src[i] + dst[i];
t1 = (AT)src[i+1]*src[i+1] + dst[i+1];
dst[i] = t0; dst[i+1] = t1;
t0 = (AT)src[i+2]*src[i+2] + dst[i+2];
t1 = (AT)src[i+3]*src[i+3] + dst[i+3];
dst[i+2] = t0; dst[i+3] = t1;
@@ -144,7 +144,7 @@ accSqr_( const T* src, AT* dst, const uchar* mask, int len, int cn )
AT t0 = (AT)src[0]*src[0] + dst[0];
AT t1 = (AT)src[1]*src[1] + dst[1];
AT t2 = (AT)src[2]*src[2] + dst[2];
dst[0] = t0; dst[1] = t1; dst[2] = t2;
}
}
@@ -159,24 +159,24 @@ accSqr_( const T* src, AT* dst, const uchar* mask, int len, int cn )
}
}
}
template<typename T, typename AT> void
accProd_( const T* src1, const T* src2, AT* dst, const uchar* mask, int len, int cn )
{
int i = 0;
if( !mask )
{
len *= cn;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= len - 4; i += 4 )
{
AT t0, t1;
t0 = (AT)src1[i]*src2[i] + dst[i];
t1 = (AT)src1[i+1]*src2[i+1] + dst[i+1];
dst[i] = t0; dst[i+1] = t1;
t0 = (AT)src1[i+2]*src2[i+2] + dst[i+2];
t1 = (AT)src1[i+3]*src2[i+3] + dst[i+3];
dst[i+2] = t0; dst[i+3] = t1;
@@ -202,7 +202,7 @@ accProd_( const T* src1, const T* src2, AT* dst, const uchar* mask, int len, int
AT t0 = (AT)src1[0]*src2[0] + dst[0];
AT t1 = (AT)src1[1]*src2[1] + dst[1];
AT t2 = (AT)src1[2]*src2[2] + dst[2];
dst[0] = t0; dst[1] = t1; dst[2] = t2;
}
}
@@ -218,24 +218,24 @@ accProd_( const T* src1, const T* src2, AT* dst, const uchar* mask, int len, int
}
}
template<typename T, typename AT> void
accW_( const T* src, AT* dst, const uchar* mask, int len, int cn, double alpha )
{
AT a = (AT)alpha, b = 1 - a;
int i = 0;
if( !mask )
{
len *= cn;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= len - 4; i += 4 )
{
AT t0, t1;
t0 = src[i]*a + dst[i]*b;
t1 = src[i+1]*a + dst[i+1]*b;
dst[i] = t0; dst[i+1] = t1;
t0 = src[i+2]*a + dst[i+2]*b;
t1 = src[i+3]*a + dst[i+3]*b;
dst[i+2] = t0; dst[i+3] = t1;
@@ -261,7 +261,7 @@ accW_( const T* src, AT* dst, const uchar* mask, int len, int cn, double alpha )
AT t0 = src[0]*a + dst[0]*b;
AT t1 = src[1]*a + dst[1]*b;
AT t2 = src[2]*a + dst[2]*b;
dst[0] = t0; dst[1] = t1; dst[2] = t2;
}
}
@@ -303,8 +303,8 @@ DEF_ACC_FUNCS(16u64f, ushort, double)
DEF_ACC_FUNCS(32f, float, float)
DEF_ACC_FUNCS(32f64f, float, double)
DEF_ACC_FUNCS(64f, double, double)
typedef void (*AccFunc)(const uchar*, uchar*, const uchar*, int, int);
typedef void (*AccProdFunc)(const uchar*, const uchar*, uchar*, const uchar*, int, int);
typedef void (*AccWFunc)(const uchar*, uchar*, const uchar*, int, int, double);
@@ -350,27 +350,27 @@ inline int getAccTabIdx(int sdepth, int ddepth)
sdepth == CV_32F && ddepth == CV_32F ? 4 :
sdepth == CV_32F && ddepth == CV_64F ? 5 :
sdepth == CV_64F && ddepth == CV_64F ? 6 : -1;
}
}
}
void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask )
{
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
int sdepth = src.depth(), ddepth = dst.depth(), cn = src.channels();
CV_Assert( dst.size == src.size && dst.channels() == cn );
CV_Assert( mask.empty() || (mask.size == src.size && mask.type() == CV_8U) );
int fidx = getAccTabIdx(sdepth, ddepth);
AccFunc func = fidx >= 0 ? accTab[fidx] : 0;
CV_Assert( func != 0 );
const Mat* arrays[] = {&src, &dst, &mask, 0};
uchar* ptrs[3];
NAryMatIterator it(arrays, ptrs);
int len = (int)it.size;
for( size_t i = 0; i < it.nplanes; i++, ++it )
func(ptrs[0], ptrs[1], ptrs[2], len, cn);
}
@@ -380,19 +380,19 @@ void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _m
{
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
int sdepth = src.depth(), ddepth = dst.depth(), cn = src.channels();
CV_Assert( dst.size == src.size && dst.channels() == cn );
CV_Assert( mask.empty() || (mask.size == src.size && mask.type() == CV_8U) );
int fidx = getAccTabIdx(sdepth, ddepth);
AccFunc func = fidx >= 0 ? accSqrTab[fidx] : 0;
CV_Assert( func != 0 );
const Mat* arrays[] = {&src, &dst, &mask, 0};
uchar* ptrs[3];
NAryMatIterator it(arrays, ptrs);
int len = (int)it.size;
for( size_t i = 0; i < it.nplanes; i++, ++it )
func(ptrs[0], ptrs[1], ptrs[2], len, cn);
}
@@ -402,20 +402,20 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2,
{
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
int sdepth = src1.depth(), ddepth = dst.depth(), cn = src1.channels();
CV_Assert( src2.size && src1.size && src2.type() == src1.type() );
CV_Assert( dst.size == src1.size && dst.channels() == cn );
CV_Assert( mask.empty() || (mask.size == src1.size && mask.type() == CV_8U) );
int fidx = getAccTabIdx(sdepth, ddepth);
AccProdFunc func = fidx >= 0 ? accProdTab[fidx] : 0;
CV_Assert( func != 0 );
const Mat* arrays[] = {&src1, &src2, &dst, &mask, 0};
uchar* ptrs[4];
NAryMatIterator it(arrays, ptrs);
int len = (int)it.size;
for( size_t i = 0; i < it.nplanes; i++, ++it )
func(ptrs[0], ptrs[1], ptrs[2], ptrs[3], len, cn);
}
@@ -426,19 +426,19 @@ void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst,
{
Mat src = _src.getMat(), dst = _dst.getMat(), mask = _mask.getMat();
int sdepth = src.depth(), ddepth = dst.depth(), cn = src.channels();
CV_Assert( dst.size == src.size && dst.channels() == cn );
CV_Assert( mask.empty() || (mask.size == src.size && mask.type() == CV_8U) );
int fidx = getAccTabIdx(sdepth, ddepth);
AccWFunc func = fidx >= 0 ? accWTab[fidx] : 0;
CV_Assert( func != 0 );
const Mat* arrays[] = {&src, &dst, &mask, 0};
uchar* ptrs[3];
NAryMatIterator it(arrays, ptrs);
int len = (int)it.size;
for( size_t i = 0; i < it.nplanes; i++, ++it )
func(ptrs[0], ptrs[1], ptrs[2], len, cn, alpha);
}

View File

@@ -648,7 +648,7 @@ icvApproxPolyDP( CvSeq* src_contour, int header_size,
dx = end_pt.x - start_pt.x;
dy = end_pt.y - start_pt.y;
dist = fabs((pt.x - start_pt.x)*dy - (pt.y - start_pt.y)*dx);
successive_inner_product = (pt.x - start_pt.x) * (end_pt.x - pt.x) +
successive_inner_product = (pt.x - start_pt.x) * (end_pt.x - pt.x) +
(pt.y - start_pt.y) * (end_pt.y - pt.y);
if( dist * dist <= 0.5*eps*(dx*dx + dy*dy) && dx != 0 && dy != 0 &&

View File

@@ -47,7 +47,7 @@ void cv::Canny( InputArray _src, OutputArray _dst,
{
Mat src = _src.getMat();
CV_Assert( src.depth() == CV_8U );
_dst.create(src.size(), CV_8U);
Mat dst = _dst.getMat();
@@ -80,7 +80,7 @@ void cv::Canny( InputArray _src, OutputArray _dst,
{
low_thresh = std::min(32767.0, low_thresh);
high_thresh = std::min(32767.0, high_thresh);
if (low_thresh > 0) low_thresh *= low_thresh;
if (high_thresh > 0) high_thresh *= high_thresh;
}
@@ -89,7 +89,7 @@ void cv::Canny( InputArray _src, OutputArray _dst,
ptrdiff_t mapstep = src.cols + 2;
cv::AutoBuffer<uchar> buffer((src.cols+2)*(src.rows+2) + cn * mapstep * 3 * sizeof(int));
int* mag_buf[3];
mag_buf[0] = (int*)(uchar*)buffer;
mag_buf[1] = mag_buf[0] + mapstep*cn;
@@ -143,7 +143,7 @@ void cv::Canny( InputArray _src, OutputArray _dst,
for (int j = 0; j < src.cols*cn; j++)
_norm[j] = int(_dx[j])*_dx[j] + int(_dy[j])*_dy[j];
}
if (cn > 1)
{
for(int j = 0, jn = 0; j < src.cols; ++j, jn += cn)
@@ -160,7 +160,7 @@ void cv::Canny( InputArray _src, OutputArray _dst,
}
else
memset(_norm-1, 0, /* cn* */mapstep*sizeof(int));
// at the very beginning we do not have a complete ring
// buffer of 3 magnitude rows for non-maxima suppression
if (i == 0)
@@ -280,7 +280,7 @@ void cvCanny( const CvArr* image, CvArr* edges, double threshold1,
{
cv::Mat src = cv::cvarrToMat(image), dst = cv::cvarrToMat(edges);
CV_Assert( src.size == dst.size && src.depth() == CV_8U && dst.type() == CV_8U );
cv::Canny(src, dst, threshold1, threshold2, aperture_size & 255,
(aperture_size & CV_CANNY_L2_GRADIENT) != 0);
}

View File

@@ -1362,7 +1362,7 @@ struct RGB2Lab_f
_coeffs = sRGB2XYZ_D65;
if (!_whitept)
_whitept = D65;
float scale[] = { 1.0f / _whitept[0], 1.0f, 1.0f / _whitept[2] };
for( int i = 0; i < _3; i++ )
@@ -1371,7 +1371,7 @@ struct RGB2Lab_f
coeffs[j + (blueIdx ^ 2)] = _coeffs[j] * scale[i];
coeffs[j + 1] = _coeffs[j + 1] * scale[i];
coeffs[j + blueIdx] = _coeffs[j + 2] * scale[i];
CV_Assert( coeffs[j] >= 0 && coeffs[j + 1] >= 0 && coeffs[j + 2] >= 0 &&
coeffs[j] + coeffs[j + 1] + coeffs[j + 2] < 1.5f*LabCbrtTabScale );
}
@@ -1394,11 +1394,11 @@ struct RGB2Lab_f
float R = clip(src[0]);
float G = clip(src[1]);
float B = clip(src[2]);
// CV_Assert(R >= 0.0f && R <= 1.0f);
// CV_Assert(G >= 0.0f && G <= 1.0f);
// CV_Assert(B >= 0.0f && B <= 1.0f);
if (gammaTab)
{
R = splineInterpolate(R * gscale, gammaTab, GAMMA_TAB_SIZE);
@@ -1408,15 +1408,15 @@ struct RGB2Lab_f
float X = R*C0 + G*C1 + B*C2;
float Y = R*C3 + G*C4 + B*C5;
float Z = R*C6 + G*C7 + B*C8;
float FX = X > 0.008856 ? pow(X, _1_3) : (7.787f * X + _a);
float FY = Y > 0.008856 ? pow(Y, _1_3) : (7.787f * Y + _a);
float FZ = Z > 0.008856 ? pow(Z, _1_3) : (7.787f * Z + _a);
float L = Y > 0.008856 ? (116.f * FY - 16.f) : (903.3 * Y);
float a = 500.f * (FX - FY);
float b = 200.f * (FY - FZ);
dst[i] = L;
dst[i + 1] = a;
dst[i + 2] = b;
@@ -1427,22 +1427,22 @@ struct RGB2Lab_f
float coeffs[9];
bool srgb;
};
struct Lab2RGB_f
{
typedef float channel_type;
Lab2RGB_f( int _dstcn, int blueIdx, const float* _coeffs,
const float* _whitept, bool _srgb )
: dstcn(_dstcn), srgb(_srgb), blueInd(blueIdx)
{
initLabTabs();
if(!_coeffs)
_coeffs = XYZ2sRGB_D65;
if(!_whitept)
_whitept = D65;
for( int i = 0; i < 3; i++ )
{
coeffs[i+(blueIdx^2)*3] = _coeffs[i]*_whitept[i];
@@ -1450,7 +1450,7 @@ struct Lab2RGB_f
coeffs[i+blueIdx*3] = _coeffs[i+6]*_whitept[i];
}
}
void operator()(const float* src, float* dst, int n) const
{
int i, dcn = dstcn;
@@ -1461,7 +1461,7 @@ struct Lab2RGB_f
C6 = coeffs[6], C7 = coeffs[7], C8 = coeffs[8];
float alpha = ColorChannel<float>::max();
n *= 3;
static const float lThresh = 0.008856f * 903.3f;
static const float fThresh = 7.787f * 0.008856f + 16.0f / 116.0f;
for (i = 0; i < n; i += 3, dst += dcn)
@@ -1469,7 +1469,7 @@ struct Lab2RGB_f
float li = src[i];
float ai = src[i + 1];
float bi = src[i + 2];
float y, fy;
if (li <= lThresh)
{
@@ -1481,44 +1481,44 @@ struct Lab2RGB_f
fy = (li + 16.0f) / 116.0f;
y = fy * fy * fy;
}
float fxz[] = { ai / 500.0f + fy, fy - bi / 200.0f };
for (int j = 0; j < 2; j++)
if (fxz[j] <= fThresh)
fxz[j] = (fxz[j] - 16.0f / 116.0f) / 7.787f;
else
fxz[j] = fxz[j] * fxz[j] * fxz[j];
float x = fxz[0], z = fxz[1];
float ro = clip(C0 * x + C1 * y + C2 * z);
float go = clip(C3 * x + C4 * y + C5 * z);
float bo = clip(C6 * x + C7 * y + C8 * z);
// CV_Assert(ro >= 0.0f && ro <= 1.0f);
// CV_Assert(go >= 0.0f && go <= 1.0f);
// CV_Assert(bo >= 0.0f && bo <= 1.0f);
if (gammaTab)
{
ro = splineInterpolate(ro * gscale, gammaTab, GAMMA_TAB_SIZE);
go = splineInterpolate(go * gscale, gammaTab, GAMMA_TAB_SIZE);
bo = splineInterpolate(bo * gscale, gammaTab, GAMMA_TAB_SIZE);
}
dst[0] = ro, dst[1] = go, dst[2] = bo;
if( dcn == 4 )
dst[3] = alpha;
}
}
int dstcn;
float coeffs[9];
bool srgb;
int blueInd;
};
#undef clip
struct Lab2RGB_b

View File

@@ -55,7 +55,7 @@ calcMinEigenVal( const Mat& _cov, Mat& _dst )
#if CV_SSE
volatile bool simd = checkHardwareSupport(CV_CPU_SSE);
#endif
if( _cov.isContinuous() && _dst.isContinuous() )
{
size.width *= size.height;
@@ -112,7 +112,7 @@ calcHarris( const Mat& _cov, Mat& _dst, double k )
#if CV_SSE
volatile bool simd = checkHardwareSupport(CV_CPU_SSE);
#endif
if( _cov.isContinuous() && _dst.isContinuous() )
{
size.width *= size.height;
@@ -161,7 +161,7 @@ calcHarris( const Mat& _cov, Mat& _dst, double k )
}
}
void eigen2x2( const float* cov, float* dst, int n )
{
for( int j = 0; j < n; j++ )
@@ -169,16 +169,16 @@ void eigen2x2( const float* cov, float* dst, int n )
double a = cov[j*3];
double b = cov[j*3+1];
double c = cov[j*3+2];
double u = (a + c)*0.5;
double v = std::sqrt((a - c)*(a - c)*0.25 + b*b);
double l1 = u + v;
double l2 = u - v;
double x = b;
double y = l1 - a;
double e = fabs(x);
if( e + fabs(y) < 1e-4 )
{
y = b;
@@ -190,16 +190,16 @@ void eigen2x2( const float* cov, float* dst, int n )
x *= e, y *= e;
}
}
double d = 1./std::sqrt(x*x + y*y + DBL_EPSILON);
dst[6*j] = (float)l1;
dst[6*j + 2] = (float)(x*d);
dst[6*j + 3] = (float)(y*d);
x = b;
y = l2 - a;
e = fabs(x);
if( e + fabs(y) < 1e-4 )
{
y = b;
@@ -211,7 +211,7 @@ void eigen2x2( const float* cov, float* dst, int n )
x *= e, y *= e;
}
}
d = 1./std::sqrt(x*x + y*y + DBL_EPSILON);
dst[6*j + 1] = (float)l2;
dst[6*j + 4] = (float)(x*d);
@@ -250,7 +250,7 @@ cornerEigenValsVecs( const Mat& src, Mat& eigenv, int block_size,
#ifdef HAVE_TEGRA_OPTIMIZATION
if (tegra::cornerEigenValsVecs(src, eigenv, block_size, aperture_size, op_type, k, borderType))
return;
#endif
#endif
int depth = src.depth();
double scale = (double)(1 << ((aperture_size > 0 ? aperture_size : 3) - 1)) * block_size;
@@ -331,7 +331,7 @@ void cv::cornerEigenValsAndVecs( InputArray _src, OutputArray _dst, int blockSiz
Mat src = _src.getMat();
Size dsz = _dst.size();
int dtype = _dst.type();
if( dsz.height != src.rows || dsz.width*CV_MAT_CN(dtype) != src.cols*6 || CV_MAT_DEPTH(dtype) != CV_32F )
_dst.create( src.size(), CV_32FC(6) );
Mat dst = _dst.getMat();
@@ -346,7 +346,7 @@ void cv::preCornerDetect( InputArray _src, OutputArray _dst, int ksize, int bord
CV_Assert( src.type() == CV_8UC1 || src.type() == CV_32FC1 );
_dst.create( src.size(), CV_32F );
Mat dst = _dst.getMat();
Sobel( src, Dx, CV_32F, 1, 0, ksize, 1, 0, borderType );
Sobel( src, Dy, CV_32F, 0, 1, ksize, 1, 0, borderType );
Sobel( src, D2x, CV_32F, 2, 0, ksize, 1, 0, borderType );
@@ -368,7 +368,7 @@ void cv::preCornerDetect( InputArray _src, OutputArray _dst, int ksize, int bord
const float* d2xdata = (const float*)(D2x.data + i*D2x.step);
const float* d2ydata = (const float*)(D2y.data + i*D2y.step);
const float* dxydata = (const float*)(Dxy.data + i*Dxy.step);
for( j = 0; j < size.width; j++ )
{
float dx = dxdata[j];

View File

@@ -46,7 +46,7 @@ cvFindCornerSubPix( const void* srcarr, CvPoint2D32f* corners,
CvTermCriteria criteria )
{
cv::AutoBuffer<float> buffer;
const int MAX_ITERS = 100;
const float drv[] = { -1.f, 0.f, 1.f };
float *maskX;
@@ -257,7 +257,7 @@ void cv::cornerSubPix( InputArray _image, InputOutputArray _corners,
CV_Assert( ncorners >= 0 && corners.depth() == CV_32F );
Mat image = _image.getMat();
CvMat c_image = image;
cvFindCornerSubPix( &c_image, (CvPoint2D32f*)corners.data, ncorners,
winSize, zeroZone, criteria );
}

View File

@@ -173,7 +173,7 @@ static void getSobelKernels( OutputArray _kx, OutputArray _ky,
_kx.create(ksizeX, 1, ktype, -1, true);
_ky.create(ksizeY, 1, ktype, -1, true);
Mat kx = _kx.getMat();
Mat ky = _ky.getMat();
Mat ky = _ky.getMat();
if( _ksize % 2 == 0 || _ksize > 31 )
CV_Error( CV_StsOutOfRange, "The kernel size must be odd and not larger than 31" );
@@ -484,7 +484,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k
}
}
#endif
void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
@@ -505,7 +505,7 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
return;
}
#endif
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if(dx < 3 && dy < 3 && src.channels() == 1 && borderType == 1)
{
@@ -544,7 +544,7 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
if (tegra::scharr(src, dst, dx, dy, borderType))
return;
#endif
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
if(dx < 2 && dy < 2 && src.channels() == 1 && borderType == 1)
{
@@ -572,24 +572,24 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy,
void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
double scale, double delta, int borderType )
{
Mat src = _src.getMat();
Mat src = _src.getMat();
if (ddepth < 0)
ddepth = src.depth();
_dst.create( src.size(), CV_MAKETYPE(ddepth, src.channels()) );
Mat dst = _dst.getMat();
#ifdef HAVE_TEGRA_OPTIMIZATION
if (scale == 1.0 && delta == 0)
{
if (ksize == 1 && tegra::laplace1(src, dst, borderType))
if (ksize == 1 && tegra::laplace1(src, dst, borderType))
return;
if (ksize == 3 && tegra::laplace3(src, dst, borderType))
if (ksize == 3 && tegra::laplace3(src, dst, borderType))
return;
if (ksize == 5 && tegra::laplace5(src, dst, borderType))
if (ksize == 5 && tegra::laplace5(src, dst, borderType))
return;
}
#endif
if( ksize == 1 || ksize == 3 )
{
float K[2][9] =
@@ -616,7 +616,7 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
int dy0 = std::min(std::max((int)(STRIPE_SIZE/(getElemSize(src.type())*src.cols)), 1), src.rows);
Ptr<FilterEngine> fx = createSeparableLinearFilter(src.type(),
wtype, kd, ks, Point(-1,-1), 0, borderType, borderType, Scalar() );
wtype, kd, ks, Point(-1,-1), 0, borderType, borderType, Scalar() );
Ptr<FilterEngine> fy = createSeparableLinearFilter(src.type(),
wtype, ks, kd, Point(-1,-1), 0, borderType, borderType, Scalar() );

View File

@@ -51,7 +51,7 @@ icvInitTopBottom( int* temp, int tempstep, CvSize size, int border )
{
int* ttop = (int*)(temp + i*tempstep);
int* tbottom = (int*)(temp + (size.height + border*2 - i - 1)*tempstep);
for( j = 0; j < size.width + border*2; j++ )
{
ttop[j] = ICV_INIT_DIST0;
@@ -87,7 +87,7 @@ icvDistanceTransform_3x3_C1R( const uchar* src, int srcstep, int* temp,
for( j = 0; j < BORDER; j++ )
tmp[-j-1] = tmp[size.width + j] = ICV_INIT_DIST0;
for( j = 0; j < size.width; j++ )
{
if( !s[j] )
@@ -111,7 +111,7 @@ icvDistanceTransform_3x3_C1R( const uchar* src, int srcstep, int* temp,
{
float* d = (float*)(dist + i*dststep);
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
for( j = size.width - 1; j >= 0; j-- )
{
int t0 = tmp[j];
@@ -160,7 +160,7 @@ icvDistanceTransform_5x5_C1R( const uchar* src, int srcstep, int* temp,
for( j = 0; j < BORDER; j++ )
tmp[-j-1] = tmp[size.width + j] = ICV_INIT_DIST0;
for( j = 0; j < size.width; j++ )
{
if( !s[j] )
@@ -192,7 +192,7 @@ icvDistanceTransform_5x5_C1R( const uchar* src, int srcstep, int* temp,
{
float* d = (float*)(dist + i*dststep);
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
for( j = size.width - 1; j >= 0; j-- )
{
int t0 = tmp[j];
@@ -230,7 +230,7 @@ icvDistanceTransformEx_5x5_C1R( const uchar* src, int srcstep, int* temp,
CvSize size, const float* metrics )
{
const int BORDER = 2;
int i, j;
const int HV_DIST = CV_FLT_TO_FIX( metrics[0], ICV_DIST_SHIFT );
const int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], ICV_DIST_SHIFT );
@@ -253,7 +253,7 @@ icvDistanceTransformEx_5x5_C1R( const uchar* src, int srcstep, int* temp,
for( j = 0; j < BORDER; j++ )
tmp[-j-1] = tmp[size.width + j] = ICV_INIT_DIST0;
for( j = 0; j < size.width; j++ )
{
if( !s[j] )
@@ -327,7 +327,7 @@ icvDistanceTransformEx_5x5_C1R( const uchar* src, int srcstep, int* temp,
float* d = (float*)(dist + i*dststep);
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
int* lls = (int*)(labels + i*lstep);
for( j = size.width - 1; j >= 0; j-- )
{
int t0 = tmp[j];
@@ -452,7 +452,7 @@ struct DTColumnInvoker
sat_tab = _sat_tab + src->rows*2 + 1;
sqr_tab = _sqr_tab;
}
void operator()( const BlockedRange& range ) const
{
int i, i1 = range.begin(), i2 = range.end();
@@ -460,19 +460,19 @@ struct DTColumnInvoker
size_t sstep = src->step, dstep = dst->step/sizeof(float);
AutoBuffer<int> _d(m);
int* d = _d;
for( i = i1; i < i2; i++ )
{
const uchar* sptr = src->data.ptr + i + (m-1)*sstep;
float* dptr = dst->data.fl + i;
int j, dist = m-1;
for( j = m-1; j >= 0; j--, sptr -= sstep )
{
dist = (dist + 1) & (sptr[0] == 0 ? 0 : -1);
d[j] = dist;
}
dist = m-1;
for( j = 0; j < m; j++, dptr += dstep )
{
@@ -482,14 +482,14 @@ struct DTColumnInvoker
}
}
}
const CvMat* src;
CvMat* dst;
const int* sat_tab;
const float* sqr_tab;
};
struct DTRowInvoker
{
DTRowInvoker( CvMat* _dst, const float* _sqr_tab, const float* _inv_tab )
@@ -498,7 +498,7 @@ struct DTRowInvoker
sqr_tab = _sqr_tab;
inv_tab = _inv_tab;
}
void operator()( const BlockedRange& range ) const
{
const float inf = 1e15f;
@@ -508,22 +508,22 @@ struct DTRowInvoker
float* f = (float*)(uchar*)_buf;
float* z = f + n;
int* v = alignPtr((int*)(z + n + 1), sizeof(int));
for( i = i1; i < i2; i++ )
{
float* d = (float*)(dst->data.ptr + i*dst->step);
int p, q, k;
v[0] = 0;
z[0] = -inf;
z[1] = inf;
f[0] = d[0];
for( q = 1, k = 0; q < n; q++ )
{
float fq = d[q];
f[q] = fq;
for(;;k--)
{
p = v[k];
@@ -538,7 +538,7 @@ struct DTRowInvoker
}
}
}
for( q = 0, k = 0; q < n; q++ )
{
while( z[k+1] < q )
@@ -548,7 +548,7 @@ struct DTRowInvoker
}
}
}
CvMat* dst;
const float* sqr_tab;
const float* inv_tab;
@@ -560,7 +560,7 @@ static void
icvTrueDistTrans( const CvMat* src, CvMat* dst )
{
const float inf = 1e15f;
if( !CV_ARE_SIZES_EQ( src, dst ))
CV_Error( CV_StsUnmatchedSizes, "" );
@@ -586,11 +586,11 @@ icvTrueDistTrans( const CvMat* src, CvMat* dst )
for( ; i <= m*3; i++ )
sat_tab[i] = i - shift;
cv::parallel_for(cv::BlockedRange(0, n), cv::DTColumnInvoker(src, dst, sat_tab, sqr_tab));
cv::parallel_for(cv::BlockedRange(0, n), cv::DTColumnInvoker(src, dst, sat_tab, sqr_tab));
// stage 2: compute modified distance transform for each row
float* inv_tab = sqr_tab + n;
inv_tab[0] = sqr_tab[0] = 0.f;
for( i = 1; i < n; i++ )
{
@@ -634,7 +634,7 @@ icvDistanceATS_L1_8u( const CvMat* src, CvMat* dst )
int a;
uchar lut[256];
int x, y;
const uchar *sbase = src->data.ptr;
uchar *dbase = dst->data.ptr;
int srcstep = src->step;
@@ -738,7 +738,7 @@ cvDistTransform( const void* srcarr, void* dstarr,
icvTrueDistTrans( src, dst );
return;
}
if( labels )
{
labels = cvGetMat( labels, &lstub );
@@ -789,7 +789,7 @@ cvDistTransform( const void* srcarr, void* dstarr,
else
{
cvZero( labels );
if( labelType == CV_DIST_LABEL_CCOMP )
{
CvSeq *contours = 0;
@@ -799,7 +799,7 @@ cvDistTransform( const void* srcarr, void* dstarr,
cvCmpS( src_copy, 0, src_copy, CV_CMP_EQ );
cvFindContours( src_copy, st, &contours, sizeof(CvContour),
CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(-border, -border));
for( int label = 1; contours != 0; contours = contours->h_next, label++ )
{
CvScalar area_color = cvScalarAll(label);
@@ -813,7 +813,7 @@ cvDistTransform( const void* srcarr, void* dstarr,
{
const uchar* srcptr = src->data.ptr + src->step*i;
int* labelptr = (int*)(labels->data.ptr + labels->step*i);
for( int j = 0; j < src->cols; j++ )
if( srcptr[j] == 0 )
labelptr[j] = k++;

View File

@@ -48,7 +48,7 @@
An implementation of the Earth Movers Distance.
Based of the solution for the Transportation problem as described in
"Introduction to Mathematical Programming" by F. S. Hillier and
"Introduction to Mathematical Programming" by F. S. Hillier and
G. J. Lieberman, McGraw-Hill, 1990.
Copyright (C) 1998 Yossi Rubner
@@ -347,7 +347,7 @@ static int icvInitEMD( const float* signature1, int size1,
sizeof( CvNode2D * ) + /* cols_x & rows_x */
sizeof( CvNode1D ) + /* u & v */
sizeof( float ) + /* s & d */
sizeof( int ) + sizeof(CvNode2D*)) + /* idx1 & idx2 */
sizeof( int ) + sizeof(CvNode2D*)) + /* idx1 & idx2 */
(size1+1) * (sizeof( float * ) + sizeof( char * ) + /* rows pointers for */
sizeof( float * )) + 256; /* cost, is_x and delta */
@@ -384,7 +384,7 @@ static int icvInitEMD( const float* signature1, int size1,
s_sum += weight;
state->s[ssize] = weight;
state->idx1[ssize++] = i;
}
else if( weight < 0 )
CV_Error(CV_StsOutOfRange, "");
@@ -416,7 +416,7 @@ static int icvInitEMD( const float* signature1, int size1,
{
state->s[ssize] = -diff;
state->idx1[ssize++] = -1;
}
}
else
{
state->d[dsize] = diff;
@@ -525,7 +525,7 @@ static int icvInitEMD( const float* signature1, int size1,
}
state->max_cost = max_cost;
memset( buffer, 0, buffer_end - buffer );
state->rows_x = (CvNode2D **) buffer;
@@ -1144,7 +1144,7 @@ float cv::EMD( InputArray _signature1, InputArray _signature2,
{
Mat signature1 = _signature1.getMat(), signature2 = _signature2.getMat();
Mat cost = _cost.getMat(), flow;
CvMat _csignature1 = signature1;
CvMat _csignature2 = signature2;
CvMat _ccost = cost, _cflow;
@@ -1154,7 +1154,7 @@ float cv::EMD( InputArray _signature1, InputArray _signature2,
flow = _flow.getMat();
_cflow = flow;
}
return cvCalcEMD2( &_csignature1, &_csignature2, distType, 0, cost.empty() ? 0 : &_ccost,
_flow.needed() ? &_cflow : 0, lowerBound, 0 );
}

View File

@@ -51,14 +51,14 @@ template<typename T> struct greaterThanPtr
};
}
void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
int maxCorners, double qualityLevel, double minDistance,
InputArray _mask, int blockSize,
bool useHarrisDetector, double harrisK )
{
Mat image = _image.getMat(), mask = _mask.getMat();
CV_Assert( qualityLevel > 0 && minDistance >= 0 && maxCorners >= 0 );
CV_Assert( mask.empty() || (mask.type() == CV_8UC1 && mask.size() == image.size()) );
@@ -116,7 +116,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
int y = (int)(ofs / eig.step);
int x = (int)((ofs - y*eig.step)/sizeof(float));
bool good = true;
bool good = true;
int x_cell = x / cell_size;
int y_cell = y / cell_size;
@@ -135,7 +135,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
for( int yy = y1; yy <= y2; yy++ )
{
for( int xx = x1; xx <= x2; xx++ )
{
{
vector <Point2f> &m = grid[yy*grid_width + xx];
if( m.size() )
@@ -151,7 +151,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
goto break_out;
}
}
}
}
}
}
@@ -185,7 +185,7 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
break;
}
}
Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F);
/*

View File

@@ -56,34 +56,34 @@ cv::Mat cv::getGaborKernel( Size ksize, double sigma, double theta,
int nstds = 3;
int xmin, xmax, ymin, ymax;
double c = cos(theta), s = sin(theta);
if( ksize.width > 0 )
xmax = ksize.width/2;
else
xmax = cvRound(std::max(fabs(nstds*sigma_x*c), fabs(nstds*sigma_y*s)));
if( ksize.height > 0 )
ymax = ksize.height/2;
else
ymax = cvRound(std::max(fabs(nstds*sigma_x*s), fabs(nstds*sigma_y*c)));
xmin = -xmax;
ymin = -ymax;
CV_Assert( ktype == CV_32F || ktype == CV_64F );
Mat kernel(ymax - ymin + 1, xmax - xmin + 1, ktype);
double scale = 1;
double ex = -0.5/(sigma_x*sigma_x);
double ey = -0.5/(sigma_y*sigma_y);
double cscale = CV_PI*2/lambd;
for( int y = ymin; y <= ymax; y++ )
for( int x = xmin; x <= xmax; x++ )
{
double xr = x*c + y*s;
double yr = -x*s + y*c;
double v = scale*exp(ex*xr*xr + ey*yr*yr)*cos(cscale*xr + psi);
if( ktype == CV_32F )
kernel.at<float>(ymax - y, xmax - x) = (float)v;

View File

@@ -131,7 +131,7 @@ CV_IMPL double
cvPointPolygonTest( const CvArr* _contour, CvPoint2D32f pt, int measure_dist )
{
double result = 0;
CvSeqBlock block;
CvContour header;
CvSeq* contour = (CvSeq*)_contour;
@@ -256,7 +256,7 @@ cvPointPolygonTest( const CvArr* _contour, CvPoint2D32f pt, int measure_dist )
for( i = 0; i < total; i++ )
{
double dx, dy, dx1, dy1, dx2, dy2, dist_num, dist_denom = 1;
v0 = v;
if( is_float )
{
@@ -267,11 +267,11 @@ cvPointPolygonTest( const CvArr* _contour, CvPoint2D32f pt, int measure_dist )
CV_READ_SEQ_ELEM( iv, reader );
v = cvPointTo32f( iv );
}
dx = v.x - v0.x; dy = v.y - v0.y;
dx1 = pt.x - v0.x; dy1 = pt.y - v0.y;
dx2 = pt.x - v.x; dy2 = pt.y - v.y;
if( dx1*dx + dy1*dy <= 0 )
dist_num = dx1*dx1 + dy1*dy1;
else if( dx2*dx + dy2*dy >= 0 )
@@ -316,7 +316,7 @@ cvPointPolygonTest( const CvArr* _contour, CvPoint2D32f pt, int measure_dist )
This code is described in "Computational Geometry in C" (Second Edition),
Chapter 7. It is not written to be comprehensible without the
explanation in that book.
Written by Joseph O'Rourke.
Last modified: December 1997
Questions to orourke@cs.smith.edu.
@@ -345,7 +345,7 @@ static int areaSign( Point2f a, Point2f b, Point2f c )
static bool between( Point2f a, Point2f b, Point2f c )
{
Point2f ba, ca;
// If ab not vertical, check betweenness on x; else on y.
if ( a.x != b.x )
return ((a.x <= c.x) && (c.x <= b.x)) ||
@@ -394,38 +394,38 @@ static char segSegInt( Point2f a, Point2f b, Point2f c, Point2f d, Point2f& p, P
double s, t; // The two parameters of the parametric eqns.
double num, denom; // Numerator and denoninator of equations.
char code = '?'; // Return char characterizing intersection.
denom = a.x * (double)( d.y - c.y ) +
b.x * (double)( c.y - d.y ) +
d.x * (double)( b.y - a.y ) +
c.x * (double)( a.y - b.y );
// If denom is zero, then segments are parallel: handle separately.
if (denom == 0.0)
return parallelInt(a, b, c, d, p, q);
num = a.x * (double)( d.y - c.y ) +
c.x * (double)( a.y - d.y ) +
d.x * (double)( c.y - a.y );
if ( (num == 0.0) || (num == denom) ) code = 'v';
s = num / denom;
num = -( a.x * (double)( c.y - b.y ) +
b.x * (double)( a.y - c.y ) +
c.x * (double)( b.y - a.y ) );
if ( (num == 0.0) || (num == denom) ) code = 'v';
t = num / denom;
if ( (0.0 < s) && (s < 1.0) &&
(0.0 < t) && (t < 1.0) )
code = '1';
else if ( (0.0 > s) || (s > 1.0) ||
(0.0 > t) || (t > 1.0) )
code = '0';
p.x = (float)(a.x + s*(b.x - a.x));
p.y = (float)(a.y + s*(b.y - a.y));
return code;
}
@@ -446,7 +446,7 @@ static int advance( int a, int *aa, int n, bool inside, Point2f v, Point2f*& res
*result++ = v;
(*aa)++;
return (a+1) % n;
}
}
static void addSharedSeg( Point2f p, Point2f q, Point2f*& result )
{
@@ -469,19 +469,19 @@ static int intersectConvexConvex_( const Point2f* P, int n, const Point2f* Q, in
bool FirstPoint=true;// Is this the first point? (used to initialize).
Point2f p0; // The first point.
*result++ = Point2f(FLT_MAX, FLT_MAX);
do
{
// Computations of key variables.
int a1 = (a + n - 1) % n; // a-1, b-1 (resp.)
int b1 = (b + m - 1) % m;
Point2f A = P[a] - P[a1], B = Q[b] - Q[b1]; // directed edges on P and Q (resp.)
int cross = areaSign( Origin, A, B ); // sign of z-component of A x B
int aHB = areaSign( Q[b1], Q[b], P[a] ); // a in H(b).
int bHA = areaSign( P[a1], P[a], Q[b] ); // b in H(A);
// If A & B intersect, update inflag.
Point2f p, q;
int code = segSegInt( P[a1], P[a], Q[b1], Q[b], p, q );
@@ -496,20 +496,20 @@ static int intersectConvexConvex_( const Point2f* P, int n, const Point2f* Q, in
}
inflag = inOut( p, inflag, aHB, bHA, result );
}
//-----Advance rules-----
// Special case: A & B overlap and oppositely oriented.
if( code == 'e' && A.ddot(B) < 0 )
{
addSharedSeg( p, q, result );
return (int)(result - result0);
}
// Special case: A & B parallel and separated.
if( cross == 0 && aHB < 0 && bHA < 0 )
return (int)(result - result0);
// Special case: A & B collinear.
else if ( cross == 0 && aHB == 0 && bHA == 0 ) {
// Advance but do not output point.
@@ -518,7 +518,7 @@ static int intersectConvexConvex_( const Point2f* P, int n, const Point2f* Q, in
else
a = advance( a, &aa, n, inflag == Pin, P[a], result );
}
// Generic cases.
else if( cross >= 0 )
{
@@ -537,14 +537,14 @@ static int intersectConvexConvex_( const Point2f* P, int n, const Point2f* Q, in
// Quit when both adv. indices have cycled, or one has cycled twice.
}
while ( ((aa < n) || (ba < m)) && (aa < 2*n) && (ba < 2*m) );
// Deal with special cases: not implemented.
if( inflag == Unknown )
{
// The boundaries of P and Q do not cross.
// ...
}
int i, nr = (int)(result - result0);
double area = 0;
Point2f prev = result0[nr-1];
@@ -554,44 +554,44 @@ static int intersectConvexConvex_( const Point2f* P, int n, const Point2f* Q, in
area += (double)prev.x*result0[i].y - (double)prev.y*result0[i].x;
prev = result0[i];
}
*_area = (float)(area*0.5);
if( result0[nr-2] == result0[0] && nr > 1 )
nr--;
return nr-1;
}
}
float cv::intersectConvexConvex( InputArray _p1, InputArray _p2, OutputArray _p12, bool handleNested )
{
Mat p1 = _p1.getMat(), p2 = _p2.getMat();
CV_Assert( p1.depth() == CV_32S || p1.depth() == CV_32F );
CV_Assert( p2.depth() == CV_32S || p2.depth() == CV_32F );
int n = p1.checkVector(2, p1.depth(), true);
int m = p2.checkVector(2, p2.depth(), true);
CV_Assert( n >= 0 && m >= 0 );
if( n < 2 || m < 2 )
{
_p12.release();
return 0.f;
}
AutoBuffer<Point2f> _result(n*2 + m*2 + 1);
Point2f *fp1 = _result, *fp2 = fp1 + n;
Point2f* result = fp2 + m;
int orientation = 0;
for( int k = 1; k <= 2; k++ )
{
Mat& p = k == 1 ? p1 : p2;
int len = k == 1 ? n : m;
Point2f* dst = k == 1 ? fp1 : fp2;
Mat temp(p.size(), CV_MAKETYPE(CV_32F, p.channels()), dst);
p.convertTo(temp, CV_32F);
CV_Assert( temp.ptr<Point2f>() == dst );
@@ -610,7 +610,7 @@ float cv::intersectConvexConvex( InputArray _p1, InputArray _p2, OutputArray _p1
}
}
}
float area = 0.f;
int nr = intersectConvexConvex_(fp1, n, fp2, m, result, &area);
if( nr == 0 )
@@ -620,7 +620,7 @@ float cv::intersectConvexConvex( InputArray _p1, InputArray _p2, OutputArray _p1
_p12.release();
return 0.f;
}
if( pointPolygonTest(_InputArray(fp1, n), fp2[0], false) >= 0 )
{
result = fp2;
@@ -638,7 +638,7 @@ float cv::intersectConvexConvex( InputArray _p1, InputArray _p2, OutputArray _p1
}
area = (float)contourArea(_InputArray(result, nr), false);
}
if( _p12.needed() )
{
Mat temp(nr, 1, CV_32FC2, result);
@@ -662,7 +662,7 @@ static void testConvConv()
100, 100,
0, 100,
};
static const int Q1[] =
{
100, 80,
@@ -670,7 +670,7 @@ static void testConvConv()
50, 50,
100, 50
};
static const int P2[] =
{
0, 0,
@@ -679,7 +679,7 @@ static void testConvConv()
100, 200,
0, 100
};
static const int Q2[] =
{
100, 100,
@@ -687,7 +687,7 @@ static void testConvConv()
300, 200,
100, 200
};
static const int P3[] =
{
0, 0,
@@ -695,7 +695,7 @@ static void testConvConv()
100, 100,
0, 100
};
static const int Q3[] =
{
50, 50,
@@ -703,7 +703,7 @@ static void testConvConv()
150, 150,
50, 150
};
static const int P4[] =
{
0, 160,
@@ -717,7 +717,7 @@ static void testConvConv()
70, 320,
30, 290
};
static const int Q4[] =
{
160, -30,
@@ -726,12 +726,12 @@ static void testConvConv()
0, 220,
30, 100
};
static const void* PQs[] =
{
P1, Q1, P2, Q2, P3, Q3, P4, Q4
};
static const int lens[] =
{
CV_DIM(P1), CV_DIM(Q1),
@@ -739,36 +739,36 @@ static void testConvConv()
CV_DIM(P3), CV_DIM(Q3),
CV_DIM(P4), CV_DIM(Q4)
};
Mat img(800, 800, CV_8UC3);
for( int i = 0; i < CV_DIM(PQs)/2; i++ )
{
Mat Pm = Mat(lens[i*2]/2, 1, CV_32SC2, (void*)PQs[i*2]) + Scalar(100, 100);
Mat Qm = Mat(lens[i*2+1]/2, 1, CV_32SC2, (void*)PQs[i*2+1]) + Scalar(100, 100);
Point* P = Pm.ptr<Point>();
Point* Q = Qm.ptr<Point>();
flip(Pm, Pm, 0);
flip(Qm, Qm, 0);
Mat Rm;
intersectConvexConvex(Pm, Qm, Rm);
std::cout << Rm << std::endl << std::endl;
img = Scalar::all(0);
polylines(img, Pm, true, Scalar(0,255,0), 1, CV_AA, 0);
polylines(img, Qm, true, Scalar(0,0,255), 1, CV_AA, 0);
Mat temp;
Rm.convertTo(temp, CV_32S, 256);
polylines(img, temp, true, Scalar(128, 255, 255), 3, CV_AA, 8);
namedWindow("test", 1);
imshow("test", img);
waitKey();
}
}
*/
/* End of file. */

View File

@@ -119,7 +119,7 @@ double GMM::operator()( int ci, const Vec3d color ) const
double res = 0;
if( coefs[ci] > 0 )
{
CV_Assert( covDeterms[ci] > std::numeric_limits<double>::epsilon() );
CV_Assert( covDeterms[ci] > std::numeric_limits<double>::epsilon() );
Vec3d diff = color;
double* m = mean + 3*ci;
diff[0] -= m[0]; diff[1] -= m[1]; diff[2] -= m[2];
@@ -138,7 +138,7 @@ int GMM::whichComponent( const Vec3d color ) const
for( int ci = 0; ci < componentsCount; ci++ )
{
double p = (*this)( ci, color );
double p = (*this)( ci, color );
if( p > max )
{
k = ci;
@@ -406,7 +406,7 @@ static void assignGMMsComponents( const Mat& img, const Mat& mask, const GMM& bg
for( p.x = 0; p.x < img.cols; p.x++ )
{
Vec3d color = img.at<Vec3b>(p);
compIdxs.at<int>(p) = mask.at<uchar>(p) == GC_BGD || mask.at<uchar>(p) == GC_PR_BGD ?
compIdxs.at<int>(p) = mask.at<uchar>(p) == GC_BGD || mask.at<uchar>(p) == GC_PR_BGD ?
bgdGMM.whichComponent(color) : fgdGMM.whichComponent(color);
}
}

View File

@@ -251,12 +251,12 @@ public:
ify(_ify)
{
}
virtual void operator() (const Range& range) const
{
Size ssize = src.size(), dsize = dst.size();
int y, x, pix_size = (int)src.elemSize();
for( y = range.start; y < range.end; y++ )
{
uchar* D = dst.data + dst.step*y;
@@ -327,7 +327,7 @@ public:
}
}
}
private:
const Mat src;
Mat dst;
@@ -354,7 +354,7 @@ resizeNN( const Mat& src, Mat& dst, double fx, double fy )
int sx = cvFloor(x*ifx);
x_ofs[x] = std::min(sx, ssize.width-1)*pix_size;
}
Range range(0, dsize.height);
resizeNNInvoker invoker(src, dst, x_ofs, pix_size4, ify);
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
@@ -1132,7 +1132,7 @@ public:
typedef typename HResize::value_type T;
typedef typename HResize::buf_type WT;
typedef typename HResize::alpha_type AT;
resizeGeneric_Invoker(const Mat& _src, Mat &_dst, const int *_xofs, const int *_yofs,
const AT* _alpha, const AT* __beta, const Size& _ssize, const Size &_dsize,
int _ksize, int _xmin, int _xmax) :
@@ -1141,13 +1141,13 @@ public:
ksize(_ksize), xmin(_xmin), xmax(_xmax)
{
}
virtual void operator() (const Range& range) const
{
int dy, cn = src.channels();
HResize hresize;
VResize vresize;
int bufstep = (int)alignSize(dsize.width, 16);
AutoBuffer<WT> _buffer(bufstep*ksize);
const T* srows[MAX_ESIZE]={0};
@@ -1159,9 +1159,9 @@ public:
prev_sy[k] = -1;
rows[k] = (WT*)_buffer + bufstep*k;
}
const AT* beta = _beta + ksize * range.start;
for( dy = range.start; dy < range.end; dy++, beta += ksize )
{
int sy0 = yofs[dy], k0=ksize, k1=0, ksize2 = ksize/2;
@@ -1190,7 +1190,7 @@ public:
vresize( (const WT**)rows, (T*)(dst.data + dst.step*dy), beta, dsize.width );
}
}
private:
Mat src;
Mat dst;
@@ -1218,7 +1218,7 @@ static void resizeGeneric_( const Mat& src, Mat& dst,
xmin *= cn;
xmax *= cn;
// image resize is a separable operation. In case of not too strong
Range range(0, dsize.height);
resizeGeneric_Invoker<HResize, VResize> invoker(src, dst, xofs, yofs, (const AT*)_alpha, beta,
ssize, dsize, ksize, xmin, xmax);
@@ -1238,18 +1238,18 @@ struct ResizeAreaFastVec
{
ResizeAreaFastVec(int _scale_x, int _scale_y, int _cn, int _step/*, const int* _ofs*/) :
scale_x(_scale_x), scale_y(_scale_y), cn(_cn), step(_step)/*, ofs(_ofs)*/
{
fast_mode = scale_x == 2 && scale_y == 2 && (cn == 1 || cn == 3 || cn == 4);
{
fast_mode = scale_x == 2 && scale_y == 2 && (cn == 1 || cn == 3 || cn == 4);
}
int operator() (const T* S, T* D, int w) const
{
if( !fast_mode )
return 0;
const T* nextS = (const T*)((const uchar*)S + step);
int dx = 0;
if (cn == 1)
for( ; dx < w; ++dx )
{
@@ -1276,10 +1276,10 @@ struct ResizeAreaFastVec
D[dx+3] = (T)((S[index+3] + S[index+7] + nextS[index+3] + nextS[index+7] + 2) >> 2);
}
}
return dx;
}
private:
int scale_x, scale_y;
int cn;
@@ -1298,7 +1298,7 @@ public:
scale_y(_scale_y), ofs(_ofs), xofs(_xofs)
{
}
virtual void operator() (const Range& range) const
{
Size ssize = src.size(), dsize = dst.size();
@@ -1309,15 +1309,15 @@ public:
dsize.width *= cn;
ssize.width *= cn;
int dy, dx, k = 0;
VecOp vop(scale_x, scale_y, src.channels(), (int)src.step/*, area_ofs*/);
for( dy = range.start; dy < range.end; dy++ )
{
T* D = (T*)(dst.data + dst.step*dy);
int sy0 = dy*scale_y;
int w = sy0 + scale_y <= ssize.height ? dwidth1 : 0;
if( sy0 >= ssize.height )
{
for( dx = 0; dx < dsize.width; dx++ )
@@ -1366,7 +1366,7 @@ public:
}
}
}
private:
Mat src;
Mat dst;
@@ -1379,7 +1379,7 @@ static void resizeAreaFast_( const Mat& src, Mat& dst, const int* ofs, const int
int scale_x, int scale_y )
{
Range range(0, dst.rows);
resizeAreaFast_Invoker<T, WT, VecOp> invoker(src, dst, scale_x,
resizeAreaFast_Invoker<T, WT, VecOp> invoker(src, dst, scale_x,
scale_y, ofs, xofs);
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
}
@@ -1395,16 +1395,16 @@ class resizeArea_Invoker :
public ParallelLoopBody
{
public:
resizeArea_Invoker(const Mat& _src, Mat& _dst, const DecimateAlpha* _xofs,
int _xofs_count, double _scale_y_, const int* _cur_dy_ofs,
resizeArea_Invoker(const Mat& _src, Mat& _dst, const DecimateAlpha* _xofs,
int _xofs_count, double _scale_y_, const int* _cur_dy_ofs,
const std::vector<std::pair<int, int> >& _bands) :
ParallelLoopBody(), src(_src), dst(_dst), xofs(_xofs),
ParallelLoopBody(), src(_src), dst(_dst), xofs(_xofs),
xofs_count(_xofs_count), scale_y_(_scale_y_),
cur_dy_ofs(_cur_dy_ofs), bands(_bands)
{
}
void resize_single_band(const Range& range) const
void resize_single_band(const Range& range) const
{
Size ssize = src.size(), dsize = dst.size();
int cn = src.channels();
@@ -1413,11 +1413,11 @@ public:
WT *buf = _buffer, *sum = buf + dsize.width;
int k = 0, sy = 0, dx = 0, cur_dy = 0;
WT scale_y = (WT)scale_y_;
CV_Assert( cn <= 4 );
for( dx = 0; dx < dsize.width; dx++ )
buf[dx] = sum[dx] = 0;
cur_dy = cur_dy_ofs[range.start];
for (sy = range.start; sy < range.end; sy++)
{
@@ -1463,7 +1463,7 @@ public:
t1 = buf[dxn+3] + S[sxn+3]*alpha;
buf[dxn+2] = t0; buf[dxn+3] = t1;
}
if( (cur_dy + 1)*scale_y <= sy + 1 || sy == ssize.height - 1 )
{
WT beta = std::max(sy + 1 - (cur_dy+1)*scale_y, (WT)0);
@@ -1481,7 +1481,7 @@ public:
}
else
for( dx = 0; dx < dsize.width; dx++ )
{
{
D[dx] = saturate_cast<T>((sum[dx] + buf[dx]* beta1)/ min(scale_y, src.rows - cur_dy*scale_y)); //
sum[dx] = buf[dx]*beta;
buf[dx] = 0;
@@ -1505,7 +1505,7 @@ public:
}
}
}
virtual void operator() (const Range& range) const
{
for (int i = range.start; i < range.end; ++i)
@@ -1514,7 +1514,7 @@ public:
resize_single_band(band_range);
}
}
private:
Mat src;
Mat dst;
@@ -1533,11 +1533,11 @@ static void resizeArea_( const Mat& src, Mat& dst, const DecimateAlpha* xofs, in
int *cur_dy_ofs = _yofs;
int cur_dy = 0, index = 0;
std::vector<std::pair<int, int> > bands;
for (int sy = 0; sy < ssize.height; sy++)
{
cur_dy_ofs[sy] = cur_dy;
if ((cur_dy + 1) * scale_y_ <= sy + 1 || sy == ssize.height - 1 )
{
WT beta = (WT)std::max(sy + 1 - (cur_dy + 1) * scale_y_, 0.);
@@ -1569,7 +1569,7 @@ typedef void (*ResizeAreaFastFunc)( const Mat& src, Mat& dst,
int scale_x, int scale_y );
typedef void (*ResizeAreaFunc)( const Mat& src, Mat& dst,
const DecimateAlpha* xofs, int xofs_count,
const DecimateAlpha* xofs, int xofs_count,
double scale_y_);
}
@@ -1667,7 +1667,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
static ResizeAreaFastFunc areafast_tab[] =
{
resizeAreaFast_<uchar, int, ResizeAreaFastVec<uchar> >,
resizeAreaFast_<uchar, int, ResizeAreaFastVec<uchar> >,
0,
resizeAreaFast_<ushort, float, ResizeAreaFastVec<ushort> >,
resizeAreaFast_<short, float, ResizeAreaFastVec<short> >,
@@ -1679,7 +1679,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
static ResizeAreaFunc area_tab[] =
{
resizeArea_<uchar, float>, 0, resizeArea_<ushort, float>,
resizeArea_<uchar, float>, 0, resizeArea_<ushort, float>,
resizeArea_<short, float>, 0, resizeArea_<float, float>,
resizeArea_<double, double>, 0
};
@@ -1718,15 +1718,15 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
resizeNN( src, dst, inv_scale_x, inv_scale_y );
return;
}
{
int iscale_x = saturate_cast<int>(scale_x);
int iscale_y = saturate_cast<int>(scale_y);
bool is_area_fast = std::abs(scale_x - iscale_x) < DBL_EPSILON &&
std::abs(scale_y - iscale_y) < DBL_EPSILON;
// in case of scale_x && scale_y is equal to 2
// in case of scale_x && scale_y is equal to 2
// INTER_AREA (fast) also is equal to INTER_LINEAR
if( interpolation == INTER_LINEAR && is_area_fast && iscale_x == 2 && iscale_y == 2 )
{
@@ -1801,7 +1801,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
xofs[k++].alpha = (float)(min(fsx2 - sx2, 1.) / min(scale_x, src.cols - fsx1));
}
}
func( src, dst, xofs, k, scale_y);
return;
}
@@ -2684,15 +2684,15 @@ class RemapInvoker :
public ParallelLoopBody
{
public:
RemapInvoker(const Mat& _src, Mat& _dst, const Mat *_m1,
RemapInvoker(const Mat& _src, Mat& _dst, const Mat *_m1,
const Mat *_m2, int _interpolation, int _borderType, const Scalar &_borderValue,
int _planar_input, RemapNNFunc _nnfunc, RemapFunc _ifunc, const void *_ctab) :
ParallelLoopBody(), src(&_src), dst(&_dst), m1(_m1), m2(_m2),
interpolation(_interpolation), borderType(_borderType), borderValue(_borderValue),
interpolation(_interpolation), borderType(_borderType), borderValue(_borderValue),
planar_input(_planar_input), nnfunc(_nnfunc), ifunc(_ifunc), ctab(_ctab)
{
}
{
}
virtual void operator() (const Range& range) const
{
int x, y, x1, y1;
@@ -2866,7 +2866,7 @@ public:
}
}
}
private:
const Mat* src;
Mat* dst;
@@ -2972,7 +2972,7 @@ void cv::remap( InputArray _src, OutputArray _dst,
planar_input = map1.channels() == 1;
}
RemapInvoker invoker(src, dst, m1, m2, interpolation,
RemapInvoker invoker(src, dst, m1, m2, interpolation,
borderType, borderValue, planar_input, nnfunc, ifunc,
ctab);
parallel_for_(Range(0, dst.rows), invoker, dst.total()/(double)(1<<16));
@@ -3117,33 +3117,33 @@ void cv::convertMaps( InputArray _map1, InputArray _map2,
}
}
namespace cv
{
class warpAffineInvoker :
class warpAffineInvoker :
public ParallelLoopBody
{
public:
warpAffineInvoker(const Mat &_src, Mat &_dst, int _interpolation, int _borderType,
warpAffineInvoker(const Mat &_src, Mat &_dst, int _interpolation, int _borderType,
const Scalar &_borderValue, int *_adelta, int *_bdelta, double *_M) :
ParallelLoopBody(), src(_src), dst(_dst), interpolation(_interpolation),
borderType(_borderType), borderValue(_borderValue), adelta(_adelta), bdelta(_bdelta),
M(_M)
{
}
virtual void operator() (const Range& range) const
{
const int BLOCK_SZ = 64;
short XY[BLOCK_SZ*BLOCK_SZ*2], A[BLOCK_SZ*BLOCK_SZ];
const int AB_BITS = MAX(10, (int)INTER_BITS);
const int AB_SCALE = 1 << AB_BITS;
const int AB_SCALE = 1 << AB_BITS;
int round_delta = interpolation == INTER_NEAREST ? AB_SCALE/2 : AB_SCALE/INTER_TAB_SIZE/2, x, y, x1, y1;
#if CV_SSE2
bool useSIMD = checkHardwareSupport(CV_CPU_SSE2);
#endif
int bh0 = std::min(BLOCK_SZ/2, dst.rows);
int bw0 = std::min(BLOCK_SZ*BLOCK_SZ/bh0, dst.cols);
bh0 = std::min(BLOCK_SZ*BLOCK_SZ/bw0, dst.rows);
@@ -3232,7 +3232,7 @@ public:
}
}
}
private:
Mat src;
Mat dst;
@@ -3243,8 +3243,8 @@ private:
};
}
void cv::warpAffine( InputArray _src, OutputArray _dst,
InputArray _M0, Size dsize,
int flags, int borderType, const Scalar& borderValue )
@@ -3308,41 +3308,41 @@ class warpPerspectiveInvoker :
public ParallelLoopBody
{
public:
warpPerspectiveInvoker(const Mat &_src, Mat &_dst, double *_M, int _interpolation,
int _borderType, const Scalar &_borderValue) :
ParallelLoopBody(), src(_src), dst(_dst), M(_M), interpolation(_interpolation),
borderType(_borderType), borderValue(_borderValue)
{
}
virtual void operator() (const Range& range) const
{
const int BLOCK_SZ = 32;
short XY[BLOCK_SZ*BLOCK_SZ*2], A[BLOCK_SZ*BLOCK_SZ];
int x, y, x1, y1, width = dst.cols, height = dst.rows;
int bh0 = std::min(BLOCK_SZ/2, height);
int bw0 = std::min(BLOCK_SZ*BLOCK_SZ/bh0, width);
bh0 = std::min(BLOCK_SZ*BLOCK_SZ/bw0, height);
for( y = range.start; y < range.end; y += bh0 )
{
for( x = 0; x < width; x += bw0 )
{
int bw = std::min( bw0, width - x);
int bh = std::min( bh0, range.end - y); // height
Mat _XY(bh, bw, CV_16SC2, XY), matA;
Mat dpart(dst, Rect(x, y, bw, bh));
for( y1 = 0; y1 < bh; y1++ )
{
short* xy = XY + y1*bw*2;
double X0 = M[0]*x + M[1]*(y + y1) + M[2];
double Y0 = M[3]*x + M[4]*(y + y1) + M[5];
double W0 = M[6]*x + M[7]*(y + y1) + M[8];
if( interpolation == INTER_NEAREST )
for( x1 = 0; x1 < bw; x1++ )
{
@@ -3352,7 +3352,7 @@ public:
double fY = std::max((double)INT_MIN, std::min((double)INT_MAX, (Y0 + M[3]*x1)*W));
int X = saturate_cast<int>(fX);
int Y = saturate_cast<int>(fY);
xy[x1*2] = saturate_cast<short>(X);
xy[x1*2+1] = saturate_cast<short>(Y);
}
@@ -3367,7 +3367,7 @@ public:
double fY = std::max((double)INT_MIN, std::min((double)INT_MAX, (Y0 + M[3]*x1)*W));
int X = saturate_cast<int>(fX);
int Y = saturate_cast<int>(fY);
xy[x1*2] = saturate_cast<short>(X >> INTER_BITS);
xy[x1*2+1] = saturate_cast<short>(Y >> INTER_BITS);
alpha[x1] = (short)((Y & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE +
@@ -3375,7 +3375,7 @@ public:
}
}
}
if( interpolation == INTER_NEAREST )
remap( src, dpart, _XY, Mat(), interpolation, borderType, borderValue );
else
@@ -3386,7 +3386,7 @@ public:
}
}
}
private:
Mat src;
Mat dst;
@@ -3394,7 +3394,7 @@ private:
int interpolation, borderType;
Scalar borderValue;
};
}
void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,

View File

@@ -394,7 +394,7 @@ static CvStatus icvFitLine2D( CvPoint2D32f * points, int count, int dist,
int first = 1;
for( i = 0; i < count; i++ )
w[i] = 0.f;
for( i = 0; i < MIN(count,10); )
{
j = cvRandInt(&rng) % count;
@@ -542,7 +542,7 @@ icvFitLine3D( CvPoint3D32f * points, int count, int dist,
int first = 1;
for( i = 0; i < count; i++ )
w[i] = 0.f;
for( i = 0; i < MIN(count,10); )
{
j = cvRandInt(&rng) % count;

View File

@@ -51,7 +51,7 @@
// method - method for the matching calculation
// (now CV_IPPI_CONTOURS_MATCH_I1, CV_CONTOURS_MATCH_I2 or
// CV_CONTOURS_MATCH_I3 only )
// rezult - output calculated measure
// rezult - output calculated measure
//
//F*/
CV_IMPL double

View File

@@ -91,7 +91,7 @@ struct MorphNoVec
{
int operator()(uchar**, int, uchar*, int) const { return 0; }
};
#if CV_SSE2
template<class VecUpdate> struct MorphRowIVec
@@ -103,7 +103,7 @@ template<class VecUpdate> struct MorphRowIVec
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
cn *= ESZ;
int i, k, _ksize = ksize*cn;
width = (width & -4)*cn;
@@ -145,7 +145,7 @@ template<class VecUpdate> struct MorphRowFVec
{
if( !checkHardwareSupport(CV_CPU_SSE) )
return 0;
int i, k, _ksize = ksize*cn;
width = (width & -4)*cn;
VecUpdate updateOp;
@@ -177,7 +177,7 @@ template<class VecUpdate> struct MorphColumnIVec
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
int i = 0, k, _ksize = ksize;
width *= ESZ;
VecUpdate updateOp;
@@ -281,7 +281,7 @@ template<class VecUpdate> struct MorphColumnFVec
{
if( !checkHardwareSupport(CV_CPU_SSE) )
return 0;
int i = 0, k, _ksize = ksize;
VecUpdate updateOp;
@@ -410,7 +410,7 @@ template<class VecUpdate> struct MorphIVec
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
int i, k;
width *= ESZ;
VecUpdate updateOp;
@@ -457,7 +457,7 @@ template<class VecUpdate> struct MorphFVec
{
if( !checkHardwareSupport(CV_CPU_SSE) )
return 0;
const float** src = (const float**)_src;
float* dst = (float*)_dst;
int i, k;
@@ -707,8 +707,8 @@ template<class Op, class VecOp> struct MorphColumnFilter : public BaseColumnFilt
for( ; _ksize > 1 && count > 1; count -= 2, D += dststep*2, src += 2 )
{
i = i0;
#if CV_ENABLE_UNROLLED
i = i0;
#if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 )
{
const T* sptr = src[1] + i;
@@ -748,8 +748,8 @@ template<class Op, class VecOp> struct MorphColumnFilter : public BaseColumnFilt
for( ; count > 0; count--, D += dststep, src++ )
{
i = i0;
#if CV_ENABLE_UNROLLED
i = i0;
#if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 )
{
const T* sptr = src[0] + i;
@@ -889,7 +889,7 @@ cv::Ptr<cv::BaseRowFilter> cv::getMorphologyRowFilter(int op, int type, int ksiz
if( depth == CV_64F )
return Ptr<BaseRowFilter>(new MorphRowFilter<MaxOp<double>,
DilateRowVec64f>(ksize, anchor));
}
}
CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type));
return Ptr<BaseRowFilter>(0);
@@ -1149,7 +1149,7 @@ static void morphOp( int op, InputArray _src, OutputArray _dst,
_dst.create( src.size(), src.type() );
Mat dst = _dst.getMat();
if( iterations == 0 || kernel.rows*kernel.cols == 1 )
{
src.copyTo(dst);
@@ -1219,15 +1219,15 @@ void cv::morphologyEx( InputArray _src, OutputArray _dst, int op,
Mat src = _src.getMat(), temp;
_dst.create(src.size(), src.type());
Mat dst = _dst.getMat();
switch( op )
{
case MORPH_ERODE:
erode( src, dst, kernel, anchor, iterations, borderType, borderValue );
break;
break;
case MORPH_DILATE:
dilate( src, dst, kernel, anchor, iterations, borderType, borderValue );
break;
break;
case MORPH_OPEN:
erode( src, dst, kernel, anchor, iterations, borderType, borderValue );
dilate( dst, dst, kernel, anchor, iterations, borderType, borderValue );
@@ -1355,14 +1355,14 @@ cvMorphologyEx( const void* srcarr, void* dstarr, void*,
IplConvKernel* temp_element = NULL;
if (!element)
{
temp_element = cvCreateStructuringElementEx(3, 3, 1, 1, CV_SHAPE_RECT);
temp_element = cvCreateStructuringElementEx(3, 3, 1, 1, CV_SHAPE_RECT);
} else {
temp_element = element;
temp_element = element;
}
convertConvKernel( temp_element, kernel, anchor );
if (!element)
{
cvReleaseStructuringElement(&temp_element);
cvReleaseStructuringElement(&temp_element);
}
cv::morphologyEx( src, dst, op, kernel, anchor, iterations, cv::BORDER_REPLICATE );
}

View File

@@ -43,7 +43,7 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#ifdef HAVE_CVCONFIG_H
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif

View File

@@ -72,7 +72,7 @@ struct PyrDownVec_32s8u
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
int x = 0;
const int *row0 = src[0], *row1 = src[1], *row2 = src[2], *row3 = src[3], *row4 = src[4];
__m128i delta = _mm_set1_epi16(128);
@@ -139,7 +139,7 @@ struct PyrDownVec_32f
{
if( !checkHardwareSupport(CV_CPU_SSE) )
return 0;
int x = 0;
const float *row0 = src[0], *row1 = src[1], *row2 = src[2], *row3 = src[3], *row4 = src[4];
__m128 _4 = _mm_set1_ps(4.f), _scale = _mm_set1_ps(1.f/256);
@@ -217,7 +217,7 @@ pyrDown_( const Mat& _src, Mat& _dst, int borderType )
tabR[x*cn + k] = sx1 + k;
}
}
ssize.width *= cn;
dsize.width *= cn;
width0 *= cn;
@@ -400,7 +400,7 @@ pyrUp_( const Mat& _src, Mat& _dst, int)
typedef void (*PyrFunc)(const Mat&, Mat&, int);
}
void cv::pyrDown( InputArray _src, OutputArray _dst, const Size& _dsz, int borderType )
{
Mat src = _src.getMat();
@@ -492,11 +492,11 @@ cvReleasePyramid( CvMat*** _pyramid, int extra_layers )
{
if( !_pyramid )
CV_Error( CV_StsNullPtr, "" );
if( *_pyramid )
for( int i = 0; i <= extra_layers; i++ )
cvReleaseMat( &(*_pyramid)[i] );
cvFree( _pyramid );
}

View File

@@ -50,7 +50,7 @@ cvSampleLine( const void* img, CvPoint pt1, CvPoint pt2,
void* _buffer, int connectivity )
{
int count = -1;
int i, coi = 0, pix_size;
CvMat stub, *mat = cvGetMat( img, &stub, &coi );
CvLineIterator iterator;

View File

@@ -64,7 +64,7 @@ static CvWSNode*
icvAllocWSNodes( CvMemStorage* storage )
{
CvWSNode* n = 0;
int i, count = (storage->block_size - sizeof(CvMemBlock))/sizeof(*n) - 1;
n = (CvWSNode*)cvMemStorageAlloc( storage, count*sizeof(*n) );
@@ -83,7 +83,7 @@ cvWatershed( const CvArr* srcarr, CvArr* dstarr )
const int WSHED = -1;
const int NQ = 256;
cv::Ptr<CvMemStorage> storage;
CvMat sstub, *src;
CvMat dstub, *dst;
CvSize size;
@@ -149,7 +149,7 @@ cvWatershed( const CvArr* srcarr, CvArr* dstarr )
if( CV_MAT_TYPE(dst->type) != CV_32SC1 )
CV_Error( CV_StsUnsupportedFormat,
"Only 32-bit, 1-channel output images are supported" );
if( !CV_ARE_SIZES_EQ( src, dst ))
CV_Error( CV_StsUnmatchedSizes, "The input and output images must have the same size" );
@@ -231,7 +231,7 @@ cvWatershed( const CvArr* srcarr, CvArr* dstarr )
int lab = 0, t;
int* m;
uchar* ptr;
if( q[active_queue].first == 0 )
{
for( i = active_queue+1; i < NQ; i++ )
@@ -316,13 +316,13 @@ void cv::watershed( InputArray _src, InputOutputArray markers )
\****************************************************************************************/
CV_IMPL void
cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
double sp0, double sr, int max_level,
CvTermCriteria termcrit )
{
const int cn = 3;
const int MAX_LEVELS = 8;
if( (unsigned)max_level > (unsigned)MAX_LEVELS )
CV_Error( CV_StsOutOfRange, "The number of pyramid levels is too large or negative" );
@@ -343,7 +343,7 @@ cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
if( src0.type() != CV_8UC3 )
CV_Error( CV_StsUnsupportedFormat, "Only 8-bit, 3-channel images are supported" );
if( src0.type() != dst0.type() )
CV_Error( CV_StsUnmatchedFormats, "The input and output images must have the same type" );
@@ -423,9 +423,9 @@ cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
for( i = 0; i < size.height; i++, sptr += sstep - size.width*3,
dptr += dstep - size.width*3,
mask += mstep )
{
{
for( j = 0; j < size.width; j++, sptr += 3, dptr += 3 )
{
{
int x0 = j, y0 = i, x1, y1, iter;
int c0, c1, c2;
@@ -449,46 +449,46 @@ cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
miny = cvRound(y0 - sp); miny = MAX(miny, 0);
maxx = cvRound(x0 + sp); maxx = MIN(maxx, size.width-1);
maxy = cvRound(y0 + sp); maxy = MIN(maxy, size.height-1);
ptr = sptr + (miny - i)*sstep + (minx - j)*3;
ptr = sptr + (miny - i)*sstep + (minx - j)*3;
for( y = miny; y <= maxy; y++, ptr += sstep - (maxx-minx+1)*3 )
{
int row_count = 0;
x = minx;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; x + 3 <= maxx; x += 4, ptr += 12 )
{
int t0 = ptr[0], t1 = ptr[1], t2 = ptr[2];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
{
s0 += t0; s1 += t1; s2 += t2;
sx += x; row_count++;
}
t0 = ptr[3], t1 = ptr[4], t2 = ptr[5];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
{
s0 += t0; s1 += t1; s2 += t2;
sx += x+1; row_count++;
}
t0 = ptr[6], t1 = ptr[7], t2 = ptr[8];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
{
s0 += t0; s1 += t1; s2 += t2;
sx += x+2; row_count++;
}
t0 = ptr[9], t1 = ptr[10], t2 = ptr[11];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
{
s0 += t0; s1 += t1; s2 += t2;
sx += x+3; row_count++;
}
}
#endif
for( ; x <= maxx; x++, ptr += 3 )
{
{
int t0 = ptr[0], t1 = ptr[1], t2 = ptr[2];
if( tab[t0-c0+255] + tab[t1-c1+255] + tab[t2-c2+255] <= isr2 )
{
{
s0 += t0; s1 += t1; s2 += t2;
sx += x; row_count++;
}
@@ -510,7 +510,7 @@ cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
stop_flag = (x0 == x1 && y0 == y1) || abs(x1-x0) + abs(y1-y0) +
tab[s0 - c0 + 255] + tab[s1 - c1 + 255] +
tab[s2 - c2 + 255] <= termcrit.epsilon;
x0 = x1; y0 = y1;
c0 = s0; c1 = s1; c2 = s2;
@@ -531,7 +531,7 @@ void cv::pyrMeanShiftFiltering( InputArray _src, OutputArray _dst,
TermCriteria termcrit )
{
Mat src = _src.getMat();
if( src.empty() )
return;

View File

@@ -1064,47 +1064,47 @@ cvBoundingRect( CvArr* array, int update )
if( xmin >= size.width )
xmin = ymin = 0;
}
else if( ptseq->total )
{
int is_float = CV_SEQ_ELTYPE(ptseq) == CV_32FC2;
cvStartReadSeq( ptseq, &reader, 0 );
CvPoint pt;
CV_READ_SEQ_ELEM( pt, reader );
#if CV_SSE4_2
if(cv::checkHardwareSupport(CV_CPU_SSE4_2))
{
if( !is_float )
{
}
else if( ptseq->total )
{
int is_float = CV_SEQ_ELTYPE(ptseq) == CV_32FC2;
cvStartReadSeq( ptseq, &reader, 0 );
CvPoint pt;
CV_READ_SEQ_ELEM( pt, reader );
#if CV_SSE4_2
if(cv::checkHardwareSupport(CV_CPU_SSE4_2))
{
if( !is_float )
{
__m128i minval, maxval;
minval = maxval = _mm_loadl_epi64((const __m128i*)(&pt)); //min[0]=pt.x, min[1]=pt.y
for( i = 1; i < ptseq->total; i++)
{
__m128i ptXY = _mm_loadl_epi64((const __m128i*)(reader.ptr));
minval = maxval = _mm_loadl_epi64((const __m128i*)(&pt)); //min[0]=pt.x, min[1]=pt.y
for( i = 1; i < ptseq->total; i++)
{
__m128i ptXY = _mm_loadl_epi64((const __m128i*)(reader.ptr));
CV_NEXT_SEQ_ELEM(sizeof(pt), reader);
minval = _mm_min_epi32(ptXY, minval);
maxval = _mm_max_epi32(ptXY, maxval);
}
minval = _mm_min_epi32(ptXY, minval);
maxval = _mm_max_epi32(ptXY, maxval);
}
xmin = _mm_cvtsi128_si32(minval);
ymin = _mm_cvtsi128_si32(_mm_srli_si128(minval, 4));
xmax = _mm_cvtsi128_si32(maxval);
ymax = _mm_cvtsi128_si32(_mm_srli_si128(maxval, 4));
}
else
{
}
else
{
__m128 minvalf, maxvalf, z = _mm_setzero_ps(), ptXY = _mm_setzero_ps();
minvalf = maxvalf = _mm_loadl_pi(z, (const __m64*)(&pt));
minvalf = maxvalf = _mm_loadl_pi(z, (const __m64*)(&pt));
for( i = 1; i < ptseq->total; i++ )
{
ptXY = _mm_loadl_pi(ptXY, (const __m64*)reader.ptr);
for( i = 1; i < ptseq->total; i++ )
{
ptXY = _mm_loadl_pi(ptXY, (const __m64*)reader.ptr);
CV_NEXT_SEQ_ELEM(sizeof(pt), reader);
minvalf = _mm_min_ps(minvalf, ptXY);
maxvalf = _mm_max_ps(maxvalf, ptXY);
}
minvalf = _mm_min_ps(minvalf, ptXY);
maxvalf = _mm_max_ps(maxvalf, ptXY);
}
float xyminf[2], xymaxf[2];
_mm_storel_pi((__m64*)xyminf, minvalf);
_mm_storel_pi((__m64*)xymaxf, maxvalf);
@@ -1113,72 +1113,72 @@ cvBoundingRect( CvArr* array, int update )
xmax = cvFloor(xymaxf[0]);
ymax = cvFloor(xymaxf[1]);
}
}
}
else
#endif
{
if( !is_float )
{
xmin = xmax = pt.x;
ymin = ymax = pt.y;
{
if( !is_float )
{
xmin = xmax = pt.x;
ymin = ymax = pt.y;
for( i = 1; i < ptseq->total; i++ )
{
CV_READ_SEQ_ELEM( pt, reader );
for( i = 1; i < ptseq->total; i++ )
{
CV_READ_SEQ_ELEM( pt, reader );
if( xmin > pt.x )
xmin = pt.x;
if( xmin > pt.x )
xmin = pt.x;
if( xmax < pt.x )
xmax = pt.x;
if( xmax < pt.x )
xmax = pt.x;
if( ymin > pt.y )
ymin = pt.y;
if( ymin > pt.y )
ymin = pt.y;
if( ymax < pt.y )
ymax = pt.y;
}
}
else
{
Cv32suf v;
// init values
xmin = xmax = CV_TOGGLE_FLT(pt.x);
ymin = ymax = CV_TOGGLE_FLT(pt.y);
if( ymax < pt.y )
ymax = pt.y;
}
}
else
{
Cv32suf v;
// init values
xmin = xmax = CV_TOGGLE_FLT(pt.x);
ymin = ymax = CV_TOGGLE_FLT(pt.y);
for( i = 1; i < ptseq->total; i++ )
{
CV_READ_SEQ_ELEM( pt, reader );
pt.x = CV_TOGGLE_FLT(pt.x);
pt.y = CV_TOGGLE_FLT(pt.y);
for( i = 1; i < ptseq->total; i++ )
{
CV_READ_SEQ_ELEM( pt, reader );
pt.x = CV_TOGGLE_FLT(pt.x);
pt.y = CV_TOGGLE_FLT(pt.y);
if( xmin > pt.x )
xmin = pt.x;
if( xmin > pt.x )
xmin = pt.x;
if( xmax < pt.x )
xmax = pt.x;
if( xmax < pt.x )
xmax = pt.x;
if( ymin > pt.y )
ymin = pt.y;
if( ymin > pt.y )
ymin = pt.y;
if( ymax < pt.y )
ymax = pt.y;
}
if( ymax < pt.y )
ymax = pt.y;
}
v.i = CV_TOGGLE_FLT(xmin); xmin = cvFloor(v.f);
v.i = CV_TOGGLE_FLT(ymin); ymin = cvFloor(v.f);
// because right and bottom sides of the bounding rectangle are not inclusive
// (note +1 in width and height calculation below), cvFloor is used here instead of cvCeil
v.i = CV_TOGGLE_FLT(xmax); xmax = cvFloor(v.f);
v.i = CV_TOGGLE_FLT(ymax); ymax = cvFloor(v.f);
}
}
v.i = CV_TOGGLE_FLT(xmin); xmin = cvFloor(v.f);
v.i = CV_TOGGLE_FLT(ymin); ymin = cvFloor(v.f);
// because right and bottom sides of the bounding rectangle are not inclusive
// (note +1 in width and height calculation below), cvFloor is used here instead of cvCeil
v.i = CV_TOGGLE_FLT(xmax); xmax = cvFloor(v.f);
v.i = CV_TOGGLE_FLT(ymax); ymax = cvFloor(v.f);
}
}
rect.x = xmin;
rect.y = ymin;
rect.width = xmax - xmin + 1;
rect.height = ymax - ymin + 1;
}
if( update )
}
if( update )
((CvContour*)ptseq)->rect = rect;
return rect;
}

View File

@@ -215,10 +215,10 @@ template<> struct ColumnSum<int, uchar> : public BaseColumnFilter
int* SUM;
bool haveScale = scale != 1;
double _scale = scale;
#if CV_SSE2
bool haveSSE2 = checkHardwareSupport(CV_CPU_SSE2);
#endif
#if CV_SSE2
bool haveSSE2 = checkHardwareSupport(CV_CPU_SSE2);
#endif
if( width != (int)sum.size() )
{
@@ -229,22 +229,22 @@ template<> struct ColumnSum<int, uchar> : public BaseColumnFilter
SUM = &sum[0];
if( sumCount == 0 )
{
memset((void*)SUM, 0, width*sizeof(int));
memset((void*)SUM, 0, width*sizeof(int));
for( ; sumCount < ksize - 1; sumCount++, src++ )
{
const int* Sp = (const int*)src[0];
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-4; i+=4 )
{
__m128i _sum = _mm_loadu_si128((const __m128i*)(SUM+i));
__m128i _sp = _mm_loadu_si128((const __m128i*)(Sp+i));
_mm_storeu_si128((__m128i*)(SUM+i),_mm_add_epi32(_sum, _sp));
}
}
#endif
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-4; i+=4 )
{
__m128i _sum = _mm_loadu_si128((const __m128i*)(SUM+i));
__m128i _sp = _mm_loadu_si128((const __m128i*)(Sp+i));
_mm_storeu_si128((__m128i*)(SUM+i),_mm_add_epi32(_sum, _sp));
}
}
#endif
for( ; i < width; i++ )
SUM[i] += Sp[i];
}
@@ -262,33 +262,33 @@ template<> struct ColumnSum<int, uchar> : public BaseColumnFilter
uchar* D = (uchar*)dst;
if( haveScale )
{
i = 0;
#if CV_SSE2
if(haveSSE2)
{
const __m128 scale4 = _mm_set1_ps((float)_scale);
for( ; i < width-8; i+=8 )
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _sm1 = _mm_loadu_si128((const __m128i*)(Sm+i+4));
i = 0;
#if CV_SSE2
if(haveSSE2)
{
const __m128 scale4 = _mm_set1_ps((float)_scale);
for( ; i < width-8; i+=8 )
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _sm1 = _mm_loadu_si128((const __m128i*)(Sm+i+4));
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
_mm_loadu_si128((const __m128i*)(Sp+i)));
__m128i _s01 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i+4)),
__m128i _s01 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i+4)),
_mm_loadu_si128((const __m128i*)(Sp+i+4)));
__m128i _s0T = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s0)));
__m128i _s0T1 = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s01)));
_s0T = _mm_packs_epi32(_s0T, _s0T1);
__m128i _s0T = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s0)));
__m128i _s0T1 = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s01)));
_mm_storel_epi64((__m128i*)(D+i), _mm_packus_epi16(_s0T, _s0T));
_s0T = _mm_packs_epi32(_s0T, _s0T1);
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
_mm_storeu_si128((__m128i*)(SUM+i+4),_mm_sub_epi32(_s01,_sm1));
}
}
#endif
_mm_storel_epi64((__m128i*)(D+i), _mm_packus_epi16(_s0T, _s0T));
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
_mm_storeu_si128((__m128i*)(SUM+i+4),_mm_sub_epi32(_s01,_sm1));
}
}
#endif
for( ; i < width; i++ )
{
int s0 = SUM[i] + Sp[i];
@@ -298,29 +298,29 @@ template<> struct ColumnSum<int, uchar> : public BaseColumnFilter
}
else
{
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-8; i+=8 )
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _sm1 = _mm_loadu_si128((const __m128i*)(Sm+i+4));
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-8; i+=8 )
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _sm1 = _mm_loadu_si128((const __m128i*)(Sm+i+4));
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
_mm_loadu_si128((const __m128i*)(Sp+i)));
__m128i _s01 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i+4)),
__m128i _s01 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i+4)),
_mm_loadu_si128((const __m128i*)(Sp+i+4)));
__m128i _s0T = _mm_packs_epi32(_s0, _s01);
_mm_storel_epi64((__m128i*)(D+i), _mm_packus_epi16(_s0T, _s0T));
__m128i _s0T = _mm_packs_epi32(_s0, _s01);
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
_mm_storeu_si128((__m128i*)(SUM+i+4),_mm_sub_epi32(_s01,_sm1));
}
}
#endif
_mm_storel_epi64((__m128i*)(D+i), _mm_packus_epi16(_s0T, _s0T));
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
_mm_storeu_si128((__m128i*)(SUM+i+4),_mm_sub_epi32(_s01,_sm1));
}
}
#endif
for( ; i < width; i++ )
{
@@ -357,9 +357,9 @@ template<> struct ColumnSum<int, short> : public BaseColumnFilter
bool haveScale = scale != 1;
double _scale = scale;
#if CV_SSE2
bool haveSSE2 = checkHardwareSupport(CV_CPU_SSE2);
#endif
#if CV_SSE2
bool haveSSE2 = checkHardwareSupport(CV_CPU_SSE2);
#endif
if( width != (int)sum.size() )
{
@@ -369,22 +369,22 @@ template<> struct ColumnSum<int, short> : public BaseColumnFilter
SUM = &sum[0];
if( sumCount == 0 )
{
memset((void*)SUM, 0, width*sizeof(int));
memset((void*)SUM, 0, width*sizeof(int));
for( ; sumCount < ksize - 1; sumCount++, src++ )
{
const int* Sp = (const int*)src[0];
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-4; i+=4 )
{
__m128i _sum = _mm_loadu_si128((const __m128i*)(SUM+i));
__m128i _sp = _mm_loadu_si128((const __m128i*)(Sp+i));
_mm_storeu_si128((__m128i*)(SUM+i),_mm_add_epi32(_sum, _sp));
}
}
#endif
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-4; i+=4 )
{
__m128i _sum = _mm_loadu_si128((const __m128i*)(SUM+i));
__m128i _sp = _mm_loadu_si128((const __m128i*)(Sp+i));
_mm_storeu_si128((__m128i*)(SUM+i),_mm_add_epi32(_sum, _sp));
}
}
#endif
for( ; i < width; i++ )
SUM[i] += Sp[i];
}
@@ -402,31 +402,31 @@ template<> struct ColumnSum<int, short> : public BaseColumnFilter
short* D = (short*)dst;
if( haveScale )
{
i = 0;
#if CV_SSE2
if(haveSSE2)
{
const __m128 scale4 = _mm_set1_ps((float)_scale);
for( ; i < width-8; i+=8 )
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _sm1 = _mm_loadu_si128((const __m128i*)(Sm+i+4));
i = 0;
#if CV_SSE2
if(haveSSE2)
{
const __m128 scale4 = _mm_set1_ps((float)_scale);
for( ; i < width-8; i+=8 )
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _sm1 = _mm_loadu_si128((const __m128i*)(Sm+i+4));
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
_mm_loadu_si128((const __m128i*)(Sp+i)));
__m128i _s01 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i+4)),
__m128i _s01 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i+4)),
_mm_loadu_si128((const __m128i*)(Sp+i+4)));
__m128i _s0T = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s0)));
__m128i _s0T1 = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s01)));
_mm_storeu_si128((__m128i*)(D+i), _mm_packs_epi32(_s0T, _s0T1));
__m128i _s0T = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s0)));
__m128i _s0T1 = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s01)));
_mm_storeu_si128((__m128i*)(SUM+i),_mm_sub_epi32(_s0,_sm));
_mm_storeu_si128((__m128i*)(SUM+i+4), _mm_sub_epi32(_s01,_sm1));
}
}
#endif
_mm_storeu_si128((__m128i*)(D+i), _mm_packs_epi32(_s0T, _s0T1));
_mm_storeu_si128((__m128i*)(SUM+i),_mm_sub_epi32(_s0,_sm));
_mm_storeu_si128((__m128i*)(SUM+i+4), _mm_sub_epi32(_s01,_sm1));
}
}
#endif
for( ; i < width; i++ )
{
int s0 = SUM[i] + Sp[i];
@@ -436,28 +436,28 @@ template<> struct ColumnSum<int, short> : public BaseColumnFilter
}
else
{
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-8; i+=8 )
{
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-8; i+=8 )
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _sm1 = _mm_loadu_si128((const __m128i*)(Sm+i+4));
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _sm1 = _mm_loadu_si128((const __m128i*)(Sm+i+4));
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
_mm_loadu_si128((const __m128i*)(Sp+i)));
__m128i _s01 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i+4)),
__m128i _s01 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i+4)),
_mm_loadu_si128((const __m128i*)(Sp+i+4)));
_mm_storeu_si128((__m128i*)(D+i), _mm_packs_epi32(_s0, _s01));
_mm_storeu_si128((__m128i*)(D+i), _mm_packs_epi32(_s0, _s01));
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
_mm_storeu_si128((__m128i*)(SUM+i+4),_mm_sub_epi32(_s01,_sm1));
}
}
#endif
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
_mm_storeu_si128((__m128i*)(SUM+i+4),_mm_sub_epi32(_s01,_sm1));
}
}
#endif
for( ; i < width; i++ )
{
@@ -494,9 +494,9 @@ template<> struct ColumnSum<int, ushort> : public BaseColumnFilter
int* SUM;
bool haveScale = scale != 1;
double _scale = scale;
#if CV_SSE2
bool haveSSE2 = checkHardwareSupport(CV_CPU_SSE2);
#endif
#if CV_SSE2
bool haveSSE2 = checkHardwareSupport(CV_CPU_SSE2);
#endif
if( width != (int)sum.size() )
{
@@ -506,22 +506,22 @@ template<> struct ColumnSum<int, ushort> : public BaseColumnFilter
SUM = &sum[0];
if( sumCount == 0 )
{
memset((void*)SUM, 0, width*sizeof(int));
memset((void*)SUM, 0, width*sizeof(int));
for( ; sumCount < ksize - 1; sumCount++, src++ )
{
const int* Sp = (const int*)src[0];
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-4; i+=4 )
{
__m128i _sum = _mm_loadu_si128((const __m128i*)(SUM+i));
__m128i _sp = _mm_loadu_si128((const __m128i*)(Sp+i));
_mm_storeu_si128((__m128i*)(SUM+i), _mm_add_epi32(_sum, _sp));
}
}
#endif
i = 0;
#if CV_SSE2
if(haveSSE2)
{
for( ; i < width-4; i+=4 )
{
__m128i _sum = _mm_loadu_si128((const __m128i*)(SUM+i));
__m128i _sp = _mm_loadu_si128((const __m128i*)(Sp+i));
_mm_storeu_si128((__m128i*)(SUM+i), _mm_add_epi32(_sum, _sp));
}
}
#endif
for( ; i < width; i++ )
SUM[i] += Sp[i];
}
@@ -539,30 +539,30 @@ template<> struct ColumnSum<int, ushort> : public BaseColumnFilter
ushort* D = (ushort*)dst;
if( haveScale )
{
i = 0;
#if CV_SSE2
if(haveSSE2)
{
const __m128 scale4 = _mm_set1_ps((float)_scale);
const __m128i delta0 = _mm_set1_epi32(0x8000);
i = 0;
#if CV_SSE2
if(haveSSE2)
{
const __m128 scale4 = _mm_set1_ps((float)_scale);
const __m128i delta0 = _mm_set1_epi32(0x8000);
const __m128i delta1 = _mm_set1_epi32(0x80008000);
for( ; i < width-4; i+=4)
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
for( ; i < width-4; i+=4)
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
_mm_loadu_si128((const __m128i*)(Sp+i)));
__m128i _res = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s0)));
__m128i _res = _mm_cvtps_epi32(_mm_mul_ps(scale4, _mm_cvtepi32_ps(_s0)));
_res = _mm_sub_epi32(_res, delta0);
_res = _mm_add_epi16(_mm_packs_epi32(_res, _res), delta1);
_mm_storel_epi64((__m128i*)(D+i), _res);
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
}
}
#endif
_mm_storel_epi64((__m128i*)(D+i), _res);
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
}
}
#endif
for( ; i < width; i++ )
{
int s0 = SUM[i] + Sp[i];
@@ -572,27 +572,27 @@ template<> struct ColumnSum<int, ushort> : public BaseColumnFilter
}
else
{
i = 0;
#if CV_SSE2
if(haveSSE2)
{
const __m128i delta0 = _mm_set1_epi32(0x8000);
i = 0;
#if CV_SSE2
if(haveSSE2)
{
const __m128i delta0 = _mm_set1_epi32(0x8000);
const __m128i delta1 = _mm_set1_epi32(0x80008000);
for( ; i < width-4; i+=4 )
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
for( ; i < width-4; i+=4 )
{
__m128i _sm = _mm_loadu_si128((const __m128i*)(Sm+i));
__m128i _s0 = _mm_add_epi32(_mm_loadu_si128((const __m128i*)(SUM+i)),
_mm_loadu_si128((const __m128i*)(Sp+i)));
__m128i _res = _mm_sub_epi32(_s0, delta0);
__m128i _res = _mm_sub_epi32(_s0, delta0);
_res = _mm_add_epi16(_mm_packs_epi32(_res, _res), delta1);
_mm_storel_epi64((__m128i*)(D+i), _res);
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
}
}
#endif
_mm_storel_epi64((__m128i*)(D+i), _res);
_mm_storeu_si128((__m128i*)(SUM+i), _mm_sub_epi32(_s0,_sm));
}
}
#endif
for( ; i < width; i++ )
{
@@ -1712,7 +1712,7 @@ public:
maxk(_maxk), space_ofs(_space_ofs), space_weight(_space_weight), color_weight(_color_weight)
{
}
virtual void operator() (const Range& range) const
{
int i, j, cn = dest->channels(), k;
@@ -1723,12 +1723,12 @@ public:
static const int CV_DECL_ALIGNED(16) bufSignMask[] = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 };
bool haveSSE3 = checkHardwareSupport(CV_CPU_SSE3);
#endif
for( i = range.start; i < range.end; i++ )
{
const uchar* sptr = temp->ptr(i+radius) + radius*cn;
uchar* dptr = dest->ptr(i);
if( cn == 1 )
{
for( j = 0; j < size.width; j++ )
@@ -1746,7 +1746,7 @@ public:
{
__m128 _valF = _mm_set_ps(sptr[j + space_ofs[k+3]], sptr[j + space_ofs[k+2]],
sptr[j + space_ofs[k+1]], sptr[j + space_ofs[k]]);
__m128 _val = _mm_andnot_ps(_signMask, _mm_sub_ps(_valF, _val0));
_mm_store_si128((__m128i*)buf, _mm_cvtps_epi32(_val));
@@ -1791,7 +1791,7 @@ public:
const __m128 _g0 = _mm_set1_ps(static_cast<float>(g0));
const __m128 _r0 = _mm_set1_ps(static_cast<float>(r0));
const __m128 _signMask = _mm_load_ps((const float*)bufSignMask);
for( ; k <= maxk - 4; k += 4 )
{
const uchar* sptr_k = sptr + j + space_ofs[k];
@@ -1851,7 +1851,7 @@ public:
}
}
}
private:
const Mat *temp;
Mat *dest;
@@ -1868,41 +1868,41 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
int cn = src.channels();
int i, j, maxk, radius;
Size size = src.size();
CV_Assert( (src.type() == CV_8UC1 || src.type() == CV_8UC3) &&
src.type() == dst.type() && src.size() == dst.size() &&
src.data != dst.data );
if( sigma_color <= 0 )
sigma_color = 1;
if( sigma_space <= 0 )
sigma_space = 1;
double gauss_color_coeff = -0.5/(sigma_color*sigma_color);
double gauss_space_coeff = -0.5/(sigma_space*sigma_space);
if( d <= 0 )
radius = cvRound(sigma_space*1.5);
else
radius = d/2;
radius = MAX(radius, 1);
d = radius*2 + 1;
Mat temp;
copyMakeBorder( src, temp, radius, radius, radius, radius, borderType );
vector<float> _color_weight(cn*256);
vector<float> _space_weight(d*d);
vector<int> _space_ofs(d*d);
float* color_weight = &_color_weight[0];
float* space_weight = &_space_weight[0];
int* space_ofs = &_space_ofs[0];
// initialize color-related bilateral filter coefficients
for( i = 0; i < 256*cn; i++ )
color_weight[i] = (float)std::exp(i*i*gauss_color_coeff);
// initialize space-related bilateral filter coefficients
for( i = -radius, maxk = 0; i <= radius; i++ )
{
@@ -1917,7 +1917,7 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
space_ofs[maxk++] = (int)(i*temp.step + j*cn);
}
}
BilateralFilter_8u_Invoker body(dst, temp, radius, maxk, space_ofs, space_weight, color_weight);
parallel_for_(Range(0, size.height), body, dst.total()/(double)(1<<16));
}
@@ -1964,7 +1964,7 @@ public:
const __m128 _val0 = _mm_set1_ps(sptr[j]);
const __m128 _scale_index = _mm_set1_ps(scale_index);
const __m128 _signMask = _mm_load_ps((const float*)bufSignMask);
for( ; k <= maxk - 4 ; k += 4 )
{
__m128 _sw = _mm_loadu_ps(space_weight + k);
@@ -1980,7 +1980,7 @@ public:
expLUT[idxBuf[1]], expLUT[idxBuf[0]]);
__m128 _explut1 = _mm_set_ps(expLUT[idxBuf[3]+1], expLUT[idxBuf[2]+1],
expLUT[idxBuf[1]+1], expLUT[idxBuf[0]+1]);
__m128 _w = _mm_mul_ps(_sw, _mm_add_ps(_explut, _mm_mul_ps(_alpha, _mm_sub_ps(_explut1, _explut))));
_val = _mm_mul_ps(_w, _val);
@@ -2023,7 +2023,7 @@ public:
const __m128 _r0 = _mm_set1_ps(r0);
const __m128 _scale_index = _mm_set1_ps(scale_index);
const __m128 _signMask = _mm_load_ps((const float*)bufSignMask);
for( ; k <= maxk-4; k += 4 )
{
__m128 _sw = _mm_loadu_ps(space_weight + k);
@@ -2049,7 +2049,7 @@ public:
__m128 _explut = _mm_set_ps(expLUT[idxBuf[3]], expLUT[idxBuf[2]], expLUT[idxBuf[1]], expLUT[idxBuf[0]]);
__m128 _explut1 = _mm_set_ps(expLUT[idxBuf[3]+1], expLUT[idxBuf[2]+1], expLUT[idxBuf[1]+1], expLUT[idxBuf[0]+1]);
__m128 _w = _mm_mul_ps(_sw, _mm_add_ps(_explut, _mm_mul_ps(_alpha, _mm_sub_ps(_explut1, _explut))));
_b = _mm_mul_ps(_b, _w);
@@ -2070,7 +2070,7 @@ public:
}
#endif
for(; k < maxk; k++ )
{
const float* sptr_k = sptr + j + space_ofs[k];
@@ -2099,7 +2099,7 @@ private:
Mat *dest;
float scale_index, *space_weight, *expLUT;
};
static void
bilateralFilter_32f( const Mat& src, Mat& dst, int d,
@@ -2176,7 +2176,7 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
}
// initialize space-related bilateral filter coefficients
for( i = -radius, maxk = 0; i <= radius; i++ )
for( i = -radius, maxk = 0; i <= radius; i++ )
for( j = -radius; j <= radius; j++ )
{
double r = std::sqrt((double)i*i + (double)j*j);

View File

@@ -42,7 +42,7 @@
namespace cv
{
int Subdiv2D::nextEdge(int edge) const
{
CV_DbgAssert((size_t)(edge >> 2) < qedges.size());
@@ -114,7 +114,7 @@ Subdiv2D::Subdiv2D(Rect rect)
freeQEdge = 0;
freePoint = 0;
recentEdge = 0;
initDelaunay(rect);
}
@@ -132,7 +132,7 @@ Subdiv2D::QuadEdge::QuadEdge(int edgeidx)
next[1] = edgeidx+3;
next[2] = edgeidx+2;
next[3] = edgeidx+1;
pt[0] = pt[1] = pt[2] = pt[3] = 0;
}
@@ -187,10 +187,10 @@ void Subdiv2D::setEdgePoints(int edge, int orgPt, int dstPt)
int Subdiv2D::connectEdges( int edgeA, int edgeB )
{
int edge = newEdge();
splice(edge, getEdge(edgeA, NEXT_AROUND_LEFT));
splice(symEdge(edge), edgeB);
setEdgePoints(edge, edgeDst(edgeA), edgeOrg(edgeB));
return edge;
}
@@ -200,12 +200,12 @@ void Subdiv2D::swapEdges( int edge )
int sedge = symEdge(edge);
int a = getEdge(edge, PREV_AROUND_ORG);
int b = getEdge(sedge, PREV_AROUND_ORG);
splice(edge, a);
splice(sedge, b);
setEdgePoints(edge, edgeDst(a), edgeDst(b));
splice(edge, getEdge(a, NEXT_AROUND_LEFT));
splice(sedge, getEdge(b, NEXT_AROUND_LEFT));
}
@@ -213,15 +213,15 @@ void Subdiv2D::swapEdges( int edge )
static double triangleArea( Point2f a, Point2f b, Point2f c )
{
return ((double)b.x - a.x) * ((double)c.y - a.y) - ((double)b.y - a.y) * ((double)c.x - a.x);
}
}
int Subdiv2D::isRightOf(Point2f pt, int edge) const
{
Point2f org, dst;
edgeOrg(edge, &org);
edgeDst(edge, &dst);
double cw_area = triangleArea( pt, dst, org );
return (cw_area > 0) - (cw_area < 0);
}
@@ -244,7 +244,7 @@ void Subdiv2D::deleteEdge(int edge)
splice( edge, getEdge(edge, PREV_AROUND_ORG) );
int sedge = symEdge(edge);
splice(sedge, getEdge(sedge, PREV_AROUND_ORG) );
edge >>= 2;
qedges[edge].next[0] = 0;
qedges[edge].next[1] = freeQEdge;
@@ -261,7 +261,7 @@ int Subdiv2D::newPoint(Point2f pt, bool isvirtual, int firstEdge)
int vidx = freePoint;
freePoint = vtx[vidx].firstEdge;
vtx[vidx] = Vertex(pt, isvirtual, firstEdge);
return vidx;
}
@@ -276,35 +276,35 @@ void Subdiv2D::deletePoint(int vidx)
int Subdiv2D::locate(Point2f pt, int& _edge, int& _vertex)
{
int vertex = 0;
int i, maxEdges = (int)(qedges.size() * 4);
if( qedges.size() < (size_t)4 )
CV_Error( CV_StsError, "Subdivision is empty" );
if( pt.x < topLeft.x || pt.y < topLeft.y || pt.x >= bottomRight.x || pt.y >= bottomRight.y )
CV_Error( CV_StsOutOfRange, "" );
int edge = recentEdge;
CV_Assert(edge > 0);
int location = PTLOC_ERROR;
int right_of_curr = isRightOf(pt, edge);
if( right_of_curr > 0 )
{
edge = symEdge(edge);
right_of_curr = -right_of_curr;
}
for( i = 0; i < maxEdges; i++ )
{
int onext_edge = nextEdge( edge );
int dprev_edge = getEdge( edge, PREV_AROUND_DST );
int right_of_onext = isRightOf( pt, onext_edge );
int right_of_dprev = isRightOf( pt, dprev_edge );
if( right_of_dprev > 0 )
{
if( right_of_onext > 0 || (right_of_onext == 0 && right_of_curr == 0) )
@@ -345,22 +345,22 @@ int Subdiv2D::locate(Point2f pt, int& _edge, int& _vertex)
}
}
}
recentEdge = edge;
if( location == PTLOC_INSIDE )
{
Point2f org_pt, dst_pt;
edgeOrg(edge, &org_pt);
edgeDst(edge, &dst_pt);
double t1 = fabs( pt.x - org_pt.x );
t1 += fabs( pt.y - org_pt.y );
double t2 = fabs( pt.x - dst_pt.x );
t2 += fabs( pt.y - dst_pt.y );
double t3 = fabs( org_pt.x - dst_pt.x );
t3 += fabs( org_pt.y - dst_pt.y );
if( t1 < FLT_EPSILON )
{
location = PTLOC_VERTEX;
@@ -380,16 +380,16 @@ int Subdiv2D::locate(Point2f pt, int& _edge, int& _vertex)
vertex = 0;
}
}
if( location == PTLOC_ERROR )
{
edge = 0;
vertex = 0;
}
_edge = edge;
_vertex = vertex;
return location;
}
@@ -402,7 +402,7 @@ isPtInCircle3( Point2f pt, Point2f a, Point2f b, Point2f c)
val -= ((double)b.x * b.x + (double)b.y * b.y) * triangleArea( a, c, pt );
val += ((double)c.x * c.x + (double)c.y * c.y) * triangleArea( a, b, pt );
val -= ((double)pt.x * pt.x + (double)pt.y * pt.y) * triangleArea( a, b, c );
return val > eps ? 1 : val < -eps ? -1 : 0;
}
@@ -411,16 +411,16 @@ int Subdiv2D::insert(Point2f pt)
{
int curr_point = 0, curr_edge = 0, deleted_edge = 0;
int location = locate( pt, curr_edge, curr_point );
if( location == PTLOC_ERROR )
CV_Error( CV_StsBadSize, "" );
if( location == PTLOC_OUTSIDE_RECT )
CV_Error( CV_StsOutOfRange, "" );
if( location == PTLOC_VERTEX )
return curr_point;
if( location == PTLOC_ON_EDGE )
{
deleted_edge = curr_edge;
@@ -431,36 +431,36 @@ int Subdiv2D::insert(Point2f pt)
;
else
CV_Error_(CV_StsError, ("Subdiv2D::locate returned invalid location = %d", location) );
assert( curr_edge != 0 );
validGeometry = false;
curr_point = newPoint(pt, false);
int base_edge = newEdge();
int first_point = edgeOrg(curr_edge);
setEdgePoints(base_edge, first_point, curr_point);
splice(base_edge, curr_edge);
do
{
base_edge = connectEdges( curr_edge, symEdge(base_edge) );
curr_edge = getEdge(base_edge, PREV_AROUND_ORG);
}
while( edgeDst(curr_edge) != first_point );
curr_edge = getEdge( base_edge, PREV_AROUND_ORG );
int i, max_edges = (int)(qedges.size()*4);
for( i = 0; i < max_edges; i++ )
{
int temp_dst = 0, curr_org = 0, curr_dst = 0;
int temp_edge = getEdge( curr_edge, PREV_AROUND_ORG );
temp_dst = edgeDst( temp_edge );
curr_org = edgeOrg( curr_edge );
curr_dst = edgeDst( curr_edge );
if( isRightOf( vtx[temp_dst].pt, curr_edge ) > 0 &&
isPtInCircle3( vtx[curr_org].pt, vtx[temp_dst].pt,
vtx[curr_dst].pt, vtx[curr_point].pt ) < 0 )
@@ -473,7 +473,7 @@ int Subdiv2D::insert(Point2f pt)
else
curr_edge = getEdge( nextEdge( curr_edge ), PREV_AROUND_LEFT );
}
return curr_point;
}
@@ -488,42 +488,42 @@ void Subdiv2D::initDelaunay( Rect rect )
float big_coord = 3.f * MAX( rect.width, rect.height );
float rx = (float)rect.x;
float ry = (float)rect.y;
vtx.clear();
qedges.clear();
recentEdge = 0;
validGeometry = false;
topLeft = Point2f( rx, ry );
bottomRight = Point2f( rx + rect.width, ry + rect.height );
Point2f ppA( rx + big_coord, ry );
Point2f ppB( rx, ry + big_coord );
Point2f ppC( rx - big_coord, ry - big_coord );
vtx.push_back(Vertex());
qedges.push_back(QuadEdge());
freeQEdge = 0;
freePoint = 0;
int pA = newPoint(ppA, false);
int pB = newPoint(ppB, false);
int pC = newPoint(ppC, false);
int edge_AB = newEdge();
int edge_BC = newEdge();
int edge_CA = newEdge();
setEdgePoints( edge_AB, pA, pB );
setEdgePoints( edge_BC, pB, pC );
setEdgePoints( edge_CA, pC, pA );
splice( edge_AB, symEdge( edge_CA ));
splice( edge_BC, symEdge( edge_AB ));
splice( edge_CA, symEdge( edge_BC ));
recentEdge = edge_AB;
}
@@ -531,17 +531,17 @@ void Subdiv2D::initDelaunay( Rect rect )
void Subdiv2D::clearVoronoi()
{
size_t i, total = qedges.size();
for( i = 0; i < total; i++ )
qedges[i].pt[1] = qedges[i].pt[3] = 0;
total = vtx.size();
for( i = 0; i < total; i++ )
{
if( vtx[i].isvirtual() )
deletePoint((int)i);
}
validGeometry = false;
}
@@ -551,20 +551,20 @@ static Point2f computeVoronoiPoint(Point2f org0, Point2f dst0, Point2f org1, Poi
double a0 = dst0.x - org0.x;
double b0 = dst0.y - org0.y;
double c0 = -0.5*(a0 * (dst0.x + org0.x) + b0 * (dst0.y + org0.y));
double a1 = dst1.x - org1.x;
double b1 = dst1.y - org1.y;
double c1 = -0.5*(a1 * (dst1.x + org1.x) + b1 * (dst1.y + org1.y));
double det = a0 * b1 - a1 * b0;
if( det != 0 )
{
det = 1. / det;
return Point2f((float) ((b0 * c1 - b1 * c0) * det),
(float) ((a1 * c0 - a0 * c1) * det));
}
return Point2f(FLT_MAX, FLT_MAX);
}
@@ -574,33 +574,33 @@ void Subdiv2D::calcVoronoi()
// check if it is already calculated
if( validGeometry )
return;
clearVoronoi();
int i, total = (int)qedges.size();
// loop through all quad-edges, except for the first 3 (#1, #2, #3 - 0 is reserved for "NULL" pointer)
for( i = 4; i < total; i++ )
{
QuadEdge& quadedge = qedges[i];
if( quadedge.isfree() )
continue;
int edge0 = (int)(i*4);
Point2f org0, dst0, org1, dst1;
if( !quadedge.pt[3] )
{
int edge1 = getEdge( edge0, NEXT_AROUND_LEFT );
int edge2 = getEdge( edge1, NEXT_AROUND_LEFT );
edgeOrg(edge0, &org0);
edgeDst(edge0, &dst0);
edgeOrg(edge1, &org1);
edgeDst(edge1, &dst1);
Point2f virt_point = computeVoronoiPoint(org0, dst0, org1, dst1);
if( fabs( virt_point.x ) < FLT_MAX * 0.5 &&
fabs( virt_point.y ) < FLT_MAX * 0.5 )
{
@@ -608,28 +608,28 @@ void Subdiv2D::calcVoronoi()
qedges[edge2 >> 2].pt[3 - (edge2 & 2)] = newPoint(virt_point, true);
}
}
if( !quadedge.pt[1] )
{
int edge1 = getEdge( edge0, NEXT_AROUND_RIGHT );
int edge2 = getEdge( edge1, NEXT_AROUND_RIGHT );
edgeOrg(edge0, &org0);
edgeDst(edge0, &dst0);
edgeOrg(edge1, &org1);
edgeDst(edge1, &dst1);
Point2f virt_point = computeVoronoiPoint(org0, dst0, org1, dst1);
if( fabs( virt_point.x ) < FLT_MAX * 0.5 &&
fabs( virt_point.y ) < FLT_MAX * 0.5 )
{
quadedge.pt[1] = qedges[edge1 >> 2].pt[1 + (edge1 & 2)] =
quadedge.pt[1] = qedges[edge1 >> 2].pt[1 + (edge1 & 2)] =
qedges[edge2 >> 2].pt[1 + (edge2 & 2)] = newPoint(virt_point, true);
}
}
}
validGeometry = true;
}
@@ -646,70 +646,70 @@ int Subdiv2D::findNearest(Point2f pt, Point2f* nearestPt)
{
if( !validGeometry )
calcVoronoi();
int vertex = 0, edge = 0;
int loc = locate( pt, edge, vertex );
if( loc != PTLOC_ON_EDGE && loc != PTLOC_INSIDE )
return vertex;
vertex = 0;
Point2f start;
edgeOrg(edge, &start);
Point2f diff = pt - start;
edge = rotateEdge(edge, 1);
int i, total = (int)vtx.size();
for( i = 0; i < total; i++ )
{
Point2f t;
for(;;)
{
CV_Assert( edgeDst(edge, &t) > 0 );
if( isRightOf2( t, start, diff ) >= 0 )
break;
edge = getEdge( edge, NEXT_AROUND_LEFT );
}
for(;;)
{
CV_Assert( edgeOrg( edge, &t ) > 0 );
if( isRightOf2( t, start, diff ) < 0 )
break;
edge = getEdge( edge, PREV_AROUND_LEFT );
}
Point2f tempDiff;
edgeDst(edge, &tempDiff);
edgeOrg(edge, &t);
tempDiff -= t;
if( isRightOf2( pt, t, tempDiff ) >= 0 )
{
vertex = edgeOrg(rotateEdge( edge, 3 ));
break;
}
edge = symEdge( edge );
}
if( nearestPt && vertex > 0 )
*nearestPt = vtx[vertex].pt;
return vertex;
}
void Subdiv2D::getEdgeList(vector<Vec4f>& edgeList) const
{
edgeList.clear();
for( size_t i = 4; i < qedges.size(); i++ )
{
if( qedges[i].isfree() )
@@ -728,7 +728,7 @@ void Subdiv2D::getTriangleList(vector<Vec6f>& triangleList) const
triangleList.clear();
int i, total = (int)(qedges.size()*4);
vector<bool> edgemask(total, false);
for( i = 4; i < total; i += 2 )
{
if( edgemask[i] )
@@ -754,23 +754,23 @@ void Subdiv2D::getVoronoiFacetList(const vector<int>& idx,
calcVoronoi();
facetList.clear();
facetCenters.clear();
vector<Point2f> buf;
size_t i, total;
if( idx.empty() )
i = 4, total = vtx.size();
else
i = 0, total = idx.size();
for( ; i < total; i++ )
{
int k = idx.empty() ? (int)i : idx[i];
if( vtx[k].isfree() || vtx[k].isvirtual() )
continue;
int edge = rotateEdge(vtx[k].firstEdge, 1), t = edge;
int edge = rotateEdge(vtx[k].firstEdge, 1), t = edge;
// gather points
buf.clear();
do
@@ -779,7 +779,7 @@ void Subdiv2D::getVoronoiFacetList(const vector<int>& idx,
t = getEdge( t, NEXT_AROUND_LEFT );
}
while( t != edge );
facetList.push_back(buf);
facetCenters.push_back(vtx[k].pt);
}
@@ -789,14 +789,14 @@ void Subdiv2D::getVoronoiFacetList(const vector<int>& idx,
void Subdiv2D::checkSubdiv() const
{
int i, j, total = (int)qedges.size();
for( i = 0; i < total; i++ )
{
const QuadEdge& qe = qedges[i];
if( qe.isfree() )
continue;
for( j = 0; j < 4; j++ )
{
int e = (int)(i*4 + j);
@@ -804,13 +804,13 @@ void Subdiv2D::checkSubdiv() const
int o_prev = getEdge(e, PREV_AROUND_ORG );
int d_prev = getEdge(e, PREV_AROUND_DST );
int d_next = getEdge(e, NEXT_AROUND_DST );
// check points
CV_Assert( edgeOrg(e) == edgeOrg(o_next));
CV_Assert( edgeOrg(e) == edgeOrg(o_prev));
CV_Assert( edgeDst(e) == edgeDst(d_next));
CV_Assert( edgeDst(e) == edgeDst(d_prev));
if( j % 2 == 0 )
{
CV_Assert( edgeDst(o_next) == edgeOrg(d_prev));
@@ -820,8 +820,8 @@ void Subdiv2D::checkSubdiv() const
}
}
}
}
}
}
/* End of file. */

View File

@@ -158,7 +158,7 @@ const float icv8x32fSqrTab[] =
61504.f, 62001.f, 62500.f, 63001.f, 63504.f, 64009.f, 64516.f, 65025.f
};
const uchar icvSaturate8u_cv[] =
const uchar icvSaturate8u_cv[] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

View File

@@ -56,26 +56,26 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
int depth = img.depth(), cn = img.channels();
int tdepth = templ.depth(), tcn = templ.channels();
int cdepth = CV_MAT_DEPTH(ctype), ccn = CV_MAT_CN(ctype);
CV_Assert( img.dims <= 2 && templ.dims <= 2 && corr.dims <= 2 );
if( depth != tdepth && tdepth != std::max(CV_32F, depth) )
{
_templ.convertTo(templ, std::max(CV_32F, depth));
tdepth = templ.depth();
}
CV_Assert( depth == tdepth || tdepth == CV_32F);
CV_Assert( corrsize.height <= img.rows + templ.rows - 1 &&
corrsize.width <= img.cols + templ.cols - 1 );
CV_Assert( ccn == 1 || delta == 0 );
corr.create(corrsize, ctype);
int maxDepth = depth > CV_8S ? CV_64F : std::max(std::max(CV_32F, tdepth), cdepth);
Size blocksize, dftsize;
blocksize.width = cvRound(templ.cols*blockScale);
blocksize.width = std::max( blocksize.width, minBlockSize - templ.cols + 1 );
blocksize.width = std::min( blocksize.width, corr.cols );
@@ -109,7 +109,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
bufSize = std::max( bufSize, blocksize.width*blocksize.height*CV_ELEM_SIZE(cdepth));
buf.resize(bufSize);
// compute DFT of each template plane
for( k = 0; k < tcn; k++ )
{
@@ -139,11 +139,11 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
int tileCountX = (corr.cols + blocksize.width - 1)/blocksize.width;
int tileCountY = (corr.rows + blocksize.height - 1)/blocksize.height;
int tileCount = tileCountX * tileCountY;
Size wholeSize = img.size();
Point roiofs(0,0);
Mat img0 = img;
if( !(borderType & BORDER_ISOLATED) )
{
img.locateROI(wholeSize, roiofs);
@@ -151,13 +151,13 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
roiofs.x, wholeSize.width-img.cols-roiofs.x);
}
borderType |= BORDER_ISOLATED;
// calculate correlation by blocks
for( i = 0; i < tileCount; i++ )
{
int x = (i%tileCountX)*blocksize.width;
int y = (i/tileCountX)*blocksize.height;
Size bsz(std::min(blocksize.width, corr.cols - x),
std::min(blocksize.height, corr.rows - y));
Size dsz(bsz.width + templ.cols - 1, bsz.height + templ.rows - 1);
@@ -169,12 +169,12 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
Mat dst(dftImg, Rect(0, 0, dsz.width, dsz.height));
Mat dst1(dftImg, Rect(x1-x0, y1-y0, x2-x1, y2-y1));
Mat cdst(corr, Rect(x, y, bsz.width, bsz.height));
for( k = 0; k < cn; k++ )
{
Mat src = src0;
dftImg = Scalar::all(0);
if( cn > 1 )
{
src = depth == maxDepth ? dst1 : Mat(y2-y1, x2-x1, depth, &buf[0]);
@@ -206,7 +206,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
src = plane;
}
int pairs[] = {0, k};
mixChannels(&src, 1, &cdst, 1, pairs, 1);
mixChannels(&src, 1, &cdst, 1, pairs, 1);
}
else
{
@@ -234,7 +234,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, int method )
{
CV_Assert( CV_TM_SQDIFF <= method && method <= CV_TM_CCOEFF_NORMED );
int numType = method == CV_TM_CCORR || method == CV_TM_CCORR_NORMED ? 0 :
method == CV_TM_CCOEFF || method == CV_TM_CCOEFF_NORMED ? 1 : 2;
bool isNormed = method == CV_TM_CCORR_NORMED ||
@@ -244,14 +244,14 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
Mat img = _img.getMat(), templ = _templ.getMat();
if( img.rows < templ.rows || img.cols < templ.cols )
std::swap(img, templ);
CV_Assert( (img.depth() == CV_8U || img.depth() == CV_32F) &&
img.type() == templ.type() );
Size corrSize(img.cols - templ.cols + 1, img.rows - templ.rows + 1);
_result.create(corrSize, CV_32F);
Mat result = _result.getMat();
int cn = img.channels();
crossCorr( img, templ, result, result.size(), result.type(), Point(0,0), 0, 0);
@@ -264,7 +264,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
Scalar templMean, templSdv;
double *q0 = 0, *q1 = 0, *q2 = 0, *q3 = 0;
double templNorm = 0, templSum2 = 0;
if( method == CV_TM_CCOEFF )
{
integral(img, sum, CV_64F);
@@ -283,7 +283,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
result = Scalar::all(1);
return;
}
templSum2 = templNorm +
CV_SQR(templMean[0]) + CV_SQR(templMean[1]) +
CV_SQR(templMean[2]) + CV_SQR(templMean[3]);
@@ -293,7 +293,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
templMean = Scalar::all(0);
templNorm = templSum2;
}
templSum2 /= invArea;
templNorm = sqrt(templNorm);
templNorm /= sqrt(invArea); // care of accuracy here
@@ -313,7 +313,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
int sqstep = sqsum.data ? (int)(sqsum.step / sizeof(double)) : 0;
int i, j, k;
for( i = 0; i < result.rows; i++ )
{
float* rrow = (float*)(result.data + i*result.step);
@@ -324,7 +324,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
{
double num = rrow[j], t;
double wndMean2 = 0, wndSum2 = 0;
if( numType == 1 )
{
for( k = 0; k < cn; k++ )

View File

@@ -781,7 +781,7 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
;
else
CV_Error( CV_StsUnsupportedFormat, "" );
parallel_for_(Range(0, dst.rows),
ThresholdRunner(src, dst, thresh, maxval, type),
dst.total()/(double)(1<<16));

View File

@@ -48,9 +48,9 @@ CV_IMPL CvSeq* cvPointSeqFromMat( int seq_kind, const CvArr* arr,
int eltype;
CvMat* mat = (CvMat*)arr;
if( !CV_IS_MAT( mat ))
CV_Error( CV_StsBadArg, "Input array is not a valid matrix" );
CV_Error( CV_StsBadArg, "Input array is not a valid matrix" );
eltype = CV_MAT_TYPE( mat->type );
if( eltype != CV_32SC2 && eltype != CV_32FC2 )
@@ -93,14 +93,14 @@ static void copyMakeBorder_8u( const uchar* src, size_t srcstep, Size srcroi,
int* tab = _tab;
int right = dstroi.width - srcroi.width - left;
int bottom = dstroi.height - srcroi.height - top;
for( i = 0; i < left; i++ )
{
j = borderInterpolate(i - left, srcroi.width, borderType)*cn;
for( k = 0; k < cn; k++ )
tab[i*cn + k] = j + k;
}
for( i = 0; i < right; i++ )
{
j = borderInterpolate(srcroi.width + i, srcroi.width, borderType)*cn;
@@ -112,14 +112,14 @@ static void copyMakeBorder_8u( const uchar* src, size_t srcstep, Size srcroi,
dstroi.width *= cn;
left *= cn;
right *= cn;
uchar* dstInner = dst + dststep*top + left*elemSize;
for( i = 0; i < srcroi.height; i++, dstInner += dststep, src += srcstep )
{
if( dstInner != src )
memcpy(dstInner, src, srcroi.width*elemSize);
if( intMode )
{
const int* isrc = (int*)src;
@@ -137,16 +137,16 @@ static void copyMakeBorder_8u( const uchar* src, size_t srcstep, Size srcroi,
dstInner[j + srcroi.width] = src[tab[j + left]];
}
}
dstroi.width *= elemSize;
dst += dststep*top;
for( i = 0; i < top; i++ )
{
j = borderInterpolate(i - top, srcroi.height, borderType);
memcpy(dst + (i - top)*dststep, dst + j*dststep, dstroi.width);
}
for( i = 0; i < bottom; i++ )
{
j = borderInterpolate(i + srcroi.height, srcroi.height, borderType);
@@ -164,20 +164,20 @@ static void copyMakeConstBorder_8u( const uchar* src, size_t srcstep, Size srcro
uchar* constBuf = _constBuf;
int right = dstroi.width - srcroi.width - left;
int bottom = dstroi.height - srcroi.height - top;
for( i = 0; i < dstroi.width; i++ )
{
for( j = 0; j < cn; j++ )
constBuf[i*cn + j] = value[j];
}
srcroi.width *= cn;
dstroi.width *= cn;
left *= cn;
right *= cn;
uchar* dstInner = dst + dststep*top + left;
for( i = 0; i < srcroi.height; i++, dstInner += dststep, src += srcstep )
{
if( dstInner != src )
@@ -185,24 +185,24 @@ static void copyMakeConstBorder_8u( const uchar* src, size_t srcstep, Size srcro
memcpy( dstInner - left, constBuf, left );
memcpy( dstInner + srcroi.width, constBuf, right );
}
dst += dststep*top;
for( i = 0; i < top; i++ )
memcpy(dst + (i - top)*dststep, constBuf, dstroi.width);
for( i = 0; i < bottom; i++ )
memcpy(dst + (i + srcroi.height)*dststep, constBuf, dstroi.width);
}
}
void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
int left, int right, int borderType, const Scalar& value )
{
Mat src = _src.getMat();
CV_Assert( top >= 0 && bottom >= 0 && left >= 0 && right >= 0 );
if( src.isSubmatrix() && (borderType & BORDER_ISOLATED) == 0 )
{
Size wholeSize;
@@ -228,9 +228,9 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
src.copyTo(dst);
return;
}
borderType &= ~BORDER_ISOLATED;
if( borderType != BORDER_CONSTANT )
copyMakeBorder_8u( src.data, src.step, src.size(),
dst.data, dst.step, dst.size(),
@@ -268,7 +268,7 @@ cvCopyMakeBorder( const CvArr* srcarr, CvArr* dstarr, CvPoint offset,
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
int left = offset.x, right = dst.cols - src.cols - left;
int top = offset.y, bottom = dst.rows - src.rows - top;
CV_Assert( dst.type() == src.type() );
cv::copyMakeBorder( src, dst, top, bottom, left, right, borderType, value );
}