Merged the trunk r8589:8653 - all changes related to build warnings

This commit is contained in:
Andrey Kamaev
2012-06-15 13:04:17 +00:00
parent 73c152abc4
commit bd0e0b5800
438 changed files with 20374 additions and 19674 deletions

View File

@@ -1,3 +1,7 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
#endif
#ifndef __OPENCV_PERF_PRECOMP_HPP__
#define __OPENCV_PERF_PRECOMP_HPP__
@@ -5,7 +9,7 @@
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#if GTEST_CREATE_SHARED_LIBRARY
#ifdef GTEST_CREATE_SHARED_LIBRARY
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif

View File

@@ -98,6 +98,7 @@ typedef struct _list _CVLIST;
_LIST_INLINE CVPOS prefix##get_tail_pos_##type(_CVLIST*);\
_LIST_INLINE type* prefix##get_next_##type(CVPOS*);\
_LIST_INLINE type* prefix##get_prev_##type(CVPOS*);\
_LIST_INLINE int prefix##is_pos_##type(CVPOS pos);\
/* Modification functions*/\
_LIST_INLINE void prefix##clear_list_##type(_CVLIST*);\
_LIST_INLINE CVPOS prefix##add_head_##type(_CVLIST*, type*);\
@@ -151,8 +152,8 @@ typedef struct _list _CVLIST;
}\
element->m_next = ((element_type*)l->m_head_free.m_pos);\
l->m_head_free.m_pos = element;
/*#define GET_FIRST_FREE(l) ((ELEMENT_##type*)(l->m_head_free.m_pos))*/
#define IMPLEMENT_LIST(type, prefix)\

File diff suppressed because it is too large Load Diff

View File

@@ -48,11 +48,11 @@
/*
Various border types, image boundaries are denoted with '|'
* BORDER_REPLICATE: aaaaaa|abcdefgh|hhhhhhh
* BORDER_REFLECT: fedcba|abcdefgh|hgfedcb
* BORDER_REFLECT_101: gfedcb|abcdefgh|gfedcba
* BORDER_WRAP: cdefgh|abcdefgh|abcdefg
* BORDER_WRAP: cdefgh|abcdefgh|abcdefg
* BORDER_CONSTANT: iiiiii|abcdefgh|iiiiiii with some specified 'i'
*/
int cv::borderInterpolate( int p, int len, int borderType )
@@ -113,7 +113,7 @@ FilterEngine::FilterEngine()
wholeSize = Size(-1,-1);
}
FilterEngine::FilterEngine( const Ptr<BaseFilter>& _filter2D,
const Ptr<BaseRowFilter>& _rowFilter,
@@ -125,7 +125,7 @@ FilterEngine::FilterEngine( const Ptr<BaseFilter>& _filter2D,
init(_filter2D, _rowFilter, _columnFilter, _srcType, _dstType, _bufType,
_rowBorderType, _columnBorderType, _borderValue);
}
FilterEngine::~FilterEngine()
{
}
@@ -141,24 +141,24 @@ void FilterEngine::init( const Ptr<BaseFilter>& _filter2D,
_srcType = CV_MAT_TYPE(_srcType);
_bufType = CV_MAT_TYPE(_bufType);
_dstType = CV_MAT_TYPE(_dstType);
srcType = _srcType;
int srcElemSize = (int)getElemSize(srcType);
dstType = _dstType;
bufType = _bufType;
filter2D = _filter2D;
rowFilter = _rowFilter;
columnFilter = _columnFilter;
if( _columnBorderType < 0 )
_columnBorderType = _rowBorderType;
rowBorderType = _rowBorderType;
columnBorderType = _columnBorderType;
CV_Assert( columnBorderType != BORDER_WRAP );
if( isSeparable() )
{
CV_Assert( !rowFilter.empty() && !columnFilter.empty() );
@@ -175,7 +175,7 @@ void FilterEngine::init( const Ptr<BaseFilter>& _filter2D,
CV_Assert( 0 <= anchor.x && anchor.x < ksize.width &&
0 <= anchor.y && anchor.y < ksize.height );
borderElemSize = srcElemSize/(CV_MAT_DEPTH(srcType) >= CV_32S ? sizeof(int) : 1);
borderElemSize = srcElemSize/(CV_MAT_DEPTH(srcType) >= CV_32S ? sizeof(int) : 1);
int borderLength = std::max(ksize.width - 1, 1);
borderTab.resize(borderLength*borderElemSize);
@@ -198,7 +198,7 @@ static const int VEC_ALIGN = CV_MALLOC_ALIGN;
int FilterEngine::start(Size _wholeSize, Rect _roi, int _maxBufRows)
{
int i, j;
wholeSize = _wholeSize;
roi = _roi;
CV_Assert( roi.x >= 0 && roi.y >= 0 && roi.width >= 0 && roi.height >= 0 &&
@@ -226,7 +226,7 @@ int FilterEngine::start(Size _wholeSize, Rect _roi, int _maxBufRows)
int n = (int)constBorderValue.size(), N;
N = (maxWidth + ksize.width - 1)*esz;
tdst = isSeparable() ? &srcRow[0] : dst;
for( i = 0; i < N; i += n )
{
n = std::min( n, N - i );
@@ -237,7 +237,7 @@ int FilterEngine::start(Size _wholeSize, Rect _roi, int _maxBufRows)
if( isSeparable() )
(*rowFilter)(&srcRow[0], dst, maxWidth, cn);
}
int maxBufStep = bufElemSize*(int)alignSize(maxWidth +
(!isSeparable() ? ksize.width - 1 : 0),VEC_ALIGN);
ringBuf.resize(maxBufStep*rows.size()+VEC_ALIGN);
@@ -265,10 +265,10 @@ int FilterEngine::start(Size _wholeSize, Rect _roi, int _maxBufRows)
else
{
int xofs1 = std::min(roi.x, anchor.x) - roi.x;
int btab_esz = borderElemSize, wholeWidth = wholeSize.width;
int* btab = (int*)&borderTab[0];
for( i = 0; i < dx1; i++ )
{
int p0 = (borderInterpolate(i-dx1, wholeWidth, rowBorderType) + xofs1)*btab_esz;
@@ -301,20 +301,20 @@ int FilterEngine::start(const Mat& src, const Rect& _srcRoi,
bool isolated, int maxBufRows)
{
Rect srcRoi = _srcRoi;
if( srcRoi == Rect(0,0,-1,-1) )
srcRoi = Rect(0,0,src.cols,src.rows);
CV_Assert( srcRoi.x >= 0 && srcRoi.y >= 0 &&
srcRoi.width >= 0 && srcRoi.height >= 0 &&
srcRoi.x + srcRoi.width <= src.cols &&
srcRoi.y + srcRoi.height <= src.rows );
Point ofs;
Size wholeSize(src.cols, src.rows);
Size wsz(src.cols, src.rows);
if( !isolated )
src.locateROI( wholeSize, ofs );
start( wholeSize, srcRoi + ofs, maxBufRows );
src.locateROI( wsz, ofs );
start( wsz, srcRoi + ofs, maxBufRows );
return startY - ofs.y;
}
@@ -334,7 +334,7 @@ int FilterEngine::proceed( const uchar* src, int srcstep, int count,
uchar* dst, int dststep )
{
CV_Assert( wholeSize.width > 0 && wholeSize.height > 0 );
const int *btab = &borderTab[0];
int esz = (int)getElemSize(srcType), btab_esz = borderElemSize;
uchar** brows = &rows[0];
@@ -365,7 +365,7 @@ int FilterEngine::proceed( const uchar* src, int srcstep, int count,
int bi = (startY - startY0 + rowCount) % bufRows;
uchar* brow = alignPtr(&ringBuf[0], VEC_ALIGN) + bi*bufStep;
uchar* row = isSep ? &srcRow[0] : brow;
if( ++rowCount > bufRows )
{
--rowCount;
@@ -394,7 +394,7 @@ int FilterEngine::proceed( const uchar* src, int srcstep, int count,
row[i + (width1 - _dx2)*esz] = src[btab[i+_dx1*esz]];
}
}
if( isSep )
(*rowFilter)(row, brow, width, CV_MAT_CN(srcType));
}
@@ -434,11 +434,11 @@ void FilterEngine::apply(const Mat& src, Mat& dst,
const Rect& _srcRoi, Point dstOfs, bool isolated)
{
CV_Assert( src.type() == srcType && dst.type() == dstType );
Rect srcRoi = _srcRoi;
if( srcRoi == Rect(0,0,-1,-1) )
srcRoi = Rect(0,0,src.cols,src.rows);
if( srcRoi.area() == 0 )
return;
@@ -560,7 +560,7 @@ struct RowVec_8u32s
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
int i = 0, k, _ksize = kernel.rows + kernel.cols - 1;
int* dst = (int*)_dst;
const int* _kx = (const int*)kernel.data;
@@ -593,7 +593,7 @@ struct RowVec_8u32s
s2 = _mm_add_epi32(s2, _mm_unpacklo_epi16(x2, x3));
s3 = _mm_add_epi32(s3, _mm_unpackhi_epi16(x2, x3));
}
_mm_store_si128((__m128i*)(dst + i), s0);
_mm_store_si128((__m128i*)(dst + i + 4), s1);
_mm_store_si128((__m128i*)(dst + i + 8), s2);
@@ -652,7 +652,7 @@ struct SymmRowSmallVec_8u32s
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
int i = 0, j, k, _ksize = kernel.rows + kernel.cols - 1;
int* dst = (int*)_dst;
bool symmetrical = (symmetryType & KERNEL_SYMMETRICAL) != 0;
@@ -973,7 +973,7 @@ struct SymmColumnVec_32s8u
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
int ksize2 = (kernel.rows + kernel.cols - 1)/2;
const float* ky = (const float*)kernel.data + ksize2;
int i = 0, k;
@@ -1121,7 +1121,7 @@ struct SymmColumnSmallVec_32s16s
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
int ksize2 = (kernel.rows + kernel.cols - 1)/2;
const float* ky = (const float*)kernel.data + ksize2;
int i = 0;
@@ -1237,9 +1237,9 @@ struct SymmColumnSmallVec_32s16s
Mat kernel;
};
/////////////////////////////////////// 16s //////////////////////////////////
struct RowVec_16s32f
{
RowVec_16s32f() {}
@@ -1248,17 +1248,17 @@ struct RowVec_16s32f
kernel = _kernel;
sse2_supported = checkHardwareSupport(CV_CPU_SSE2);
}
int operator()(const uchar* _src, uchar* _dst, int width, int cn) const
{
if( !sse2_supported )
return 0;
int i = 0, k, _ksize = kernel.rows + kernel.cols - 1;
float* dst = (float*)_dst;
const float* _kx = (const float*)kernel.data;
width *= cn;
for( ; i <= width - 8; i += 8 )
{
const short* src = (const short*)_src + i;
@@ -1267,7 +1267,7 @@ struct RowVec_16s32f
{
f = _mm_load_ss(_kx+k);
f = _mm_shuffle_ps(f, f, 0);
__m128i x0i = _mm_loadu_si128((const __m128i*)src);
__m128i x1i = _mm_srai_epi32(_mm_unpackhi_epi16(x0i, x0i), 16);
x0i = _mm_srai_epi32(_mm_unpacklo_epi16(x0i, x0i), 16);
@@ -1281,12 +1281,12 @@ struct RowVec_16s32f
}
return i;
}
Mat kernel;
bool sse2_supported;
};
struct SymmColumnVec_32f16s
{
SymmColumnVec_32f16s() { symmetryType=0; }
@@ -1298,12 +1298,12 @@ struct SymmColumnVec_32f16s
CV_Assert( (symmetryType & (KERNEL_SYMMETRICAL | KERNEL_ASYMMETRICAL)) != 0 );
sse2_supported = checkHardwareSupport(CV_CPU_SSE2);
}
int operator()(const uchar** _src, uchar* _dst, int width) const
{
if( !sse2_supported )
return 0;
int ksize2 = (kernel.rows + kernel.cols - 1)/2;
const float* ky = (const float*)kernel.data + ksize2;
int i = 0, k;
@@ -1312,7 +1312,7 @@ struct SymmColumnVec_32f16s
const float *S, *S2;
short* dst = (short*)_dst;
__m128 d4 = _mm_set1_ps(delta);
if( symmetrical )
{
for( ; i <= width - 16; i += 16 )
@@ -1330,7 +1330,7 @@ struct SymmColumnVec_32f16s
s3 = _mm_load_ps(S+12);
s2 = _mm_add_ps(_mm_mul_ps(s2, f), d4);
s3 = _mm_add_ps(_mm_mul_ps(s3, f), d4);
for( k = 1; k <= ksize2; k++ )
{
S = src[k] + i;
@@ -1346,23 +1346,23 @@ struct SymmColumnVec_32f16s
s2 = _mm_add_ps(s2, _mm_mul_ps(x0, f));
s3 = _mm_add_ps(s3, _mm_mul_ps(x1, f));
}
__m128i s0i = _mm_cvtps_epi32(s0);
__m128i s1i = _mm_cvtps_epi32(s1);
__m128i s2i = _mm_cvtps_epi32(s2);
__m128i s3i = _mm_cvtps_epi32(s3);
_mm_storeu_si128((__m128i*)(dst + i), _mm_packs_epi32(s0i, s1i));
_mm_storeu_si128((__m128i*)(dst + i + 8), _mm_packs_epi32(s2i, s3i));
}
for( ; i <= width - 4; i += 4 )
{
__m128 f = _mm_load_ss(ky);
f = _mm_shuffle_ps(f, f, 0);
__m128 x0, s0 = _mm_load_ps(src[0] + i);
s0 = _mm_add_ps(_mm_mul_ps(s0, f), d4);
for( k = 1; k <= ksize2; k++ )
{
f = _mm_load_ss(ky+k);
@@ -1372,7 +1372,7 @@ struct SymmColumnVec_32f16s
x0 = _mm_add_ps(_mm_load_ps(src[k]+i), _mm_load_ps(src[-k] + i));
s0 = _mm_add_ps(s0, _mm_mul_ps(x0, f));
}
__m128i s0i = _mm_cvtps_epi32(s0);
_mm_storel_epi64((__m128i*)(dst + i), _mm_packs_epi32(s0i, s0i));
}
@@ -1384,7 +1384,7 @@ struct SymmColumnVec_32f16s
__m128 f, s0 = d4, s1 = d4, s2 = d4, s3 = d4;
__m128 x0, x1;
S = src[0] + i;
for( k = 1; k <= ksize2; k++ )
{
S = src[k] + i;
@@ -1400,20 +1400,20 @@ struct SymmColumnVec_32f16s
s2 = _mm_add_ps(s2, _mm_mul_ps(x0, f));
s3 = _mm_add_ps(s3, _mm_mul_ps(x1, f));
}
__m128i s0i = _mm_cvtps_epi32(s0);
__m128i s1i = _mm_cvtps_epi32(s1);
__m128i s2i = _mm_cvtps_epi32(s2);
__m128i s3i = _mm_cvtps_epi32(s3);
_mm_storeu_si128((__m128i*)(dst + i), _mm_packs_epi32(s0i, s1i));
_mm_storeu_si128((__m128i*)(dst + i + 8), _mm_packs_epi32(s2i, s3i));
}
for( ; i <= width - 4; i += 4 )
{
__m128 f, x0, s0 = d4;
for( k = 1; k <= ksize2; k++ )
{
f = _mm_load_ss(ky+k);
@@ -1421,21 +1421,21 @@ struct SymmColumnVec_32f16s
x0 = _mm_sub_ps(_mm_load_ps(src[k]+i), _mm_load_ps(src[-k] + i));
s0 = _mm_add_ps(s0, _mm_mul_ps(x0, f));
}
__m128i s0i = _mm_cvtps_epi32(s0);
_mm_storel_epi64((__m128i*)(dst + i), _mm_packs_epi32(s0i, s0i));
}
}
return i;
}
int symmetryType;
float delta;
Mat kernel;
bool sse2_supported;
};
};
/////////////////////////////////////// 32f //////////////////////////////////
@@ -1451,7 +1451,7 @@ struct RowVec_32f
{
if( !checkHardwareSupport(CV_CPU_SSE) )
return 0;
int i = 0, k, _ksize = kernel.rows + kernel.cols - 1;
float* dst = (float*)_dst;
const float* _kx = (const float*)kernel.data;
@@ -1494,7 +1494,7 @@ struct SymmRowSmallVec_32f
{
if( !checkHardwareSupport(CV_CPU_SSE) )
return 0;
int i = 0, _ksize = kernel.rows + kernel.cols - 1;
float* dst = (float*)_dst;
const float* src = (const float*)_src + (_ksize/2)*cn;
@@ -1594,12 +1594,12 @@ struct SymmRowSmallVec_32f
y0 = _mm_mul_ps(_mm_add_ps(y0, y2), k1);
x0 = _mm_add_ps(x0, _mm_mul_ps(x1, k0));
y0 = _mm_add_ps(y0, _mm_mul_ps(y1, k0));
x2 = _mm_add_ps(_mm_loadu_ps(src + cn*2), _mm_loadu_ps(src - cn*2));
y2 = _mm_add_ps(_mm_loadu_ps(src + cn*2 + 4), _mm_loadu_ps(src - cn*2 + 4));
x0 = _mm_add_ps(x0, _mm_mul_ps(x2, k2));
y0 = _mm_add_ps(y0, _mm_mul_ps(y2, k2));
_mm_store_ps(dst + i, x0);
_mm_store_ps(dst + i + 4, y0);
}
@@ -1654,12 +1654,12 @@ struct SymmRowSmallVec_32f
x0 = _mm_mul_ps(_mm_sub_ps(x0, x2), k1);
y0 = _mm_mul_ps(_mm_sub_ps(y0, y2), k1);
x2 = _mm_sub_ps(_mm_loadu_ps(src + cn*2), _mm_loadu_ps(src - cn*2));
y2 = _mm_sub_ps(_mm_loadu_ps(src + cn*2 + 4), _mm_loadu_ps(src - cn*2 + 4));
x0 = _mm_add_ps(x0, _mm_mul_ps(x2, k2));
y0 = _mm_add_ps(y0, _mm_mul_ps(y2, k2));
_mm_store_ps(dst + i, x0);
_mm_store_ps(dst + i + 4, y0);
}
@@ -1689,7 +1689,7 @@ struct SymmColumnVec_32f
{
if( !checkHardwareSupport(CV_CPU_SSE) )
return 0;
int ksize2 = (kernel.rows + kernel.cols - 1)/2;
const float* ky = (const float*)kernel.data + ksize2;
int i = 0, k;
@@ -1829,7 +1829,7 @@ struct SymmColumnSmallVec_32f
{
if( !checkHardwareSupport(CV_CPU_SSE) )
return 0;
int ksize2 = (kernel.rows + kernel.cols - 1)/2;
const float* ky = (const float*)kernel.data + ksize2;
int i = 0;
@@ -1963,7 +1963,7 @@ struct FilterVec_8u
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
const float* kf = (const float*)&coeffs[0];
int i = 0, k, nz = _nz;
__m128 d4 = _mm_set1_ps(delta);
@@ -2046,7 +2046,7 @@ struct FilterVec_8u16s
{
if( !checkHardwareSupport(CV_CPU_SSE2) )
return 0;
const float* kf = (const float*)&coeffs[0];
short* dst = (short*)_dst;
int i = 0, k, nz = _nz;
@@ -2127,7 +2127,7 @@ struct FilterVec_32f
{
if( !checkHardwareSupport(CV_CPU_SSE) )
return 0;
const float* kf = (const float*)&coeffs[0];
const float** src = (const float**)_src;
float* dst = (float*)_dst;
@@ -2217,7 +2217,7 @@ template<typename ST, typename DT, class VecOp> struct RowFilter : public BaseRo
(kernel.rows == 1 || kernel.cols == 1));
vecOp = _vecOp;
}
void operator()(const uchar* src, uchar* dst, int width, int cn)
{
int _ksize = ksize;
@@ -2242,7 +2242,7 @@ template<typename ST, typename DT, class VecOp> struct RowFilter : public BaseRo
s0 += f*S[0]; s1 += f*S[1];
s2 += f*S[2]; s3 += f*S[3];
}
D[i] = s0; D[i+1] = s1;
D[i+2] = s2; D[i+3] = s3;
}
@@ -2275,7 +2275,7 @@ template<typename ST, typename DT, class VecOp> struct SymmRowSmallFilter :
symmetryType = _symmetryType;
CV_Assert( (symmetryType & (KERNEL_SYMMETRICAL | KERNEL_ASYMMETRICAL)) != 0 && this->ksize <= 5 );
}
void operator()(const uchar* src, uchar* dst, int width, int cn)
{
int ksize2 = this->ksize/2, ksize2n = ksize2*cn;
@@ -2397,7 +2397,7 @@ template<class CastOp, class VecOp> struct ColumnFilter : public BaseColumnFilte
{
typedef typename CastOp::type1 ST;
typedef typename CastOp::rtype DT;
ColumnFilter( const Mat& _kernel, int _anchor,
double _delta, const CastOp& _castOp=CastOp(),
const VecOp& _vecOp=VecOp() )
@@ -2427,7 +2427,7 @@ template<class CastOp, class VecOp> struct ColumnFilter : public BaseColumnFilte
{
DT* D = (DT*)dst;
i = vecOp(src, dst, width);
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 )
{
ST f = ky[0];
@@ -2574,7 +2574,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
{
typedef typename CastOp::type1 ST;
typedef typename CastOp::rtype DT;
SymmColumnSmallFilter( const Mat& _kernel, int _anchor,
double _delta, int _symmetryType,
const CastOp& _castOp=CastOp(),
@@ -2610,7 +2610,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
{
if( is_1_2_1 )
{
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 )
{
ST s0 = S0[i] + S1[i]*2 + S2[i] + _delta;
@@ -2624,7 +2624,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+3] = castOp(s1);
}
#else
for( ; i < width; i ++ )
for( ; i < width; i ++ )
{
ST s0 = S0[i] + S1[i]*2 + S2[i] + _delta;
D[i] = castOp(s0);
@@ -2633,7 +2633,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
}
else if( is_1_m2_1 )
{
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= width - 4; i += 4 )
{
ST s0 = S0[i] - S1[i]*2 + S2[i] + _delta;
@@ -2647,7 +2647,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+3] = castOp(s1);
}
#else
for( ; i < width; i ++ )
for( ; i < width; i ++ )
{
ST s0 = S0[i] - S1[i]*2 + S2[i] + _delta;
D[i] = castOp(s0);
@@ -2700,7 +2700,7 @@ struct SymmColumnSmallFilter : public SymmColumnFilter<CastOp, VecOp>
D[i+3] = castOp(s1);
}
#else
for( ; i < width; i ++ )
for( ; i < width; i ++ )
{
ST s0 = S2[i] - S0[i] + _delta;
D[i] = castOp(s0);
@@ -2763,7 +2763,7 @@ template<typename ST, typename DT> struct FixedPtCastEx
};
}
cv::Ptr<cv::BaseRowFilter> cv::getLinearRowFilter( int srcType, int bufType,
InputArray _kernel, int anchor,
int symmetryType )
@@ -2785,7 +2785,7 @@ cv::Ptr<cv::BaseRowFilter> cv::getLinearRowFilter( int srcType, int bufType,
return Ptr<BaseRowFilter>(new SymmRowSmallFilter<float, float, SymmRowSmallVec_32f>
(kernel, anchor, symmetryType, SymmRowSmallVec_32f(kernel, symmetryType)));
}
if( sdepth == CV_8U && ddepth == CV_32S )
return Ptr<BaseRowFilter>(new RowFilter<uchar, int, RowVec_8u32s>
(kernel, anchor, RowVec_8u32s(kernel)));
@@ -2820,7 +2820,7 @@ cv::Ptr<cv::BaseRowFilter> cv::getLinearRowFilter( int srcType, int bufType,
cv::Ptr<cv::BaseColumnFilter> cv::getLinearColumnFilter( int bufType, int dstType,
InputArray _kernel, int anchor,
int symmetryType, double delta,
int symmetryType, double delta,
int bits )
{
Mat kernel = _kernel.getMat();
@@ -3045,7 +3045,7 @@ template<typename ST, class CastOp, class VecOp> struct Filter2D : public BaseFi
{
typedef typename CastOp::type1 KT;
typedef typename CastOp::rtype DT;
Filter2D( const Mat& _kernel, Point _anchor,
double _delta, const CastOp& _castOp=CastOp(),
const VecOp& _vecOp=VecOp() )
@@ -3143,7 +3143,7 @@ cv::Ptr<cv::BaseFilter> cv::getLinearFilter(int srcType, int dstType,
kernel = _kernel;
else
_kernel.convertTo(kernel, kdepth, _kernel.type() == CV_32S ? 1./(1 << bits) : 1.);
if( sdepth == CV_8U && ddepth == CV_8U )
return Ptr<BaseFilter>(new Filter2D<uchar, Cast<float, uchar>, FilterVec_8u>
(kernel, anchor, delta, Cast<float, uchar>(), FilterVec_8u(kernel, 0, delta)));
@@ -3203,7 +3203,7 @@ cv::Ptr<cv::FilterEngine> cv::createLinearFilter( int _srcType, int _dstType,
{
Mat _kernel = filter_kernel.getMat();
_srcType = CV_MAT_TYPE(_srcType);
_dstType = CV_MAT_TYPE(_dstType);
_dstType = CV_MAT_TYPE(_dstType);
int cn = CV_MAT_CN(_srcType);
CV_Assert( cn == CV_MAT_CN(_dstType) );
@@ -3211,14 +3211,14 @@ cv::Ptr<cv::FilterEngine> cv::createLinearFilter( int _srcType, int _dstType,
int bits = 0;
/*int sdepth = CV_MAT_DEPTH(_srcType), ddepth = CV_MAT_DEPTH(_dstType);
int ktype = _kernel.depth() == CV_32S ? KERNEL_INTEGER : getKernelType(_kernel, _anchor);
int ktype = _kernel.depth() == CV_32S ? KERNEL_INTEGER : getKernelType(_kernel, _anchor);
if( sdepth == CV_8U && (ddepth == CV_8U || ddepth == CV_16S) &&
_kernel.rows*_kernel.cols <= (1 << 10) )
{
bits = (ktype & KERNEL_INTEGER) ? 0 : 11;
_kernel.convertTo(kernel, CV_32S, 1 << bits);
}*/
Ptr<BaseFilter> _filter2D = getLinearFilter(_srcType, _dstType,
kernel, _anchor, _delta, bits);
@@ -3233,7 +3233,7 @@ void cv::filter2D( InputArray _src, OutputArray _dst, int ddepth,
double delta, int borderType )
{
Mat src = _src.getMat(), kernel = _kernel.getMat();
if( ddepth < 0 )
ddepth = src.depth();
@@ -3279,7 +3279,7 @@ void cv::sepFilter2D( InputArray _src, OutputArray _dst, int ddepth,
double delta, int borderType )
{
Mat src = _src.getMat(), kernelX = _kernelX.getMat(), kernelY = _kernelY.getMat();
if( ddepth < 0 )
ddepth = src.depth();

View File

@@ -233,7 +233,7 @@ typedef DiffC3<cv::Vec3i> Diff32sC3;
typedef DiffC1<float> Diff32fC1;
typedef DiffC3<cv::Vec3f> Diff32fC3;
cv::Vec3i& operator += (cv::Vec3i& a, const cv::Vec3b& b)
static cv::Vec3i& operator += (cv::Vec3i& a, const cv::Vec3b& b)
{
a[0] += b[0];
a[1] += b[1];
@@ -440,7 +440,7 @@ cvFloodFill( CvArr* arr, CvPoint seed_point,
{
cv::Ptr<CvMat> tempMask;
cv::AutoBuffer<CvFFillSegment> buffer;
if( comp )
memset( comp, 0, sizeof(*comp) );
@@ -491,16 +491,16 @@ cvFloodFill( CvArr* arr, CvPoint seed_point,
{
/*int elem_size = CV_ELEM_SIZE(type);
const uchar* seed_ptr = img->data.ptr + img->step*seed_point.y + elem_size*seed_point.x;
// check if the new value is different from the current value at the seed point.
// if they are exactly the same, use the generic version with mask to avoid infinite loops.
for( i = 0; i < elem_size; i++ )
if( seed_ptr[i] != ((uchar*)nv_buf)[i] )
break;
if( i == elem_size )
return;*/
if( type == CV_8UC1 )
icvFloodFill_CnIR(img->data.ptr, img->step, size, seed_point, nv_buf.b[0],
comp, flags, buffer, buffer_size);
@@ -632,7 +632,7 @@ int cv::floodFill( InputOutputArray _image, Point seedPoint,
}
int cv::floodFill( InputOutputArray _image, InputOutputArray _mask,
Point seedPoint, Scalar newVal, Rect* rect,
Point seedPoint, Scalar newVal, Rect* rect,
Scalar loDiff, Scalar upDiff, int flags )
{
CvConnectedComp ccomp;

View File

@@ -64,7 +64,7 @@ private:
int ts;
int dist;
TWeight weight;
uchar t;
uchar t;
};
class Edge
{
@@ -174,7 +174,7 @@ TWeight GCGraph<TWeight>::maxFlow()
v->t = v->weight < 0;
}
else
v->parent = 0;
v->parent = 0;
}
first = first->next;
last->next = nilNode;
@@ -290,14 +290,14 @@ TWeight GCGraph<TWeight>::maxFlow()
curr_ts++;
while( !orphans.empty() )
{
Vtx* v = orphans.back();
Vtx* v2 = orphans.back();
orphans.pop_back();
int d, minDist = INT_MAX;
e0 = 0;
vt = v->t;
vt = v2->t;
for( ei = v->first; ei != 0; ei = edgePtr[ei].next )
for( ei = v2->first; ei != 0; ei = edgePtr[ei].next )
{
if( edgePtr[ei^(vt^1)].weight == 0 )
continue;
@@ -344,16 +344,16 @@ TWeight GCGraph<TWeight>::maxFlow()
}
}
if( (v->parent = e0) > 0 )
if( (v2->parent = e0) > 0 )
{
v->ts = curr_ts;
v->dist = minDist;
v2->ts = curr_ts;
v2->dist = minDist;
continue;
}
/* no parent is found */
v->ts = 0;
for( ei = v->first; ei != 0; ei = edgePtr[ei].next )
v2->ts = 0;
for( ei = v2->first; ei != 0; ei = edgePtr[ei].next )
{
u = vtxPtr+edgePtr[ei].dst;
ej = u->parent;
@@ -364,7 +364,7 @@ TWeight GCGraph<TWeight>::maxFlow()
u->next = nilNode;
last = last->next = u;
}
if( ej > 0 && vtxPtr+edgePtr[ej].dst == v )
if( ej > 0 && vtxPtr+edgePtr[ej].dst == v2 )
{
orphans.push_back(u);
u->parent = ORPHAN;

View File

@@ -230,7 +230,7 @@ void GMM::calcInverseCovAndDeterm( int ci )
Calculate beta - parameter of GrabCut algorithm.
beta = 1/(2*avg(sqr(||color[i] - color[j]||)))
*/
double calcBeta( const Mat& img )
static double calcBeta( const Mat& img )
{
double beta = 0;
for( int y = 0; y < img.rows; y++ )
@@ -272,7 +272,7 @@ double calcBeta( const Mat& img )
Calculate weights of noterminal vertices of graph.
beta and gamma - parameters of GrabCut algorithm.
*/
void calcNWeights( const Mat& img, Mat& leftW, Mat& upleftW, Mat& upW, Mat& uprightW, double beta, double gamma )
static void calcNWeights( const Mat& img, Mat& leftW, Mat& upleftW, Mat& upW, Mat& uprightW, double beta, double gamma )
{
const double gammaDivSqrt2 = gamma / std::sqrt(2.0f);
leftW.create( img.rows, img.cols, CV_64FC1 );
@@ -319,7 +319,7 @@ void calcNWeights( const Mat& img, Mat& leftW, Mat& upleftW, Mat& upW, Mat& upri
/*
Check size, type and element values of mask matrix.
*/
void checkMask( const Mat& img, const Mat& mask )
static void checkMask( const Mat& img, const Mat& mask )
{
if( mask.empty() )
CV_Error( CV_StsBadArg, "mask is empty" );
@@ -342,7 +342,7 @@ void checkMask( const Mat& img, const Mat& mask )
/*
Initialize mask using rectangular.
*/
void initMaskWithRect( Mat& mask, Size imgSize, Rect rect )
static void initMaskWithRect( Mat& mask, Size imgSize, Rect rect )
{
mask.create( imgSize, CV_8UC1 );
mask.setTo( GC_BGD );
@@ -358,7 +358,7 @@ void initMaskWithRect( Mat& mask, Size imgSize, Rect rect )
/*
Initialize GMM background and foreground models using kmeans algorithm.
*/
void initGMMs( const Mat& img, const Mat& mask, GMM& bgdGMM, GMM& fgdGMM )
static void initGMMs( const Mat& img, const Mat& mask, GMM& bgdGMM, GMM& fgdGMM )
{
const int kMeansItCount = 10;
const int kMeansType = KMEANS_PP_CENTERS;
@@ -398,7 +398,7 @@ void initGMMs( const Mat& img, const Mat& mask, GMM& bgdGMM, GMM& fgdGMM )
/*
Assign GMMs components for each pixel.
*/
void assignGMMsComponents( const Mat& img, const Mat& mask, const GMM& bgdGMM, const GMM& fgdGMM, Mat& compIdxs )
static void assignGMMsComponents( const Mat& img, const Mat& mask, const GMM& bgdGMM, const GMM& fgdGMM, Mat& compIdxs )
{
Point p;
for( p.y = 0; p.y < img.rows; p.y++ )
@@ -415,7 +415,7 @@ void assignGMMsComponents( const Mat& img, const Mat& mask, const GMM& bgdGMM, c
/*
Learn GMMs parameters.
*/
void learnGMMs( const Mat& img, const Mat& mask, const Mat& compIdxs, GMM& bgdGMM, GMM& fgdGMM )
static void learnGMMs( const Mat& img, const Mat& mask, const Mat& compIdxs, GMM& bgdGMM, GMM& fgdGMM )
{
bgdGMM.initLearning();
fgdGMM.initLearning();
@@ -443,7 +443,7 @@ void learnGMMs( const Mat& img, const Mat& mask, const Mat& compIdxs, GMM& bgdGM
/*
Construct GCGraph
*/
void constructGCGraph( const Mat& img, const Mat& mask, const GMM& bgdGMM, const GMM& fgdGMM, double lambda,
static void constructGCGraph( const Mat& img, const Mat& mask, const GMM& bgdGMM, const GMM& fgdGMM, double lambda,
const Mat& leftW, const Mat& upleftW, const Mat& upW, const Mat& uprightW,
GCGraph<double>& graph )
{
@@ -506,7 +506,7 @@ void constructGCGraph( const Mat& img, const Mat& mask, const GMM& bgdGMM, const
/*
Estimate segmentation using MaxFlow algorithm
*/
void estimateSegmentation( GCGraph<double>& graph, Mat& mask )
static void estimateSegmentation( GCGraph<double>& graph, Mat& mask )
{
graph.maxFlow();
Point p;
@@ -533,7 +533,7 @@ void cv::grabCut( InputArray _img, InputOutputArray _mask, Rect rect,
Mat& mask = _mask.getMatRef();
Mat& bgdModel = _bgdModel.getMatRef();
Mat& fgdModel = _fgdModel.getMatRef();
if( img.empty() )
CV_Error( CV_StsBadArg, "image is empty" );
if( img.type() != CV_8UC3 )

File diff suppressed because it is too large Load Diff

View File

@@ -92,8 +92,6 @@ icvHoughLinesStandard( const CvMat* img, float rho, float theta,
int step, width, height;
int numangle, numrho;
int total = 0;
float ang;
int r, n;
int i, j;
float irho = 1 / rho;
double scale;
@@ -114,10 +112,11 @@ icvHoughLinesStandard( const CvMat* img, float rho, float theta,
_tabCos.allocate(numangle);
int *accum = _accum, *sort_buf = _sort_buf;
float *tabSin = _tabSin, *tabCos = _tabCos;
memset( accum, 0, sizeof(accum[0]) * (numangle+2) * (numrho+2) );
for( ang = 0, n = 0; n < numangle; ang += theta, n++ )
float ang = 0;
for(int n = 0; n < numangle; ang += theta, n++ )
{
tabSin[n] = (float)(sin(ang) * irho);
tabCos[n] = (float)(cos(ang) * irho);
@@ -128,17 +127,17 @@ icvHoughLinesStandard( const CvMat* img, float rho, float theta,
for( j = 0; j < width; j++ )
{
if( image[i * step + j] != 0 )
for( n = 0; n < numangle; n++ )
for(int n = 0; n < numangle; n++ )
{
r = cvRound( j * tabCos[n] + i * tabSin[n] );
int r = cvRound( j * tabCos[n] + i * tabSin[n] );
r += (numrho - 1) / 2;
accum[(n+1) * (numrho+2) + r+1]++;
}
}
// stage 2. find local maximums
for( r = 0; r < numrho; r++ )
for( n = 0; n < numangle; n++ )
for(int r = 0; r < numrho; r++ )
for(int n = 0; n < numangle; n++ )
{
int base = (n+1) * (numrho+2) + r+1;
if( accum[base] > threshold &&
@@ -170,10 +169,6 @@ icvHoughLinesStandard( const CvMat* img, float rho, float theta,
* Multi-Scale variant of Classical Hough Transform *
\****************************************************************************************/
#if defined _MSC_VER && _MSC_VER >= 1200
#pragma warning( disable: 4714 )
#endif
//DECLARE_AND_IMPLEMENT_LIST( _index, h_ );
IMPLEMENT_LIST( _index, h_ )
@@ -249,7 +244,7 @@ icvHoughLinesSDiv( const CvMat* img,
/* Precalculating sin */
_sinTable.resize( 5 * tn * stn );
sinTable = &_sinTable[0];
for( index = 0; index < 5 * tn * stn; index++ )
sinTable[index] = (float)cos( stheta * index * 0.2f );
@@ -449,7 +444,7 @@ icvHoughLinesSDiv( const CvMat* img,
h_get_next__index( &pos );
}
}
h_destroy_list__index(list);
}
@@ -529,7 +524,7 @@ icvHoughLinesProbabilistic( CvMat* image,
// choose random point out of the remaining ones
int idx = cvRandInt(&rng) % count;
int max_val = threshold-1, max_n = 0;
CvPoint* pt = (CvPoint*)cvGetSeqElem( seq, idx );
CvPoint* point = (CvPoint*)cvGetSeqElem( seq, idx );
CvPoint line_end[2] = {{0,0}, {0,0}};
float a, b;
int* adata = (int*)accum.data;
@@ -537,11 +532,11 @@ icvHoughLinesProbabilistic( CvMat* image,
int good_line;
const int shift = 16;
i = pt->y;
j = pt->x;
i = point->y;
j = point->x;
// "remove" it by overriding it with the last element
*pt = *(CvPoint*)cvGetSeqElem( seq, count-1 );
*point = *(CvPoint*)cvGetSeqElem( seq, count-1 );
// check if it has been excluded already (i.e. belongs to some other line)
if( !mdata0[i*width + j] )
@@ -756,7 +751,7 @@ cvHoughLines2( CvArr* src_image, void* lineStorage, int method,
}
else
CV_Error( CV_StsBadArg, "Destination is not CvMemStorage* nor CvMat*" );
iparam1 = cvRound(param1);
iparam2 = cvRound(param2);
@@ -842,7 +837,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
acols = accum->cols - 2;
adata = accum->data.i;
astep = accum->step/sizeof(adata[0]);
// Accumulate circle evidence for each edge pixel
// Accumulate circle evidence for each edge pixel
for( y = 0; y < rows; y++ )
{
const uchar* edges_row = edges->data.ptr + y*edges->step;
@@ -852,7 +847,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
for( x = 0; x < cols; x++ )
{
float vx, vy;
int sx, sy, x0, y0, x1, y1, r, k;
int sx, sy, x0, y0, x1, y1, r;
CvPoint pt;
vx = dx_row[x];
@@ -868,8 +863,8 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
x0 = cvRound((x*idp)*ONE);
y0 = cvRound((y*idp)*ONE);
// Step from min_radius to max_radius in both directions of the gradient
for( k = 0; k < 2; k++ )
// Step from min_radius to max_radius in both directions of the gradient
for(int k1 = 0; k1 < 2; k1++ )
{
x1 = x0 + min_radius * sx;
y1 = y0 + min_radius * sy;
@@ -894,7 +889,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
nz_count = nz->total;
if( !nz_count )
return;
//Find possible circle centers
//Find possible circle centers
for( y = 1; y < arows - 1; y++ )
{
for( x = 1; x < acols - 1; x++ )
@@ -924,19 +919,19 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
dr = dp;
min_dist = MAX( min_dist, dp );
min_dist *= min_dist;
// For each found possible center
// Estimate radius and check support
// For each found possible center
// Estimate radius and check support
for( i = 0; i < centers->total; i++ )
{
int ofs = *(int*)cvGetSeqElem( centers, i );
y = ofs/(acols+2);
x = ofs - (y)*(acols+2);
//Calculate circle's center in pixels
//Calculate circle's center in pixels
float cx = (float)((x + 0.5f)*dp), cy = (float)(( y + 0.5f )*dp);
float start_dist, dist_sum;
float r_best = 0, c[3];
float r_best = 0;
int max_count = 0;
// Check distance with previously detected circles
// Check distance with previously detected circles
for( j = 0; j < circles->total; j++ )
{
float* c = (float*)cvGetSeqElem( circles, j );
@@ -946,7 +941,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
if( j < circles->total )
continue;
// Estimate best radius
// Estimate best radius
cvStartReadSeq( nz, &reader );
for( j = k = 0; j < nz_count; j++ )
{
@@ -982,7 +977,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
{
float r_cur = ddata[sort_buf[(j + start_idx)/2]];
if( (start_idx - j)*r_best >= max_count*r_cur ||
(r_best < FLT_EPSILON && start_idx - j >= max_count) )
(r_best < FLT_EPSILON && start_idx - j >= max_count) )
{
r_best = r_cur;
max_count = start_idx - j;
@@ -993,9 +988,10 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist,
}
dist_sum += d;
}
// Check if the circle has enough support
// Check if the circle has enough support
if( max_count > acc_threshold )
{
float c[3];
c[0] = cx;
c[1] = cy;
c[2] = (float)r_best;
@@ -1103,9 +1099,9 @@ static void seqToMat(const CvSeq* seq, OutputArray _arr)
else
_arr.release();
}
}
void cv::HoughLines( InputArray _image, OutputArray _lines,
double rho, double theta, int threshold,
double srn, double stn )

View File

@@ -97,7 +97,6 @@ static inline void interpolateLanczos4( float x, float* coeffs )
static const double cs[][2]=
{{1, 0}, {-s45, -s45}, {0, 1}, {s45, -s45}, {-1, 0}, {s45, s45}, {0, -1}, {-s45, s45}};
int i;
if( x < FLT_EPSILON )
{
for( int i = 0; i < 8; i++ )
@@ -108,7 +107,7 @@ static inline void interpolateLanczos4( float x, float* coeffs )
float sum = 0;
double y0=-(x+3)*CV_PI*0.25, s0 = sin(y0), c0=cos(y0);
for( i = 0; i < 8; i++ )
for(int i = 0; i < 8; i++ )
{
double y = -(x+3-i)*CV_PI*0.25;
coeffs[i] = (float)((cs[i][0]*s0 + cs[i][1]*c0)/(y*y));
@@ -116,7 +115,7 @@ static inline void interpolateLanczos4( float x, float* coeffs )
}
sum = 1.f/sum;
for( i = 0; i < 8; i++ )
for(int i = 0; i < 8; i++ )
coeffs[i] *= sum;
}
@@ -1091,14 +1090,14 @@ static void resizeGeneric_( const Mat& src, Mat& dst,
const T* srows[MAX_ESIZE]={0};
WT* rows[MAX_ESIZE]={0};
int prev_sy[MAX_ESIZE];
int k, dy;
int dy;
xmin *= cn;
xmax *= cn;
HResize hresize;
VResize vresize;
for( k = 0; k < ksize; k++ )
for(int k = 0; k < ksize; k++ )
{
prev_sy[k] = -1;
rows[k] = (WT*)_buffer + bufstep*k;
@@ -1107,9 +1106,9 @@ static void resizeGeneric_( const Mat& src, Mat& dst,
// image resize is a separable operation. In case of not too strong
for( dy = 0; dy < dsize.height; dy++, beta += ksize )
{
int sy0 = yofs[dy], k, k0=ksize, k1=0, ksize2 = ksize/2;
int sy0 = yofs[dy], k0=ksize, k1=0, ksize2 = ksize/2;
for( k = 0; k < ksize; k++ )
for(int k = 0; k < ksize; k++ )
{
int sy = clip(sy0 - ksize2 + 1 + k, 0, ssize.height);
for( k1 = std::max(k1, k); k1 < ksize; k1++ )
@@ -1522,7 +1521,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
assert( k < ssize.width*2 );
xofs[k].di = dx*cn;
xofs[k].si = sx*cn;
xofs[k++].alpha = 1.f / min(scale_x, src.cols - fsx1);
xofs[k++].alpha = float(1.0 / min(scale_x, src.cols - fsx1));
}
if( fsx2 - sx2 > 1e-3 )
@@ -2374,25 +2373,25 @@ static void remapLanczos4( const Mat& _src, Mat& _dst, const Mat& _xy,
for( i = 0; i < 8; i++, w += 8 )
{
int yi = y[i];
const T* S = S0 + yi*sstep;
const T* S1 = S0 + yi*sstep;
if( yi < 0 )
continue;
if( x[0] >= 0 )
sum += (S[x[0]] - cv)*w[0];
sum += (S1[x[0]] - cv)*w[0];
if( x[1] >= 0 )
sum += (S[x[1]] - cv)*w[1];
sum += (S1[x[1]] - cv)*w[1];
if( x[2] >= 0 )
sum += (S[x[2]] - cv)*w[2];
sum += (S1[x[2]] - cv)*w[2];
if( x[3] >= 0 )
sum += (S[x[3]] - cv)*w[3];
sum += (S1[x[3]] - cv)*w[3];
if( x[4] >= 0 )
sum += (S[x[4]] - cv)*w[4];
sum += (S1[x[4]] - cv)*w[4];
if( x[5] >= 0 )
sum += (S[x[5]] - cv)*w[5];
sum += (S1[x[5]] - cv)*w[5];
if( x[6] >= 0 )
sum += (S[x[6]] - cv)*w[6];
sum += (S1[x[6]] - cv)*w[6];
if( x[7] >= 0 )
sum += (S[x[7]] - cv)*w[7];
sum += (S1[x[7]] - cv)*w[7];
}
D[k] = castOp(sum);
}
@@ -2966,8 +2965,8 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
remap( src, dpart, _XY, Mat(), interpolation, borderType, borderValue );
else
{
Mat matA(bh, bw, CV_16U, A);
remap( src, dpart, _XY, matA, interpolation, borderType, borderValue );
Mat _matA(bh, bw, CV_16U, A);
remap( src, dpart, _XY, _matA, interpolation, borderType, borderValue );
}
}
}
@@ -3064,8 +3063,8 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,
remap( src, dpart, _XY, Mat(), interpolation, borderType, borderValue );
else
{
Mat matA(bh, bw, CV_16U, A);
remap( src, dpart, _XY, matA, interpolation, borderType, borderValue );
Mat _matA(bh, bw, CV_16U, A);
remap( src, dpart, _XY, _matA, interpolation, borderType, borderValue );
}
}
}

View File

@@ -106,7 +106,7 @@ static void icvContourMoments( CvSeq* contour, CvMoments* moments )
yi_1 = ((CvPoint2D32f*)(reader.ptr))->y;
}
CV_NEXT_SEQ_ELEM( contour->elem_size, reader );
xi_12 = xi_1 * xi_1;
yi_12 = yi_1 * yi_1;
@@ -208,7 +208,7 @@ static void momentsInTile( const cv::Mat& img, double* moments )
const T* ptr = (const T*)(img.data + y*img.step);
WT x0 = 0, x1 = 0, x2 = 0;
MT x3 = 0;
for( x = 0; x < size.width; x++ )
{
WT p = ptr[x];
@@ -248,21 +248,21 @@ template<> void momentsInTile<uchar, int, int>( const cv::Mat& img, double* mome
typedef int WT;
typedef int MT;
cv::Size size = img.size();
int x, y;
int y;
MT mom[10] = {0,0,0,0,0,0,0,0,0,0};
bool useSIMD = cv::checkHardwareSupport(CV_CPU_SSE2);
for( y = 0; y < size.height; y++ )
{
const T* ptr = img.ptr<T>(y);
int x0 = 0, x1 = 0, x2 = 0, x3 = 0, x = 0;
if( useSIMD )
{
__m128i qx_init = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7);
__m128i dx = _mm_set1_epi16(8);
__m128i z = _mm_setzero_si128(), qx0 = z, qx1 = z, qx2 = z, qx3 = z, qx = qx_init;
for( ; x <= size.width - 8; x += 8 )
{
__m128i p = _mm_unpacklo_epi8(_mm_loadl_epi64((const __m128i*)(ptr + x)), z);
@@ -272,34 +272,34 @@ template<> void momentsInTile<uchar, int, int>( const cv::Mat& img, double* mome
qx1 = _mm_add_epi32(qx1, _mm_madd_epi16(p, qx));
qx2 = _mm_add_epi32(qx2, _mm_madd_epi16(p, sx));
qx3 = _mm_add_epi32(qx3, _mm_madd_epi16(px, sx));
qx = _mm_add_epi16(qx, dx);
}
int CV_DECL_ALIGNED(16) buf[4];
_mm_store_si128((__m128i*)buf, qx0);
x0 = buf[0] + buf[1] + buf[2] + buf[3];
_mm_store_si128((__m128i*)buf, qx1);
x1 = buf[0] + buf[1] + buf[2] + buf[3];
x1 = buf[0] + buf[1] + buf[2] + buf[3];
_mm_store_si128((__m128i*)buf, qx2);
x2 = buf[0] + buf[1] + buf[2] + buf[3];
_mm_store_si128((__m128i*)buf, qx3);
x3 = buf[0] + buf[1] + buf[2] + buf[3];
}
for( ; x < size.width; x++ )
{
WT p = ptr[x];
WT xp = x * p, xxp;
x0 += p;
x1 += xp;
xxp = xp * x;
x2 += xxp;
x3 += xxp * x;
}
WT py = y * x0, sy = y*y;
mom[9] += ((MT)py) * sy; // m03
mom[8] += ((MT)x1) * sy; // m12
mom[7] += ((MT)x2) * y; // m21
@@ -311,8 +311,8 @@ template<> void momentsInTile<uchar, int, int>( const cv::Mat& img, double* mome
mom[1] += x1; // m10
mom[0] += x0; // m00
}
for( x = 0; x < 10; x++ )
for(int x = 0; x < 10; x++ )
moments[x] = (double)mom[x];
}
@@ -366,7 +366,7 @@ CV_IMPL void cvMoments( const void* array, CvMoments* moments, int binary )
type = CV_MAT_TYPE( mat->type );
depth = CV_MAT_DEPTH( type );
cn = CV_MAT_CN( type );
cv::Size size = cvGetMatSize( mat );
if( cn > 1 && coi == 0 )
@@ -387,14 +387,14 @@ CV_IMPL void cvMoments( const void* array, CvMoments* moments, int binary )
func = momentsInTile<double, double, double>;
else
CV_Error( CV_StsUnsupportedFormat, "" );
cv::Mat src0(mat);
for( int y = 0; y < size.height; y += TILE_SIZE )
{
cv::Size tileSize;
tileSize.height = std::min(TILE_SIZE, size.height - y);
for( int x = 0; x < size.width; x += TILE_SIZE )
{
tileSize.width = std::min(TILE_SIZE, size.width - x);
@@ -413,20 +413,20 @@ CV_IMPL void cvMoments( const void* array, CvMoments* moments, int binary )
cv::compare( src, 0, tmp, CV_CMP_NE );
src = tmp;
}
double mom[10];
func( src, mom );
if(binary)
{
double s = 1./255;
for( int k = 0; k < 10; k++ )
mom[k] *= s;
}
double xm = x * mom[0], ym = y * mom[0];
// accumulate moments computed in each tile
// accumulate moments computed in each tile
// + m00 ( = m00' )
moments->m00 += mom[0];
@@ -451,7 +451,7 @@ CV_IMPL void cvMoments( const void* array, CvMoments* moments, int binary )
// + m21 ( = m21' + x*(2*m11' + 2*y*m10' + x*m01' + x*y*m00') + y*m20')
moments->m21 += mom[7] + x * (2 * (mom[4] + y * mom[1]) + x * (mom[2] + ym)) + y * mom[3];
// + m12 ( = m12' + y*(2*m11' + 2*x*m01' + y*m10' + x*y*m00') + x*m02')
moments->m12 += mom[8] + y * (2 * (mom[4] + x * mom[2]) + y * (mom[1] + xm)) + x * mom[5];
@@ -601,9 +601,9 @@ Moments::operator CvMoments() const
return m;
}
}
cv::Moments cv::moments( InputArray _array, bool binaryImage )
{
CvMoments om;

View File

@@ -406,42 +406,42 @@ static void fftShift(InputOutputArray _out)
merge(planes, out);
}
Point2d weightedCentroid(InputArray _src, cv::Point peakLocation, cv::Size weightBoxSize)
static Point2d weightedCentroid(InputArray _src, cv::Point peakLocation, cv::Size weightBoxSize)
{
Mat src = _src.getMat();
int type = src.type();
CV_Assert( type == CV_32FC1 || type == CV_64FC1 );
int minr = peakLocation.y - (weightBoxSize.height >> 1);
int maxr = peakLocation.y + (weightBoxSize.height >> 1);
int minc = peakLocation.x - (weightBoxSize.width >> 1);
int maxc = peakLocation.x + (weightBoxSize.width >> 1);
Point2d centroid;
double sumIntensity = 0.0;
// clamp the values to min and max if needed.
if(minr < 0)
{
minr = 0;
}
if(minc < 0)
{
minc = 0;
}
if(maxr > src.rows - 1)
{
maxr = src.rows - 1;
}
if(maxc > src.cols - 1)
{
maxc = src.cols - 1;
}
if(type == CV_32FC1)
{
const float* dataIn = (const float*)src.data;
@@ -454,7 +454,7 @@ Point2d weightedCentroid(InputArray _src, cv::Point peakLocation, cv::Size weigh
centroid.y += (double)y*dataIn[x];
sumIntensity += (double)dataIn[x];
}
dataIn += src.cols;
}
}
@@ -470,19 +470,19 @@ Point2d weightedCentroid(InputArray _src, cv::Point peakLocation, cv::Size weigh
centroid.y += (double)y*dataIn[x];
sumIntensity += dataIn[x];
}
dataIn += src.cols;
}
}
sumIntensity += DBL_EPSILON; // prevent div0 problems...
centroid.x /= sumIntensity;
centroid.y /= sumIntensity;
return centroid;
}
}
cv::Point2d cv::phaseCorrelate(InputArray _src1, InputArray _src2, InputArray _window)

View File

@@ -43,11 +43,6 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#if defined _MSC_VER && _MSC_VER >= 1200
// disable warnings related to inline functions
#pragma warning( disable: 4251 4711 4710 4514 )
#endif
#ifdef HAVE_CVCONFIG_H
#include "cvconfig.h"
#endif

View File

@@ -64,18 +64,18 @@ icvMinAreaState;
// Parameters:
// points - convex hull vertices ( any orientation )
// n - number of vertices
// mode - concrete application of algorithm
// can be CV_CALIPERS_MAXDIST or
// CV_CALIPERS_MINAREARECT
// mode - concrete application of algorithm
// can be CV_CALIPERS_MAXDIST or
// CV_CALIPERS_MINAREARECT
// left, bottom, right, top - indexes of extremal points
// out - output info.
// In case CV_CALIPERS_MAXDIST it points to float value -
// In case CV_CALIPERS_MAXDIST it points to float value -
// maximal height of polygon.
// In case CV_CALIPERS_MINAREARECT
// ((CvPoint2D32f*)out)[0] - corner
// ((CvPoint2D32f*)out)[0] - corner
// ((CvPoint2D32f*)out)[1] - vector1
// ((CvPoint2D32f*)out)[0] - corner2
//
//
// ^
// |
// vector2 |
@@ -94,15 +94,15 @@ icvRotatingCalipers( CvPoint2D32f* points, int n, int mode, float* out )
{
float minarea = FLT_MAX;
float max_dist = 0;
char buffer[32];
char buffer[32] = {};
int i, k;
CvPoint2D32f* vect = (CvPoint2D32f*)cvAlloc( n * sizeof(vect[0]) );
float* inv_vect_length = (float*)cvAlloc( n * sizeof(inv_vect_length[0]) );
int left = 0, bottom = 0, right = 0, top = 0;
int seq[4] = { -1, -1, -1, -1 };
/* rotating calipers sides will always have coordinates
(a,b) (-b,a) (-a,-b) (b, -a)
/* rotating calipers sides will always have coordinates
(a,b) (-b,a) (-a,-b) (b, -a)
*/
/* this is a first base bector (a,b) initialized by (1,0) */
float orientation = 0;
@@ -111,14 +111,14 @@ icvRotatingCalipers( CvPoint2D32f* points, int n, int mode, float* out )
float left_x, right_x, top_y, bottom_y;
CvPoint2D32f pt0 = points[0];
left_x = right_x = pt0.x;
top_y = bottom_y = pt0.y;
for( i = 0; i < n; i++ )
{
double dx, dy;
if( pt0.x < left_x )
left_x = pt0.x, left = i;
@@ -132,7 +132,7 @@ icvRotatingCalipers( CvPoint2D32f* points, int n, int mode, float* out )
bottom_y = pt0.y, bottom = i;
CvPoint2D32f pt = points[(i+1) & (i+1 < n ? -1 : 0)];
dx = pt.x - pt0.x;
dy = pt.y - pt0.y;
@@ -149,7 +149,7 @@ icvRotatingCalipers( CvPoint2D32f* points, int n, int mode, float* out )
{
double ax = vect[n-1].x;
double ay = vect[n-1].y;
for( i = 0; i < n; i++ )
{
double bx = vect[i].x;
@@ -218,7 +218,7 @@ icvRotatingCalipers( CvPoint2D32f* points, int n, int mode, float* out )
base_b = lead_y;
break;
case 1:
base_a = lead_y;
base_a = lead_y;
base_b = -lead_x;
break;
case 2:
@@ -231,12 +231,12 @@ icvRotatingCalipers( CvPoint2D32f* points, int n, int mode, float* out )
break;
default: assert(0);
}
}
}
/* change base point of main edge */
seq[main_element] += 1;
seq[main_element] = (seq[main_element] == n) ? 0 : seq[main_element];
switch (mode)
{
case CV_CALIPERS_MAXHEIGHT:
@@ -351,7 +351,7 @@ cvMinAreaRect2( const CvArr* array, CvMemStorage* storage )
CvBox2D box;
cv::AutoBuffer<CvPoint2D32f> _points;
CvPoint2D32f* points;
memset(&box, 0, sizeof(box));
int i, n;
@@ -409,7 +409,7 @@ cvMinAreaRect2( const CvArr* array, CvMemStorage* storage )
CV_READ_SEQ_ELEM( points[i], reader );
}
}
if( n > 2 )
{
icvRotatingCalipers( points, n, CV_CALIPERS_MINAREARECT, (float*)out );

View File

@@ -49,7 +49,7 @@ cvArcLength( const void *array, CvSlice slice, int is_closed )
int i, j = 0, count;
const int N = 16;
float buf[N];
CvMat buffer = cvMat( 1, N, CV_32F, buf );
CvMat buffer = cvMat( 1, N, CV_32F, buf );
CvSeqReader reader;
CvContour contour_header;
CvSeq* contour = 0;
@@ -74,7 +74,7 @@ cvArcLength( const void *array, CvSlice slice, int is_closed )
if( contour->total > 1 )
{
int is_float = CV_SEQ_ELTYPE( contour ) == CV_32FC2;
cvStartReadSeq( contour, &reader, 0 );
cvSetSeqReaderPos( &reader, slice.start_index );
count = cvSliceLength( slice, contour );
@@ -110,7 +110,7 @@ cvArcLength( const void *array, CvSlice slice, int is_closed )
CV_NEXT_SEQ_ELEM( contour->elem_size, reader );
// Bugfix by Axel at rubico.com 2010-03-22, affects closed slices only
// wraparound not handled by CV_NEXT_SEQ_ELEM
if( is_closed && i == count - 2 )
if( is_closed && i == count - 2 )
cvSetSeqReaderPos( &reader, slice.start_index );
buffer.data.fl[j] = dx * dx + dy * dy;
@@ -287,7 +287,7 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
*_radius = 0;
CvSeqReader reader;
int i, k, count;
int k, count;
CvPoint2D32f pts[8];
CvContour contour_header;
CvSeqBlock block;
@@ -324,7 +324,7 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
pt_left = pt_right = pt_top = pt_bottom = (CvPoint *)(reader.ptr);
CV_READ_SEQ_ELEM( pt, reader );
for( i = 1; i < count; i++ )
for(int i = 1; i < count; i++ )
{
CvPoint* pt_ptr = (CvPoint*)reader.ptr;
CV_READ_SEQ_ELEM( pt, reader );
@@ -351,7 +351,7 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
pt_left = pt_right = pt_top = pt_bottom = (CvPoint2D32f *) (reader.ptr);
CV_READ_SEQ_ELEM( pt, reader );
for( i = 1; i < count; i++ )
for(int i = 1; i < count; i++ )
{
CvPoint2D32f* pt_ptr = (CvPoint2D32f*)reader.ptr;
CV_READ_SEQ_ELEM( pt, reader );
@@ -375,14 +375,14 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
for( k = 0; k < max_iters; k++ )
{
double min_delta = 0, delta;
CvPoint2D32f ptfl, farAway = { 0, 0};
/*only for first iteration because the alg is repared at the loop's foot*/
if(k==0)
icvFindEnslosingCicle4pts_32f( pts, &center, &radius );
CvPoint2D32f ptfl, farAway = { 0, 0};
/*only for first iteration because the alg is repared at the loop's foot*/
if(k==0)
icvFindEnslosingCicle4pts_32f( pts, &center, &radius );
cvStartReadSeq( sequence, &reader, 0 );
for( i = 0; i < count; i++ )
for(int i = 0; i < count; i++ )
{
if( !is_float )
{
@@ -406,22 +406,22 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
if( result )
break;
CvPoint2D32f ptsCopy[4];
/* find good replacement partner for the point which is at most far away,
starting with the one that lays in the actual circle (i=3) */
for(int i = 3; i >=0; i-- )
{
for(int j = 0; j < 4; j++ )
{
ptsCopy[j]=(i != j)? pts[j]: farAway;
}
CvPoint2D32f ptsCopy[4];
/* find good replacement partner for the point which is at most far away,
starting with the one that lays in the actual circle (i=3) */
for(int i = 3; i >=0; i-- )
{
for(int j = 0; j < 4; j++ )
{
ptsCopy[j]=(i != j)? pts[j]: farAway;
}
icvFindEnslosingCicle4pts_32f(ptsCopy, &center, &radius );
if( icvIsPtInCircle( pts[i], center, radius )>=0){ // replaced one again in the new circle?
pts[i] = farAway;
break;
}
}
icvFindEnslosingCicle4pts_32f(ptsCopy, &center, &radius );
if( icvIsPtInCircle( pts[i], center, radius )>=0){ // replaced one again in the new circle?
pts[i] = farAway;
break;
}
}
}
if( !result )
@@ -429,7 +429,7 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
cvStartReadSeq( sequence, &reader, 0 );
radius = 0.f;
for( i = 0; i < count; i++ )
for(int i = 0; i < count; i++ )
{
CvPoint2D32f ptfl;
float t, dx, dy;
@@ -486,7 +486,7 @@ icvContourArea( const CvSeq* contour, double *area )
yi_1 = ((CvPoint2D32f*)(reader.ptr))->y;
}
CV_NEXT_SEQ_ELEM( contour->elem_size, reader );
while( lpt-- > 0 )
{
double dxy, xi, yi;
@@ -520,7 +520,7 @@ icvContourArea( const CvSeq* contour, double *area )
/****************************************************************************************\
copy data from one buffer to other buffer
copy data from one buffer to other buffer
\****************************************************************************************/
@@ -797,9 +797,9 @@ cvFitEllipse2( const CvArr* array )
n = ptseq->total;
if( n < 5 )
CV_Error( CV_StsBadSize, "Number of points should be >= 5" );
/*
* New fitellipse algorithm, contributed by Dr. Daniel Weiss
* New fitellipse algorithm, contributed by Dr. Daniel Weiss
*/
CvPoint2D32f c = {0,0};
double gfp[5], rp[5], t;
@@ -818,7 +818,7 @@ cvFitEllipse2( const CvArr* array )
cvStartReadSeq( ptseq, &reader );
is_float = CV_SEQ_ELTYPE(ptseq) == CV_32FC2;
for( i = 0; i < n; i++ )
{
CvPoint2D32f p;
@@ -857,7 +857,7 @@ cvFitEllipse2( const CvArr* array )
Ad[i*5 + 3] = p.x;
Ad[i*5 + 4] = p.y;
}
cvSolve( &A, &b, &x, CV_SVD );
// now use general-form parameters A - E to find the ellipse center:
@@ -1069,7 +1069,7 @@ cvBoundingRect( CvArr* array, int update )
xmin = ymin = 0;
}
else if( ptseq->total )
{
{
int is_float = CV_SEQ_ELTYPE(ptseq) == CV_32FC2;
cvStartReadSeq( ptseq, &reader, 0 );
@@ -1082,12 +1082,12 @@ cvBoundingRect( CvArr* array, int update )
ymin = ymax = pt.y;
for( i = 1; i < ptseq->total; i++ )
{
{
CV_READ_SEQ_ELEM( pt, reader );
if( xmin > pt.x )
xmin = pt.x;
if( xmax < pt.x )
xmax = pt.x;
@@ -1108,14 +1108,14 @@ cvBoundingRect( CvArr* array, int update )
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);
if( xmin > pt.x )
xmin = pt.x;
if( xmax < pt.x )
xmax = pt.x;
@@ -1144,7 +1144,7 @@ cvBoundingRect( CvArr* array, int update )
if( update )
((CvContour*)ptseq)->rect = rect;
return rect;
}

View File

@@ -73,13 +73,13 @@ template<typename T, typename ST> struct RowSum : public BaseRowFilter
ksize = _ksize;
anchor = _anchor;
}
void operator()(const uchar* src, uchar* dst, int width, int cn)
{
const T* S = (const T*)src;
ST* D = (ST*)dst;
int i = 0, k, ksz_cn = ksize*cn;
width = (width - 1)*cn;
for( k = 0; k < cn; k++, S++, D++ )
{
@@ -108,7 +108,7 @@ template<typename ST, typename T> struct ColumnSum : public BaseColumnFilter
}
void reset() { sumCount = 0; }
void operator()(const uchar** src, uchar* dst, int dststep, int count, int width)
{
int i;
@@ -198,7 +198,7 @@ template<typename ST, typename T> struct ColumnSum : public BaseColumnFilter
}
cv::Ptr<cv::BaseRowFilter> cv::getRowSumFilter(int srcType, int sumType, int ksize, int anchor)
{
int sdepth = CV_MAT_DEPTH(srcType), ddepth = CV_MAT_DEPTH(sumType);
@@ -325,7 +325,7 @@ void cv::blur( InputArray src, OutputArray dst,
Size ksize, Point anchor, int borderType )
{
boxFilter( src, dst, -1, ksize, anchor, true, borderType );
}
}
/****************************************************************************************\
Gaussian Blur
@@ -422,7 +422,7 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
Mat src = _src.getMat();
_dst.create( src.size(), src.type() );
Mat dst = _dst.getMat();
if( borderType != BORDER_CONSTANT )
{
if( src.rows == 1 )
@@ -453,11 +453,6 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
namespace cv
{
#if _MSC_VER >= 1200
#pragma warning( disable: 4244 )
#endif
typedef ushort HT;
/**
@@ -479,7 +474,7 @@ typedef struct
#if CV_SSE2
#define MEDIAN_HAVE_SIMD 1
static inline void histogram_add_simd( const HT x[16], HT y[16] )
{
const __m128i* rx = (const __m128i*)x;
@@ -499,12 +494,12 @@ static inline void histogram_sub_simd( const HT x[16], HT y[16] )
_mm_store_si128(ry+0, r0);
_mm_store_si128(ry+1, r1);
}
#else
#define MEDIAN_HAVE_SIMD 0
#endif
static inline void histogram_add( const HT x[16], HT y[16] )
{
int i;
@@ -569,7 +564,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
for( c = 0; c < cn; c++ )
{
for( j = 0; j < n; j++ )
COP( c, j, src[cn*j+c], += r+2 );
COP( c, j, src[cn*j+c], += (cv::HT)(r+2) );
for( i = 1; i < r; i++ )
{
@@ -628,7 +623,7 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
if ( luc[c][k] <= j-r )
{
memset( &H[c].fine[k], 0, 16 * sizeof(HT) );
for ( luc[c][k] = j-r; luc[c][k] < MIN(j+r+1,n); ++luc[c][k] )
for ( luc[c][k] = cv::HT(j-r); luc[c][k] < MIN(j+r+1,n); ++luc[c][k] )
histogram_add_simd( &h_fine[16*(n*(16*c+k)+luc[c][k])], H[c].fine[k] );
if ( luc[c][k] < j+r+1 )
@@ -667,14 +662,14 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
{
for( j = 0; j < 2*r; ++j )
histogram_add( &h_coarse[16*(n*c+j)], H[c].coarse );
for( j = r; j < n-r; j++ )
{
int t = 2*r*r + 2*r, b, sum = 0;
HT* segment;
histogram_add( &h_coarse[16*(n*c + std::min(j+r,n-1))], H[c].coarse );
// Find median at coarse level
for ( k = 0; k < 16 ; ++k )
{
@@ -686,14 +681,14 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
}
}
assert( k < 16 );
/* Update corresponding histogram segment */
if ( luc[c][k] <= j-r )
{
memset( &H[c].fine[k], 0, 16 * sizeof(HT) );
for ( luc[c][k] = j-r; luc[c][k] < MIN(j+r+1,n); ++luc[c][k] )
for ( luc[c][k] = cv::HT(j-r); luc[c][k] < MIN(j+r+1,n); ++luc[c][k] )
histogram_add( &h_fine[16*(n*(16*c+k)+luc[c][k])], H[c].fine[k] );
if ( luc[c][k] < j+r+1 )
{
histogram_muladd( j+r+1 - n, &h_fine[16*(n*(16*c+k)+(n-1))], &H[c].fine[k][0] );
@@ -708,9 +703,9 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
histogram_add( &h_fine[16*(n*(16*c+k)+MIN(luc[c][k],n-1))], H[c].fine[k] );
}
}
histogram_sub( &h_coarse[16*(n*c+MAX(j-r,0))], H[c].coarse );
/* Find median in segment */
segment = H[c].fine[k];
for ( b = 0; b < 16 ; b++ )
@@ -733,11 +728,6 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
#undef COP
}
#if _MSC_VER >= 1200
#pragma warning( default: 4244 )
#endif
static void
medianBlur_8u_Om( const Mat& _src, Mat& _dst, int m )
{
@@ -910,7 +900,7 @@ struct MinMax16u
b = std::max(b, t);
}
};
struct MinMax16s
{
typedef short value_type;
@@ -974,7 +964,7 @@ struct MinMaxVec16u
}
};
struct MinMaxVec16s
{
typedef short value_type;
@@ -988,9 +978,9 @@ struct MinMaxVec16s
a = _mm_min_epi16(a, b);
b = _mm_max_epi16(b, t);
}
};
};
struct MinMaxVec32f
{
typedef float value_type;
@@ -1033,7 +1023,7 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
Op op;
VecOp vop;
volatile bool useSIMD = checkHardwareSupport(CV_CPU_SSE2);
if( m == 3 )
{
if( size.width == 1 || size.height == 1 )
@@ -1055,7 +1045,7 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
}
return;
}
size.width *= cn;
for( i = 0; i < size.height; i++, dst += dstep )
{
@@ -1155,7 +1145,7 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
p[k*5+2] = rowk[j]; p[k*5+3] = rowk[j3];
p[k*5+4] = rowk[j4];
}
op(p[1], p[2]); op(p[0], p[1]); op(p[1], p[2]); op(p[4], p[5]); op(p[3], p[4]);
op(p[4], p[5]); op(p[0], p[3]); op(p[2], p[5]); op(p[2], p[3]); op(p[1], p[4]);
op(p[1], p[2]); op(p[3], p[4]); op(p[7], p[8]); op(p[6], p[7]); op(p[7], p[8]);
@@ -1195,7 +1185,7 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
p[k*5+2] = vop.load(rowk+j); p[k*5+3] = vop.load(rowk+j+cn);
p[k*5+4] = vop.load(rowk+j+cn*2);
}
vop(p[1], p[2]); vop(p[0], p[1]); vop(p[1], p[2]); vop(p[4], p[5]); vop(p[3], p[4]);
vop(p[4], p[5]); vop(p[0], p[3]); vop(p[2], p[5]); vop(p[2], p[3]); vop(p[1], p[4]);
vop(p[1], p[2]); vop(p[3], p[4]); vop(p[7], p[8]); vop(p[6], p[7]); vop(p[7], p[8]);
@@ -1229,13 +1219,13 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
}
}
void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize )
{
Mat src0 = _src0.getMat();
_dst.create( src0.size(), src0.type() );
Mat dst = _dst.getMat();
if( ksize <= 1 )
{
src0.copyTo(dst);
@@ -1248,13 +1238,13 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize )
if (tegra::medianBlur(src0, dst, ksize))
return;
#endif
bool useSortNet = ksize == 3 || (ksize == 5
#if !CV_SSE2
&& src0.depth() > CV_8U
#endif
);
Mat src;
if( useSortNet )
{
@@ -1315,7 +1305,7 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
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);
@@ -1422,7 +1412,7 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
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);
@@ -1433,9 +1423,9 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
radius = MAX(radius, 1);
d = radius*2 + 1;
// compute the min/max range for the input image (even if multichannel)
minMaxLoc( src.reshape(1), &minValSrc, &maxValSrc );
// temporary copy of the image with borders for easy processing
Mat temp;
copyMakeBorder( src, temp, radius, radius, radius, radius, borderType );
@@ -1454,7 +1444,7 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
float* expLUT = &_expLUT[0];
scale_index = kExpNumBins/len;
// initialize the exp LUT
for( i = 0; i < kExpNumBins+2; i++ )
{
@@ -1467,7 +1457,7 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
else
expLUT[i] = 0.f;
}
// initialize space-related bilateral filter coefficients
for( i = -radius, maxk = 0; i <= radius; i++ )
for( j = -radius; j <= radius; j++ )
@@ -1481,7 +1471,7 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
for( i = 0; i < size.height; i++ )
{
const float* sptr = (const float*)(temp.data + (i+radius)*temp.step) + radius*cn;
const float* sptr = (const float*)(temp.data + (i+radius)*temp.step) + radius*cn;
float* dptr = (float*)(dst.data + i*dst.step);
if( cn == 1 )
@@ -1493,11 +1483,11 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
for( k = 0; k < maxk; k++ )
{
float val = sptr[j + space_ofs[k]];
float alpha = (float)(std::abs(val - val0)*scale_index);
float alpha = (float)(std::abs(val - val0)*scale_index);
int idx = cvFloor(alpha);
alpha -= idx;
float w = space_weight[k]*(expLUT[idx] + alpha*(expLUT[idx+1] - expLUT[idx]));
sum += val*w;
sum += val*w;
wsum += w;
}
dptr[j] = (float)(sum/wsum);
@@ -1514,7 +1504,7 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
{
const float* sptr_k = sptr + j + space_ofs[k];
float b = sptr_k[0], g = sptr_k[1], r = sptr_k[2];
float alpha = (float)((std::abs(b - b0) +
float alpha = (float)((std::abs(b - b0) +
std::abs(g - g0) + std::abs(r - r0))*scale_index);
int idx = cvFloor(alpha);
alpha -= idx;
@@ -1541,7 +1531,7 @@ void cv::bilateralFilter( InputArray _src, OutputArray _dst, int d,
Mat src = _src.getMat();
_dst.create( src.size(), src.type() );
Mat dst = _dst.getMat();
if( src.depth() == CV_8U )
bilateralFilter_8u( src, dst, d, sigmaColor, sigmaSpace, borderType );
else if( src.depth() == CV_32F )

View File

@@ -134,7 +134,7 @@ void integral_( const T* src, size_t _srcstep, ST* sum, size_t _sumstep,
if( size.width == cn )
buf[cn] = 0;
if( sqsum )
{
sqsum[-cn] = 0;
@@ -148,7 +148,7 @@ void integral_( const T* src, size_t _srcstep, ST* sum, size_t _sumstep,
sum += sumstep - cn;
tilted += tiltedstep - cn;
buf += -cn;
if( sqsum )
sqsum += sqsumstep - cn;
@@ -197,7 +197,7 @@ void integral_( const T* src, size_t _srcstep, ST* sum, size_t _sumstep,
tilted[x] = t0 + t1 + tilted[x - tiltedstep - cn];
buf[x] = t0;
}
if( sqsum )
sqsum++;
}
@@ -205,10 +205,10 @@ void integral_( const T* src, size_t _srcstep, ST* sum, size_t _sumstep,
}
}
#define DEF_INTEGRAL_FUNC(suffix, T, ST, QT) \
void integral_##suffix( T* src, size_t srcstep, ST* sum, size_t sumstep, QT* sqsum, size_t sqsumstep, \
ST* tilted, size_t tiltedstep, Size size, int cn ) \
static void integral_##suffix( T* src, size_t srcstep, ST* sum, size_t sumstep, QT* sqsum, size_t sqsumstep, \
ST* tilted, size_t tiltedstep, Size size, int cn ) \
{ integral_(src, srcstep, sum, sumstep, sqsum, sqsumstep, tilted, tiltedstep, size, cn); }
DEF_INTEGRAL_FUNC(8u32s, uchar, int, double)
@@ -217,7 +217,7 @@ DEF_INTEGRAL_FUNC(8u64f, uchar, double, double)
DEF_INTEGRAL_FUNC(32f, float, float, double)
DEF_INTEGRAL_FUNC(32f64f, float, double, double)
DEF_INTEGRAL_FUNC(64f, double, double, double)
typedef void (*IntegralFunc)(const uchar* src, size_t srcstep, uchar* sum, size_t sumstep,
uchar* sqsum, size_t sqsumstep, uchar* tilted, size_t tstep,
Size size, int cn );
@@ -236,19 +236,19 @@ void cv::integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, Output
sdepth = CV_MAT_DEPTH(sdepth);
_sum.create( isize, CV_MAKETYPE(sdepth, cn) );
sum = _sum.getMat();
if( _tilted.needed() )
{
_tilted.create( isize, CV_MAKETYPE(sdepth, cn) );
tilted = _tilted.getMat();
}
if( _sqsum.needed() )
{
_sqsum.create( isize, CV_MAKETYPE(CV_64F, cn) );
sqsum = _sqsum.getMat();
}
IntegralFunc func = 0;
if( depth == CV_8U && sdepth == CV_32S )
@@ -269,7 +269,7 @@ void cv::integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, Output
func( src.data, src.step, sum.data, sum.step, sqsum.data, sqsum.step,
tilted.data, tilted.step, src.size(), cn );
}
void cv::integral( InputArray src, OutputArray sum, int sdepth )
{
integral( src, sum, noArray(), noArray(), sdepth );

View File

@@ -48,7 +48,7 @@ cv::Mat cv::getDefaultNewCameraMatrix( InputArray _cameraMatrix, Size imgsize,
Mat cameraMatrix = _cameraMatrix.getMat();
if( !centerPrincipalPoint && cameraMatrix.type() == CV_64F )
return cameraMatrix;
Mat newCameraMatrix;
cameraMatrix.convertTo(newCameraMatrix, CV_64F);
if( centerPrincipalPoint )
@@ -65,7 +65,7 @@ void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoef
{
Mat cameraMatrix = _cameraMatrix.getMat(), distCoeffs = _distCoeffs.getMat();
Mat matR = _matR.getMat(), newCameraMatrix = _newCameraMatrix.getMat();
if( m1type <= 0 )
m1type = CV_16SC2;
CV_Assert( m1type == CV_16SC2 || m1type == CV_32FC1 || m1type == CV_32FC2 );
@@ -106,7 +106,7 @@ void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoef
double u0 = A(0, 2), v0 = A(1, 2);
double fx = A(0, 0), fy = A(1, 1);
CV_Assert( distCoeffs.size() == Size(1, 4) || distCoeffs.size() == Size(4, 1) ||
CV_Assert( distCoeffs.size() == Size(1, 4) || distCoeffs.size() == Size(4, 1) ||
distCoeffs.size() == Size(1, 5) || distCoeffs.size() == Size(5, 1) ||
distCoeffs.size() == Size(1, 8) || distCoeffs.size() == Size(8, 1));
@@ -166,10 +166,10 @@ void cv::undistort( InputArray _src, OutputArray _dst, InputArray _cameraMatrix,
{
Mat src = _src.getMat(), cameraMatrix = _cameraMatrix.getMat();
Mat distCoeffs = _distCoeffs.getMat(), newCameraMatrix = _newCameraMatrix.getMat();
_dst.create( src.size(), src.type() );
Mat dst = _dst.getMat();
CV_Assert( dst.data != src.data );
int stripe_size0 = std::min(std::max(1, (1 << 12) / std::max(src.cols, 1)), src.rows);
@@ -289,11 +289,11 @@ void cvUndistortPoints( const CvMat* _src, CvMat* _dst, const CvMat* _cameraMatr
(_distCoeffs->rows == 1 || _distCoeffs->cols == 1) &&
(_distCoeffs->rows*_distCoeffs->cols == 4 ||
_distCoeffs->rows*_distCoeffs->cols == 5 ||
_distCoeffs->rows*_distCoeffs->cols == 8));
_distCoeffs->rows*_distCoeffs->cols == 8));
_Dk = cvMat( _distCoeffs->rows, _distCoeffs->cols,
CV_MAKETYPE(CV_64F,CV_MAT_CN(_distCoeffs->type)), k);
cvConvert( _distCoeffs, &_Dk );
iters = 5;
}
@@ -389,13 +389,13 @@ void cv::undistortPoints( InputArray _src, OutputArray _dst,
{
Mat src = _src.getMat(), cameraMatrix = _cameraMatrix.getMat();
Mat distCoeffs = _distCoeffs.getMat(), R = _Rmat.getMat(), P = _Pmat.getMat();
CV_Assert( src.isContinuous() && (src.depth() == CV_32F || src.depth() == CV_64F) &&
((src.rows == 1 && src.channels() == 2) || src.cols*src.channels() == 2));
_dst.create(src.size(), src.type(), -1, true);
Mat dst = _dst.getMat();
CvMat _csrc = src, _cdst = dst, _ccameraMatrix = cameraMatrix;
CvMat matR, matP, _cdistCoeffs, *pR=0, *pP=0, *pD=0;
if( R.data )
@@ -416,11 +416,11 @@ static Point2f mapPointSpherical(const Point2f& p, float alpha, Vec4d* J, int pr
double beta = 1 + 2*alpha;
double v = x*x + y*y + 1, iv = 1/v;
double u = sqrt(beta*v + alpha*alpha);
double k = (u - alpha)*iv;
double kv = (v*beta/u - (u - alpha)*2)*iv*iv;
double kx = kv*x, ky = kv*y;
if( projType == PROJ_SPHERICAL_ORTHO )
{
if(J)
@@ -433,7 +433,7 @@ static Point2f mapPointSpherical(const Point2f& p, float alpha, Vec4d* J, int pr
double iR = 1/(alpha + 1);
double x1 = std::max(std::min(x*k*iR, 1.), -1.);
double y1 = std::max(std::min(y*k*iR, 1.), -1.);
if(J)
{
double fx1 = iR/sqrt(1 - x1*x1);
@@ -446,35 +446,35 @@ static Point2f mapPointSpherical(const Point2f& p, float alpha, Vec4d* J, int pr
return Point2f();
}
static Point2f invMapPointSpherical(Point2f _p, float alpha, int projType)
{
static int avgiter = 0, avgn = 0;
double eps = 1e-12;
Vec2d p(_p.x, _p.y), q(_p.x, _p.y), err;
Vec4d J;
int i, maxiter = 5;
for( i = 0; i < maxiter; i++ )
{
Point2f p1 = mapPointSpherical(Point2f((float)q[0], (float)q[1]), alpha, &J, projType);
err = Vec2d(p1.x, p1.y) - p;
if( err[0]*err[0] + err[1]*err[1] < eps )
break;
Vec4d JtJ(J[0]*J[0] + J[2]*J[2], J[0]*J[1] + J[2]*J[3],
J[0]*J[1] + J[2]*J[3], J[1]*J[1] + J[3]*J[3]);
double d = JtJ[0]*JtJ[3] - JtJ[1]*JtJ[2];
d = d ? 1./d : 0;
Vec4d iJtJ(JtJ[3]*d, -JtJ[1]*d, -JtJ[2]*d, JtJ[0]*d);
Vec2d JtErr(J[0]*err[0] + J[2]*err[1], J[1]*err[0] + J[3]*err[1]);
q -= Vec2d(iJtJ[0]*JtErr[0] + iJtJ[1]*JtErr[1], iJtJ[2]*JtErr[0] + iJtJ[3]*JtErr[1]);
//Matx22d J(kx*x + k, kx*y, ky*x, ky*y + k);
//q -= Vec2d((J.t()*J).inv()*(J.t()*err));
}
if( i < maxiter )
{
avgiter += i;
@@ -482,12 +482,12 @@ static Point2f invMapPointSpherical(Point2f _p, float alpha, int projType)
if( avgn == 1500 )
printf("avg iters = %g\n", (double)avgiter/avgn);
}
return i < maxiter ? Point2f((float)q[0], (float)q[1]) : Point2f(-FLT_MAX, -FLT_MAX);
}
}
float cv::initWideAngleProjMap( InputArray _cameraMatrix0, InputArray _distCoeffs0,
Size imageSize, int destImageWidth, int m1type,
OutputArray _map1, OutputArray _map2, int projType, double _alpha )
@@ -500,40 +500,40 @@ float cv::initWideAngleProjMap( InputArray _cameraMatrix0, InputArray _distCoeff
Point2f dcenter((destImageWidth-1)*0.5f, 0.f);
float xmin = FLT_MAX, xmax = -FLT_MAX, ymin = FLT_MAX, ymax = -FLT_MAX;
int N = 9;
std::vector<Point2f> u(1), v(1);
Mat _u(u), I = Mat::eye(3,3,CV_64F);
std::vector<Point2f> uvec(1), vvec(1);
Mat I = Mat::eye(3,3,CV_64F);
float alpha = (float)_alpha;
int ndcoeffs = distCoeffs0.cols*distCoeffs0.rows*distCoeffs0.channels();
CV_Assert((distCoeffs0.cols == 1 || distCoeffs0.rows == 1) &&
(ndcoeffs == 4 || ndcoeffs == 5 || ndcoeffs == 8));
CV_Assert(cameraMatrix0.size() == Size(3,3));
distCoeffs0.convertTo(distCoeffs,CV_64F);
cameraMatrix0.convertTo(cameraMatrix,CV_64F);
alpha = std::min(alpha, 0.999f);
for( int i = 0; i < N; i++ )
for( int j = 0; j < N; j++ )
{
Point2f p((float)j*imageSize.width/(N-1), (float)i*imageSize.height/(N-1));
u[0] = p;
undistortPoints(_u, v, cameraMatrix, distCoeffs, I, I);
Point2f q = mapPointSpherical(v[0], alpha, 0, projType);
uvec[0] = p;
undistortPoints(uvec, vvec, cameraMatrix, distCoeffs, I, I);
Point2f q = mapPointSpherical(vvec[0], alpha, 0, projType);
if( xmin > q.x ) xmin = q.x;
if( xmax < q.x ) xmax = q.x;
if( ymin > q.y ) ymin = q.y;
if( ymax < q.y ) ymax = q.y;
}
float scale = (float)std::min(dcenter.x/fabs(xmax), dcenter.x/fabs(xmin));
Size dsize(destImageWidth, cvCeil(std::max(scale*fabs(ymin)*2, scale*fabs(ymax)*2)));
dcenter.y = (dsize.height - 1)*0.5f;
Mat mapxy(dsize, CV_32FC2);
double k1 = k[0], k2 = k[1], k3 = k[2], p1 = k[3], p2 = k[4], k4 = k[5], k5 = k[6], k6 = k[7];
double fx = cameraMatrix.at<double>(0,0), fy = cameraMatrix.at<double>(1,1), cx = scenter.x, cy = scenter.y;
for( int y = 0; y < dsize.height; y++ )
{
Point2f* mxy = mapxy.ptr<Point2f>(y);
@@ -551,11 +551,11 @@ float cv::initWideAngleProjMap( InputArray _cameraMatrix0, InputArray _distCoeff
double kr = 1 + ((k3*r2 + k2)*r2 + k1)*r2/(1 + ((k6*r2 + k5)*r2 + k4)*r2);
double u = fx*(q.x*kr + p1*_2xy + p2*(r2 + 2*x2)) + cx;
double v = fy*(q.y*kr + p1*(r2 + 2*y2) + p2*_2xy) + cy;
mxy[x] = Point2f((float)u, (float)v);
}
}
if(m1type == CV_32FC2)
{
_map1.create(mapxy.size(), mapxy.type());
@@ -565,7 +565,7 @@ float cv::initWideAngleProjMap( InputArray _cameraMatrix0, InputArray _distCoeff
}
else
convertMaps(mapxy, Mat(), _map1, _map2, m1type, false);
return scale;
}

View File

@@ -266,7 +266,7 @@ void CV_FindContourTest::run_func()
// the whole testing is done here, run_func() is not utilized in this test
int CV_FindContourTest::validate_test_results( int /*test_case_idx*/ )
{
int i, code = cvtest::TS::OK;
int code = cvtest::TS::OK;
cvCmpS( img[0], 0, img[0], CV_CMP_GT );
@@ -284,7 +284,7 @@ int CV_FindContourTest::validate_test_results( int /*test_case_idx*/ )
Mat _img[4];
for( int i = 0; i < 4; i++ )
_img[i] = cvarrToMat(img[i]);
code = cvtest::cmpEps2(ts, _img[0], _img[3], 0, true, "Comparing original image with the map of filled contours" );
if( code < 0 )
@@ -303,7 +303,7 @@ int CV_FindContourTest::validate_test_results( int /*test_case_idx*/ )
CvTreeNodeIterator iterator2;
int count3;
for( i = 0; i < 2; i++ )
for(int i = 0; i < 2; i++ )
{
CvTreeNodeIterator iterator;
cvInitTreeNodeIterator( &iterator, i == 0 ? contours : contours2, INT_MAX );
@@ -353,7 +353,7 @@ int CV_FindContourTest::validate_test_results( int /*test_case_idx*/ )
goto _exit_;
}
for( i = 0; i < seq1->total; i++ )
for(int i = 0; i < seq1->total; i++ )
{
CvPoint pt1;
CvPoint pt2;

View File

@@ -193,7 +193,7 @@ protected:
void* result;
double low_high_range;
CvScalar low, high;
bool test_cpp;
};
@@ -254,7 +254,7 @@ int CV_BaseShapeDescrTest::read_params( CvFileStorage* fs )
}
void CV_BaseShapeDescrTest::generate_point_set( void* points )
void CV_BaseShapeDescrTest::generate_point_set( void* pointsSet )
{
RNG& rng = ts->get_rng();
int i, k, n, total, point_type;
@@ -269,16 +269,16 @@ void CV_BaseShapeDescrTest::generate_point_set( void* points )
}
memset( &reader, 0, sizeof(reader) );
if( CV_IS_SEQ(points) )
if( CV_IS_SEQ(pointsSet) )
{
CvSeq* ptseq = (CvSeq*)points;
CvSeq* ptseq = (CvSeq*)pointsSet;
total = ptseq->total;
point_type = CV_SEQ_ELTYPE(ptseq);
cvStartReadSeq( ptseq, &reader );
}
else
{
CvMat* ptm = (CvMat*)points;
CvMat* ptm = (CvMat*)pointsSet;
assert( CV_IS_MAT(ptm) && CV_IS_MAT_CONT(ptm->type) );
total = ptm->rows + ptm->cols - 1;
point_type = CV_MAT_TYPE(ptm->type);
@@ -362,7 +362,7 @@ int CV_BaseShapeDescrTest::prepare_test_case( int test_case_idx )
}
generate_point_set( points );
test_cpp = (cvtest::randInt(rng) & 16) == 0;
return 1;
}
@@ -614,16 +614,16 @@ int CV_ConvHullTest::validate_test_results( int test_case_idx )
for( i = 0; i < point_count; i++ )
{
int idx = 0, on_edge = 0;
double result = cvTsPointPolygonTest( p[i], h, hull_count, &idx, &on_edge );
double pptresult = cvTsPointPolygonTest( p[i], h, hull_count, &idx, &on_edge );
if( result < 0 )
if( pptresult < 0 )
{
ts->printf( cvtest::TS::LOG, "The point #%d is outside of the convex hull\n", i );
code = cvtest::TS::FAIL_BAD_ACCURACY;
goto _exit_;
}
if( result < FLT_EPSILON && !on_edge )
if( pptresult < FLT_EPSILON && !on_edge )
mask->data.ptr[idx] = (uchar)1;
}
@@ -735,15 +735,15 @@ int CV_MinAreaRectTest::validate_test_results( int test_case_idx )
for( i = 0; i < point_count; i++ )
{
int idx = 0, on_edge = 0;
double result = cvTsPointPolygonTest( p[i], box_pt, 4, &idx, &on_edge );
if( result < -eps )
double pptresult = cvTsPointPolygonTest( p[i], box_pt, 4, &idx, &on_edge );
if( pptresult < -eps )
{
ts->printf( cvtest::TS::LOG, "The point #%d is outside of the box\n", i );
code = cvtest::TS::FAIL_BAD_ACCURACY;
goto _exit_;
}
if( result < eps )
if( pptresult < eps )
{
for( j = 0; j < 4; j++ )
{
@@ -997,7 +997,7 @@ CV_FitEllipseTest::CV_FitEllipseTest()
}
void CV_FitEllipseTest::generate_point_set( void* points )
void CV_FitEllipseTest::generate_point_set( void* pointsSet )
{
RNG& rng = ts->get_rng();
int i, total, point_type;
@@ -1020,16 +1020,16 @@ void CV_FitEllipseTest::generate_point_set( void* points )
}
memset( &reader, 0, sizeof(reader) );
if( CV_IS_SEQ(points) )
if( CV_IS_SEQ(pointsSet) )
{
CvSeq* ptseq = (CvSeq*)points;
CvSeq* ptseq = (CvSeq*)pointsSet;
total = ptseq->total;
point_type = CV_SEQ_ELTYPE(ptseq);
cvStartReadSeq( ptseq, &reader );
}
else
{
CvMat* ptm = (CvMat*)points;
CvMat* ptm = (CvMat*)pointsSet;
assert( CV_IS_MAT(ptm) && CV_IS_MAT_CONT(ptm->type) );
total = ptm->rows + ptm->cols - 1;
point_type = CV_MAT_TYPE(ptm->type);
@@ -1171,7 +1171,7 @@ class CV_FitEllipseSmallTest : public cvtest::BaseTest
{
public:
CV_FitEllipseSmallTest() {}
~CV_FitEllipseSmallTest() {}
~CV_FitEllipseSmallTest() {}
protected:
void run(int)
{
@@ -1188,7 +1188,7 @@ protected:
c[0].push_back(Point(8, 6)*scale+ofs);
c[0].push_back(Point(8, 2)*scale+ofs);
c[0].push_back(Point(6, 0)*scale+ofs);
RotatedRect e = fitEllipse(c[0]);
CV_Assert( fabs(e.center.x - 4) <= 1. &&
fabs(e.center.y - 4) <= 1. &&
@@ -1226,7 +1226,7 @@ CV_FitLineTest::CV_FitLineTest()
}
void CV_FitLineTest::generate_point_set( void* points )
void CV_FitLineTest::generate_point_set( void* pointsSet )
{
RNG& rng = ts->get_rng();
int i, k, n, total, point_type;
@@ -1250,16 +1250,16 @@ void CV_FitLineTest::generate_point_set( void* points )
memset( &reader, 0, sizeof(reader) );
if( CV_IS_SEQ(points) )
if( CV_IS_SEQ(pointsSet) )
{
CvSeq* ptseq = (CvSeq*)points;
CvSeq* ptseq = (CvSeq*)pointsSet;
total = ptseq->total;
point_type = CV_MAT_DEPTH(CV_SEQ_ELTYPE(ptseq));
cvStartReadSeq( ptseq, &reader );
}
else
{
CvMat* ptm = (CvMat*)points;
CvMat* ptm = (CvMat*)pointsSet;
assert( CV_IS_MAT(ptm) && CV_IS_MAT_CONT(ptm->type) );
total = ptm->rows + ptm->cols - 1;
point_type = CV_MAT_DEPTH(CV_MAT_TYPE(ptm->type));
@@ -1498,7 +1498,7 @@ CV_ContourMomentsTest::CV_ContourMomentsTest()
}
void CV_ContourMomentsTest::generate_point_set( void* points )
void CV_ContourMomentsTest::generate_point_set( void* pointsSet )
{
RNG& rng = ts->get_rng();
float max_sz;
@@ -1518,7 +1518,7 @@ void CV_ContourMomentsTest::generate_point_set( void* points )
max_r_scale = cvtest::randReal(rng)*max_max_r_scale*0.01;
angle = cvtest::randReal(rng)*360;
cvTsGenerateTousledBlob( center, axes, max_r_scale, angle, points, rng );
cvTsGenerateTousledBlob( center, axes, max_r_scale, angle, pointsSet, rng );
if( points1 )
points1->flags = CV_SEQ_MAGIC_VAL + CV_SEQ_POLYGON;
@@ -1614,8 +1614,8 @@ class CV_PerimeterAreaSliceTest : public cvtest::BaseTest
{
public:
CV_PerimeterAreaSliceTest();
~CV_PerimeterAreaSliceTest();
protected:
~CV_PerimeterAreaSliceTest();
protected:
void run(int);
};
@@ -1629,7 +1629,7 @@ void CV_PerimeterAreaSliceTest::run( int )
Ptr<CvMemStorage> storage = cvCreateMemStorage();
RNG& rng = theRNG();
const double min_r = 90, max_r = 120;
for( int i = 0; i < 100; i++ )
{
ts->update_context( this, i, true );
@@ -1640,7 +1640,7 @@ void CV_PerimeterAreaSliceTest::run( int )
CvPoint center;
center.x = rng.uniform(cvCeil(max_r), cvFloor(640-max_r));
center.y = rng.uniform(cvCeil(max_r), cvFloor(480-max_r));
for( int j = 0; j < n; j++ )
{
CvPoint pt;
@@ -1650,7 +1650,7 @@ void CV_PerimeterAreaSliceTest::run( int )
pt.y = cvRound(center.y - r*sin(phi));
cvSeqPush(contour, &pt);
}
CvSlice slice;
for(;;)
{
@@ -1664,14 +1664,14 @@ void CV_PerimeterAreaSliceTest::run( int )
/*printf( "%d. (%d, %d) of %d, length = %d, length1 = %d\n",
i, slice.start_index, slice.end_index,
contour->total, cvSliceLength(slice, contour), cslice->total );
double area0 = cvContourArea(cslice);
double area1 = cvContourArea(contour, slice);
double area1 = cvContourArea(contour, slice);
if( area0 != area1 )
{
ts->printf(cvtest::TS::LOG,
"The contour area slice is computed differently (%g vs %g)\n", area0, area1 );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return;
}*/
@@ -1681,7 +1681,7 @@ void CV_PerimeterAreaSliceTest::run( int )
{
ts->printf(cvtest::TS::LOG,
"The contour arc length is computed differently (%g vs %g)\n", len0, len1 );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return;
}
}

View File

@@ -253,46 +253,46 @@ void CV_MorphologyBaseTest::prepare_to_validation( int /*test_case_idx*/ )
Mat _ielement(element->nRows, element->nCols, CV_32S, element->values);
Mat _element;
_ielement.convertTo(_element, CV_8U);
Point anchor(element->anchorX, element->anchorY);
int border = BORDER_REPLICATE;
Point _anchor(element->anchorX, element->anchorY);
int _border = BORDER_REPLICATE;
if( optype == CV_MOP_ERODE )
{
cvtest::erode( src, dst, _element, anchor, border );
cvtest::erode( src, dst, _element, _anchor, _border );
}
else if( optype == CV_MOP_DILATE )
{
cvtest::dilate( src, dst, _element, anchor, border );
cvtest::dilate( src, dst, _element, _anchor, _border );
}
else
{
Mat temp;
if( optype == CV_MOP_OPEN )
{
cvtest::erode( src, temp, _element, anchor, border );
cvtest::dilate( temp, dst, _element, anchor, border );
cvtest::erode( src, temp, _element, _anchor, _border );
cvtest::dilate( temp, dst, _element, _anchor, _border );
}
else if( optype == CV_MOP_CLOSE )
{
cvtest::dilate( src, temp, _element, anchor, border );
cvtest::erode( temp, dst, _element, anchor, border );
cvtest::dilate( src, temp, _element, _anchor, _border );
cvtest::erode( temp, dst, _element, _anchor, _border );
}
else if( optype == CV_MOP_GRADIENT )
{
cvtest::erode( src, temp, _element, anchor, border );
cvtest::dilate( src, dst, _element, anchor, border );
cvtest::erode( src, temp, _element, _anchor, _border );
cvtest::dilate( src, dst, _element, _anchor, _border );
cvtest::add( dst, 1, temp, -1, Scalar::all(0), dst, dst.type() );
}
else if( optype == CV_MOP_TOPHAT )
{
cvtest::erode( src, temp, _element, anchor, border );
cvtest::dilate( temp, dst, _element, anchor, border );
cvtest::erode( src, temp, _element, _anchor, _border );
cvtest::dilate( temp, dst, _element, _anchor, _border );
cvtest::add( src, 1, dst, -1, Scalar::all(0), dst, dst.type() );
}
else if( optype == CV_MOP_BLACKHAT )
{
cvtest::dilate( src, temp, _element, anchor, border );
cvtest::erode( temp, dst, _element, anchor, border );
cvtest::dilate( src, temp, _element, _anchor, _border );
cvtest::erode( temp, dst, _element, _anchor, _border );
cvtest::add( dst, 1, src, -1, Scalar::all(0), dst, dst.type() );
}
else

View File

@@ -56,7 +56,7 @@ protected:
void prepare_to_validation( int );
void fill_array( int test_case_idx, int i, int j, Mat& arr );
/*int write_default_params(CvFileStorage* fs);
void get_timing_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types
CvSize** whole_sizes, bool *are_images );
@@ -94,7 +94,7 @@ void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx,
RNG& rng = ts->get_rng();
int depth, cn;
int i;
double buf[8];
double buff[8];
cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
depth = cvtest::randInt(rng) % 3;
@@ -111,7 +111,7 @@ void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx,
types[INPUT_OUTPUT][1] = types[REF_INPUT_OUTPUT][1] = CV_8UC1;
types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_64FC1;
sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = cvSize(9,1);
if( !use_mask )
sizes[INPUT_OUTPUT][1] = sizes[REF_INPUT_OUTPUT][1] = cvSize(0,0);
else
@@ -119,7 +119,7 @@ void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx,
CvSize sz = sizes[INPUT_OUTPUT][0];
sizes[INPUT_OUTPUT][1] = sizes[REF_INPUT_OUTPUT][1] = cvSize(sz.width+2,sz.height+2);
}
seed_pt.x = cvtest::randInt(rng) % sizes[INPUT_OUTPUT][0].width;
seed_pt.y = cvtest::randInt(rng) % sizes[INPUT_OUTPUT][0].height;
@@ -127,7 +127,7 @@ void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx,
l_diff = u_diff = Scalar::all(0.);
else
{
Mat m( 1, 8, CV_16S, buf );
Mat m( 1, 8, CV_16S, buff );
rng.fill( m, RNG::NORMAL, Scalar::all(0), Scalar::all(32) );
for( i = 0; i < 4; i++ )
{
@@ -139,7 +139,7 @@ void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx,
new_val = Scalar::all(0.);
for( i = 0; i < cn; i++ )
new_val.val[i] = cvtest::randReal(rng)*255;
test_cpp = (cvtest::randInt(rng) & 256) == 0;
}
@@ -153,13 +153,13 @@ double CV_FloodFillTest::get_success_error_level( int /*test_case_idx*/, int i,
void CV_FloodFillTest::fill_array( int test_case_idx, int i, int j, Mat& arr )
{
RNG& rng = ts->get_rng();
if( i != INPUT && i != INPUT_OUTPUT )
{
cvtest::ArrayTest::fill_array( test_case_idx, i, j, arr );
return;
}
if( j == 0 )
{
Mat tmp = arr;
@@ -191,7 +191,7 @@ void CV_FloodFillTest::run_func()
int flags = connectivity + (mask_only ? CV_FLOODFILL_MASK_ONLY : 0) +
(range_type == 1 ? CV_FLOODFILL_FIXED_RANGE : 0) + (new_mask_val << 8);
double* odata = test_mat[OUTPUT][0].ptr<double>();
if(!test_cpp)
{
CvConnectedComp comp;
@@ -255,7 +255,7 @@ cvTsFloodFill( CvMat* _img, CvPoint seed_pt, CvScalar new_val,
int cols = _img->cols, rows = _img->rows;
int u0 = 0, u1 = 0, u2 = 0;
double s0 = 0, s1 = 0, s2 = 0;
if( CV_MAT_DEPTH(_img->type) == CV_8U || CV_MAT_DEPTH(_img->type) == CV_32S )
{
tmp = cvCreateMat( rows, cols, CV_MAKETYPE(CV_32F,CV_MAT_CN(_img->type)) );
@@ -395,7 +395,7 @@ cvTsFloodFill( CvMat* _img, CvPoint seed_pt, CvScalar new_val,
cvSeqPush( seq, &p );
}
}
}
}
}
r.x = r.width = seed_pt.x;

View File

@@ -59,7 +59,7 @@ protected:
int prepare_test_case( int test_case_idx );
int validate_test_results( int test_case_idx );
virtual void init_hist( int test_case_idx, int i );
virtual void get_hist_params( int test_case_idx );
virtual float** get_hist_ranges( int test_case_idx );
@@ -73,7 +73,7 @@ protected:
int uniform;
int gen_random_hist;
double gen_hist_max_val, gen_hist_sparse_nz_ratio;
int init_ranges;
int img_type;
int img_max_log_size;
@@ -127,7 +127,7 @@ int CV_BaseHistTest::read_params( CvFileStorage* fs )
max_log_size = cvtest::clipInt( max_log_size, 1, 20 );
img_max_log_size = cvReadInt( find_param( fs, "max_log_array_size" ), img_max_log_size );
img_max_log_size = cvtest::clipInt( img_max_log_size, 1, 9 );
max_cdims = cvReadInt( find_param( fs, "max_cdims" ), max_cdims );
max_cdims = cvtest::clipInt( max_cdims, 1, 6 );
@@ -146,13 +146,13 @@ void CV_BaseHistTest::get_hist_params( int /*test_case_idx*/ )
max_dim_size = cvRound(pow(hist_size,1./cdims));
total_size = 1;
uniform = cvtest::randInt(rng) % 2;
hist_type = cvtest::randInt(rng) % 2 ? CV_HIST_SPARSE : CV_HIST_ARRAY;
hist_type = cvtest::randInt(rng) % 2 ? CV_HIST_SPARSE : CV_HIST_ARRAY;
for( i = 0; i < cdims; i++ )
{
dims[i] = cvtest::randInt(rng) % (max_dim_size + 2) + 2;
if( !uniform )
dims[i] = MIN(dims[i], max_ni_dim_size);
dims[i] = MIN(dims[i], max_ni_dim_size);
total_size *= dims[i];
}
@@ -178,12 +178,12 @@ void CV_BaseHistTest::get_hist_params( int /*test_case_idx*/ )
float** CV_BaseHistTest::get_hist_ranges( int /*test_case_idx*/ )
{
double _low = low + range_delta, _high = high - range_delta;
if( !init_ranges )
return 0;
ranges.resize(cdims);
if( uniform )
{
_ranges.resize(cdims*2);
@@ -200,7 +200,7 @@ float** CV_BaseHistTest::get_hist_ranges( int /*test_case_idx*/ )
for( i = 0; i < cdims; i++ )
dims_sum += dims[i] + 1;
_ranges.resize(dims_sum);
for( i = 0; i < cdims; i++ )
{
int j, n = dims[i];
@@ -212,7 +212,7 @@ float** CV_BaseHistTest::get_hist_ranges( int /*test_case_idx*/ )
if( (pow(q,(double)n)-1)/(q-1.) >= _high-_low )
break;
}
if( j == 0 )
{
delta = (_high-_low)/n;
@@ -223,9 +223,9 @@ float** CV_BaseHistTest::get_hist_ranges( int /*test_case_idx*/ )
q = 1 + j*0.1;
delta = cvFloor((_high-_low)*(q-1)/(pow(q,(double)n) - 1));
delta = MAX(delta, 1.);
}
}
val = _low;
for( j = 0; j <= n; j++ )
{
_ranges[j+ofs] = (float)MIN(val,_high);
@@ -236,7 +236,7 @@ float** CV_BaseHistTest::get_hist_ranges( int /*test_case_idx*/ )
ofs += n + 1;
}
}
return &ranges[0];
}
@@ -246,7 +246,7 @@ void CV_BaseHistTest::init_hist( int /*test_case_idx*/, int hist_i )
if( gen_random_hist )
{
RNG& rng = ts->get_rng();
if( hist_type == CV_HIST_ARRAY )
{
Mat h = cvarrToMat(hist[hist_i]->bins);
@@ -255,13 +255,13 @@ void CV_BaseHistTest::init_hist( int /*test_case_idx*/, int hist_i )
else
{
CvArr* arr = hist[hist_i]->bins;
int i, j, total_size = 1, nz_count;
int i, j, totalSize = 1, nz_count;
int idx[CV_MAX_DIM];
for( i = 0; i < cdims; i++ )
total_size *= dims[i];
totalSize *= dims[i];
nz_count = cvtest::randInt(rng) % MAX( total_size/4, 100 );
nz_count = MIN( nz_count, total_size );
nz_count = cvtest::randInt(rng) % MAX( totalSize/4, 100 );
nz_count = MIN( nz_count, totalSize );
// a zero number of non-zero elements should be allowed
for( i = 0; i < nz_count; i++ )
@@ -286,7 +286,7 @@ int CV_BaseHistTest::prepare_test_case( int test_case_idx )
get_hist_params( test_case_idx );
r = get_hist_ranges( test_case_idx );
hist.resize(hist_count);
for( i = 0; i < hist_count; i++ )
{
hist[i] = cvCreateHist( cdims, dims, hist_type, r, uniform );
@@ -323,7 +323,7 @@ protected:
int prepare_test_case( int test_case_idx );
int validate_test_results( int test_case_idx );
void init_hist( int test_case_idx, int i );
CvMat* indices;
CvMat* values;
CvMat* values0;
@@ -376,7 +376,7 @@ int CV_QueryHistTest::prepare_test_case( int test_case_idx )
iters = (cvtest::randInt(rng) % MAX(total_size/10,100)) + 1;
iters = MIN( iters, total_size*9/10 + 1 );
indices = cvCreateMat( 1, iters*cdims, CV_32S );
values = cvCreateMat( 1, iters, CV_32F );
values0 = cvCreateMat( 1, iters, CV_32F );
@@ -422,7 +422,7 @@ int CV_QueryHistTest::prepare_test_case( int test_case_idx )
if( GET_BIT(lin_idx) )
values0->data.fl[i] = (float)(lin_idx+1);
}
cvReleaseMat( &bit_mask );
}
@@ -539,7 +539,7 @@ int CV_QueryHistTest::validate_test_results( int /*test_case_idx*/ )
{
int code = cvtest::TS::OK;
int i, j, iters = values->cols;
for( i = 0; i < iters; i++ )
{
float v = values->data.fl[i], v0 = values0->data.fl[i];
@@ -613,7 +613,7 @@ void CV_MinMaxHistTest::init_hist(int test_case_idx, int hist_i)
}
if( !eq || total_size == 1 )
break;
}
}
min_val0 = (float)(-cvtest::randReal(rng)*10 - FLT_EPSILON);
max_val0 = (float)(cvtest::randReal(rng)*10 + FLT_EPSILON + gen_hist_max_val);
@@ -644,7 +644,7 @@ void CV_MinMaxHistTest::run_func(void)
int CV_MinMaxHistTest::validate_test_results( int /*test_case_idx*/ )
{
int code = cvtest::TS::OK;
if( cvIsNaN(min_val) || cvIsInf(min_val) ||
cvIsNaN(max_val) || cvIsInf(max_val) )
{
@@ -728,7 +728,7 @@ void CV_NormHistTest::run_func(void)
if( hist_type != CV_HIST_ARRAY && test_cpp )
{
cv::SparseMat h((CvSparseMat*)hist[0]->bins);
cv::normalize(h, h, factor, CV_L1);
cv::normalize(h, h, factor, CV_L1);
cvReleaseSparseMat((CvSparseMat**)&hist[0]->bins);
hist[0]->bins = (CvSparseMat*)h;
}
@@ -741,7 +741,7 @@ int CV_NormHistTest::validate_test_results( int /*test_case_idx*/ )
{
int code = cvtest::TS::OK;
double sum = 0;
if( hist_type == CV_HIST_ARRAY )
{
int i;
@@ -755,7 +755,7 @@ int CV_NormHistTest::validate_test_results( int /*test_case_idx*/ )
CvSparseMat* sparse = (CvSparseMat*)hist[0]->bins;
CvSparseMatIterator iterator;
CvSparseNode *node;
for( node = cvInitSparseMatIterator( sparse, &iterator );
node != 0; node = cvGetNextSparseNode( &iterator ))
{
@@ -839,7 +839,7 @@ int CV_ThreshHistTest::prepare_test_case( int test_case_idx )
if( hist_type == CV_HIST_ARRAY )
{
orig_nz_count = total_size;
values = cvCreateMat( 1, total_size, CV_32F );
memcpy( values->data.fl, cvPtr1D( hist[0]->bins, 0 ), total_size*sizeof(float) );
}
@@ -859,7 +859,7 @@ int CV_ThreshHistTest::prepare_test_case( int test_case_idx )
node != 0; node = cvGetNextSparseNode( &iterator ), i++ )
{
const int* idx = CV_NODE_IDX(sparse,node);
OPENCV_ASSERT( i < orig_nz_count, "CV_ThreshHistTest::prepare_test_case", "Buffer overflow" );
values->data.fl[i] = *(float*)CV_NODE_VAL(sparse,node);
@@ -924,7 +924,7 @@ int CV_ThreshHistTest::validate_test_results( int /*test_case_idx*/ )
}
}
}
if( code > 0 && hist_type == CV_HIST_SPARSE )
{
if( sparse->heap->active_count > 0 )
@@ -1003,7 +1003,7 @@ int CV_CompareHistTest::validate_test_results( int /*test_case_idx*/ )
{
float* ptr0 = (float*)cvPtr1D( hist[0]->bins, 0 );
float* ptr1 = (float*)cvPtr1D( hist[1]->bins, 0 );
for( i = 0; i < total_size; i++ )
{
double v0 = ptr0[i], v1 = ptr1[i];
@@ -1031,7 +1031,7 @@ int CV_CompareHistTest::validate_test_results( int /*test_case_idx*/ )
const int* idx = CV_NODE_IDX(sparse0, node);
double v0 = *(float*)CV_NODE_VAL(sparse0, node);
double v1 = (float)cvGetRealND(sparse1, idx);
result0[CV_COMP_CORREL] += v0*v1;
result0[CV_COMP_INTERSECT] += MIN(v0,v1);
if( fabs(v0) > DBL_EPSILON )
@@ -1134,7 +1134,7 @@ CV_CalcHistTest::~CV_CalcHistTest()
void CV_CalcHistTest::clear()
{
int i;
for( i = 0; i <= CV_MAX_DIM; i++ )
cvReleaseImage( &images[i] );
@@ -1160,7 +1160,7 @@ int CV_CalcHistTest::prepare_test_case( int test_case_idx )
img_type == CV_8U ? IPL_DEPTH_8U : IPL_DEPTH_32F, nch );
channels[i] = cvtest::randInt(rng) % nch;
Mat images_i = cvarrToMat(images[i]);
cvtest::randUni( rng, images_i, Scalar::all(low), Scalar::all(high) );
}
else if( i == CV_MAX_DIM && cvtest::randInt(rng) % 2 )
@@ -1168,7 +1168,7 @@ int CV_CalcHistTest::prepare_test_case( int test_case_idx )
// create mask
images[i] = cvCreateImage( img_size, IPL_DEPTH_8U, 1 );
Mat images_i = cvarrToMat(images[i]);
// make ~25% pixels in the mask non-zero
cvtest::randUni( rng, images_i, Scalar::all(-2), Scalar::all(2) );
}
@@ -1230,7 +1230,7 @@ cvTsCalcHist( IplImage** _images, CvHistogram* hist, IplImage* _mask, int* chann
{
float val[CV_MAX_DIM];
int idx[CV_MAX_DIM];
if( mptr && !mptr[x] )
continue;
if( img_depth == IPL_DEPTH_8U )
@@ -1288,7 +1288,7 @@ int CV_CalcHistTest::validate_test_results( int /*test_case_idx*/ )
{
ts->printf( cvtest::TS::LOG, "The histogram does not match to the reference one\n" );
code = cvtest::TS::FAIL_BAD_ACCURACY;
}
if( code < 0 )
@@ -1345,7 +1345,7 @@ CV_CalcBackProjectTest::~CV_CalcBackProjectTest()
void CV_CalcBackProjectTest::clear()
{
int i;
for( i = 0; i < CV_MAX_DIM+3; i++ )
cvReleaseImage( &images[i] );
@@ -1399,7 +1399,7 @@ int CV_CalcBackProjectTest::prepare_test_case( int test_case_idx )
{
int idx = cvtest::randInt(rng) % img_len;
double val = cvtest::randReal(rng)*(high - low) + low;
if( img_type == CV_8U )
((uchar*)data)[idx] = (uchar)cvRound(val);
else
@@ -1453,7 +1453,7 @@ cvTsCalcBackProject( IplImage** images, IplImage* dst, CvHistogram* hist, int* c
float val[CV_MAX_DIM];
float bin_val = 0;
int idx[CV_MAX_DIM];
if( img_depth == IPL_DEPTH_8U )
for( k = 0; k < cdims; k++ )
val[k] = plane[k].ptr[x*nch[k]];
@@ -1569,7 +1569,7 @@ CV_CalcBackProjectPatchTest::~CV_CalcBackProjectPatchTest()
void CV_CalcBackProjectPatchTest::clear()
{
int i;
for( i = 0; i < CV_MAX_DIM+2; i++ )
cvReleaseImage( &images[i] );
@@ -1627,7 +1627,7 @@ int CV_CalcBackProjectPatchTest::prepare_test_case( int test_case_idx )
{
int idx = cvtest::randInt(rng) % img_len;
double val = cvtest::randReal(rng)*(high - low) + low;
if( img_type == CV_8U )
((uchar*)data)[idx] = (uchar)cvRound(val);
else
@@ -1652,7 +1652,7 @@ cvTsCalcBackProjectPatch( IplImage** images, IplImage* dst, CvSize patch_size,
double factor, int* channels )
{
CvHistogram* model = 0;
IplImage imgstub[CV_MAX_DIM], *img[CV_MAX_DIM];
IplROI roi;
int i, dims;
@@ -1679,7 +1679,7 @@ cvTsCalcBackProjectPatch( IplImage** images, IplImage* dst, CvSize patch_size,
for( x = 0; x < size.width; x++ )
{
double result;
roi.xOffset = x;
roi.yOffset = y;
roi.width = patch_size.width;
@@ -1703,7 +1703,7 @@ int CV_CalcBackProjectPatchTest::validate_test_results( int /*test_case_idx*/ )
cvTsCalcBackProjectPatch( images, images[CV_MAX_DIM+1],
patch_size, hist[0], method, factor, channels );
Mat a = cvarrToMat(images[CV_MAX_DIM]), b = cvarrToMat(images[CV_MAX_DIM+1]);
code = cvtest::cmpEps2( ts, a, b, err_level, true, "BackProjectPatch result" );
@@ -1756,7 +1756,7 @@ void CV_BayesianProbTest::init_hist( int test_case_idx, int hist_i )
int CV_BayesianProbTest::prepare_test_case( int test_case_idx )
{
RNG& rng = ts->get_rng();
hist_count = (cvtest::randInt(rng) % (MAX_HIST/2-1) + 2)*2;
hist_count = MIN( hist_count, MAX_HIST );
int code = CV_BaseHistTest::prepare_test_case( test_case_idx );
@@ -1833,5 +1833,5 @@ TEST(Imgproc_Hist_MinMaxVal, accuracy) { CV_MinMaxHistTest test; test.safe_run()
TEST(Imgproc_Hist_CalcBackProject, accuracy) { CV_CalcBackProjectTest test; test.safe_run(); }
TEST(Imgproc_Hist_CalcBackProjectPatch, accuracy) { CV_CalcBackProjectPatchTest test; test.safe_run(); }
TEST(Imgproc_Hist_BayesianProb, accuracy) { CV_BayesianProbTest test; test.safe_run(); }
/* End Of File */

View File

@@ -135,7 +135,7 @@ int CV_ImgWarpBaseTest::prepare_test_case( int test_case_idx )
if( test_mat[INPUT_OUTPUT][0].cols >= img.cols &&
test_mat[INPUT_OUTPUT][0].rows >= img.rows )
space_scale = spatial_scale_zoom;
for( i = 0; i < img.rows; i++ )
{
uchar* ptr = img.ptr(i);
@@ -192,7 +192,7 @@ int CV_ImgWarpBaseTest::prepare_test_case( int test_case_idx )
}*/
cv::Mat src(1, cols*cn, CV_32F, &buffer[0]);
cv::Mat dst(1, cols*cn, depth, ptr);
src.convertTo(dst, dst.type());
src.convertTo(dst, dst.type());
}
return code;
@@ -279,7 +279,7 @@ void CV_ResizeTest::prepare_to_validation( int /*test_case_idx*/ )
CvMat* x_idx = cvCreateMat( 1, dst->cols, CV_32SC1 );
CvMat* y_idx = cvCreateMat( 1, dst->rows, CV_32SC1 );
int* x_tab = x_idx->data.i;
int elem_size = CV_ELEM_SIZE(src->type);
int elem_size = CV_ELEM_SIZE(src->type);
int drows = dst->rows, dcols = dst->cols;
if( interpolation == CV_INTER_NN )
@@ -302,7 +302,7 @@ void CV_ResizeTest::prepare_to_validation( int /*test_case_idx*/ )
{
double scale_x = (double)src->cols/dcols;
double scale_y = (double)src->rows/drows;
for( j = 0; j < dcols; j++ )
{
double f = ((j+0.5)*scale_x - 0.5);
@@ -322,7 +322,7 @@ void CV_ResizeTest::prepare_to_validation( int /*test_case_idx*/ )
{
uchar* dptr = dst->data.ptr + dst->step*i;
const uchar* sptr0 = src->data.ptr + src->step*y_idx->data.i[i];
for( j = 0; j < dcols; j++, dptr += elem_size )
{
const uchar* sptr = sptr0 + x_tab[j];
@@ -394,7 +394,7 @@ static void test_remap( const Mat& src, Mat& dst, const Mat& mapx, const Mat& ma
xs -= ixs;
ys -= iys;
switch( depth )
{
case CV_8U:
@@ -508,7 +508,7 @@ int CV_WarpAffineTest::prepare_test_case( int test_case_idx )
RNG& rng = ts->get_rng();
int code = CV_ImgWarpBaseTest::prepare_test_case( test_case_idx );
const Mat& src = test_mat[INPUT][0];
const Mat& dst = test_mat[INPUT_OUTPUT][0];
const Mat& dst = test_mat[INPUT_OUTPUT][0];
Mat& mat = test_mat[INPUT][1];
CvPoint2D32f center;
double scale, angle;
@@ -516,8 +516,8 @@ int CV_WarpAffineTest::prepare_test_case( int test_case_idx )
if( code <= 0 )
return code;
double buf[6];
Mat tmp( 2, 3, mat.type(), buf );
double buffer[6];
Mat tmp( 2, 3, mat.type(), buffer );
center.x = (float)((cvtest::randReal(rng)*1.2 - 0.1)*src.cols);
center.y = (float)((cvtest::randReal(rng)*1.2 - 0.1)*src.rows);
@@ -619,7 +619,7 @@ int CV_WarpPerspectiveTest::prepare_test_case( int test_case_idx )
RNG& rng = ts->get_rng();
int code = CV_ImgWarpBaseTest::prepare_test_case( test_case_idx );
const CvMat& src = test_mat[INPUT][0];
const CvMat& dst = test_mat[INPUT_OUTPUT][0];
const CvMat& dst = test_mat[INPUT_OUTPUT][0];
Mat& mat = test_mat[INPUT][1];
Point2f s[4], d[4];
int i;
@@ -636,17 +636,17 @@ int CV_WarpPerspectiveTest::prepare_test_case( int test_case_idx )
s[3] = Point2f(0,src.rows-1.f);
d[3] = Point2f(0,dst.rows-1.f);
float buf[16];
Mat tmp( 1, 16, CV_32FC1, buf );
float bufer[16];
Mat tmp( 1, 16, CV_32FC1, bufer );
rng.fill( tmp, CV_RAND_NORMAL, Scalar::all(0.), Scalar::all(0.1) );
for( i = 0; i < 4; i++ )
{
s[i].x += buf[i*4]*src.cols/2;
s[i].y += buf[i*4+1]*src.rows/2;
d[i].x += buf[i*4+2]*dst.cols/2;
d[i].y += buf[i*4+3]*dst.rows/2;
s[i].x += bufer[i*4]*src.cols/2;
s[i].y += bufer[i*4+1]*src.rows/2;
d[i].x += bufer[i*4+2]*dst.cols/2;
d[i].y += bufer[i*4+3]*dst.rows/2;
}
cv::getPerspectiveTransform( s, d ).convertTo( mat, mat.depth() );
@@ -675,11 +675,11 @@ void CV_WarpPerspectiveTest::prepare_to_validation( int /*test_case_idx*/ )
double xs = x*m[0] + y*m[1] + m[2];
double ys = x*m[3] + y*m[4] + m[5];
double ds = x*m[6] + y*m[7] + m[8];
ds = ds ? 1./ds : 0;
xs *= ds;
ys *= ds;
mapx.at<float>(y, x) = (float)xs;
mapy.at<float>(y, x) = (float)ys;
}
@@ -806,15 +806,15 @@ protected:
void fill_array( int test_case_idx, int i, int j, Mat& arr );
private:
bool useCPlus;
cv::Mat input0;
cv::Mat input1;
cv::Mat input2;
cv::Mat input_new_cam;
cv::Mat input_output;
bool useCPlus;
cv::Mat input0;
cv::Mat input1;
cv::Mat input2;
cv::Mat input_new_cam;
cv::Mat input_output;
bool zero_new_cam;
bool zero_distortion;
bool zero_new_cam;
bool zero_distortion;
};
@@ -823,7 +823,7 @@ CV_UndistortTest::CV_UndistortTest() : CV_ImgWarpBaseTest( false )
//spatial_scale_zoom = spatial_scale_decimate;
test_array[INPUT].push_back(NULL);
test_array[INPUT].push_back(NULL);
test_array[INPUT].push_back(NULL);
test_array[INPUT].push_back(NULL);
spatial_scale_decimate = spatial_scale_zoom;
}
@@ -834,14 +834,14 @@ void CV_UndistortTest::get_test_array_types_and_sizes( int test_case_idx, vector
RNG& rng = ts->get_rng();
CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
int type = types[INPUT][0];
type = CV_MAKETYPE( CV_8U, CV_MAT_CN(type) );
type = CV_MAKETYPE( CV_8U, CV_MAT_CN(type) );
types[INPUT][0] = types[INPUT_OUTPUT][0] = types[REF_INPUT_OUTPUT][0] = type;
types[INPUT][1] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
types[INPUT][2] = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
sizes[INPUT][1] = cvSize(3,3);
sizes[INPUT][2] = cvtest::randInt(rng)%2 ? cvSize(4,1) : cvSize(1,4);
types[INPUT][3] = types[INPUT][1];
sizes[INPUT][3] = sizes[INPUT][1];
types[INPUT][3] = types[INPUT][1];
sizes[INPUT][3] = sizes[INPUT][1];
interpolation = CV_INTER_LINEAR;
}
@@ -855,22 +855,22 @@ void CV_UndistortTest::fill_array( int test_case_idx, int i, int j, Mat& arr )
void CV_UndistortTest::run_func()
{
if (!useCPlus)
{
if (!useCPlus)
{
CvMat a = test_mat[INPUT][1], k = test_mat[INPUT][2];
cvUndistort2( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], &a, &k);
}
else
{
if (zero_distortion)
{
cv::undistort(input0,input_output,input1,cv::Mat());
}
else
{
cv::undistort(input0,input_output,input1,input2);
}
}
cvUndistort2( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], &a, &k);
}
else
{
if (zero_distortion)
{
cv::undistort(input0,input_output,input1,cv::Mat());
}
else
{
cv::undistort(input0,input_output,input1,input2);
}
}
}
@@ -888,10 +888,10 @@ int CV_UndistortTest::prepare_test_case( int test_case_idx )
const Mat& src = test_mat[INPUT][0];
double k[4], a[9] = {0,0,0,0,0,0,0,0,1};
double new_cam[9] = {0,0,0,0,0,0,0,0,1};
double new_cam[9] = {0,0,0,0,0,0,0,0,1};
double sz = MAX(src.rows, src.cols);
Mat& _new_cam0 = test_mat[INPUT][3];
Mat& _new_cam0 = test_mat[INPUT][3];
Mat _new_cam(test_mat[INPUT][3].rows,test_mat[INPUT][3].cols,CV_64F,new_cam);
Mat& _a0 = test_mat[INPUT][1];
Mat _a(3,3,CV_64F,a);
@@ -925,21 +925,21 @@ int CV_UndistortTest::prepare_test_case( int test_case_idx )
_a.convertTo(_a0, _a0.depth());
zero_distortion = (cvtest::randInt(rng)%2) == 0 ? false : true;
zero_distortion = (cvtest::randInt(rng)%2) == 0 ? false : true;
_k.convertTo(_k0, _k0.depth());
zero_new_cam = (cvtest::randInt(rng)%2) == 0 ? false : true;
zero_new_cam = (cvtest::randInt(rng)%2) == 0 ? false : true;
_new_cam.convertTo(_new_cam0, _new_cam0.depth());
//Testing C++ code
useCPlus = ((cvtest::randInt(rng) % 2)!=0);
if (useCPlus)
{
input0 = test_mat[INPUT][0];
input1 = test_mat[INPUT][1];
input2 = test_mat[INPUT][2];
input_new_cam = test_mat[INPUT][3];
}
//Testing C++ code
useCPlus = ((cvtest::randInt(rng) % 2)!=0);
if (useCPlus)
{
input0 = test_mat[INPUT][0];
input1 = test_mat[INPUT][1];
input2 = test_mat[INPUT][2];
input_new_cam = test_mat[INPUT][3];
}
return code;
}
@@ -947,11 +947,11 @@ int CV_UndistortTest::prepare_test_case( int test_case_idx )
void CV_UndistortTest::prepare_to_validation( int /*test_case_idx*/ )
{
if (useCPlus)
{
if (useCPlus)
{
Mat& output = test_mat[INPUT_OUTPUT][0];
input_output.convertTo(output, output.type());
}
}
Mat& src = test_mat[INPUT][0];
Mat& dst = test_mat[REF_INPUT_OUTPUT][0];
Mat& dst0 = test_mat[INPUT_OUTPUT][0];
@@ -978,7 +978,7 @@ protected:
void fill_array( int test_case_idx, int i, int j, Mat& arr );
private:
bool dualChannel;
bool dualChannel;
};
@@ -1003,8 +1003,8 @@ void CV_UndistortMapTest::get_test_array_types_and_sizes( int test_case_idx, vec
CvSize sz = sizes[OUTPUT][0];
types[INPUT][0] = types[INPUT][1] = depth;
dualChannel = cvtest::randInt(rng)%2 == 0;
types[OUTPUT][0] = types[OUTPUT][1] =
dualChannel = cvtest::randInt(rng)%2 == 0;
types[OUTPUT][0] = types[OUTPUT][1] =
types[REF_OUTPUT][0] = types[REF_OUTPUT][1] = dualChannel ? CV_32FC2 : CV_32F;
sizes[INPUT][0] = cvSize(3,3);
sizes[INPUT][1] = cvtest::randInt(rng)%2 ? cvSize(4,1) : cvSize(1,4);
@@ -1026,11 +1026,11 @@ void CV_UndistortMapTest::fill_array( int test_case_idx, int i, int j, Mat& arr
void CV_UndistortMapTest::run_func()
{
CvMat a = test_mat[INPUT][0], k = test_mat[INPUT][1];
if (!dualChannel )
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], test_array[OUTPUT][1] );
else
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], 0 );
if (!dualChannel )
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], test_array[OUTPUT][1] );
else
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], 0 );
}
@@ -1069,11 +1069,11 @@ int CV_UndistortMapTest::prepare_test_case( int test_case_idx )
_a.convertTo(_a0, _a0.depth());
_k.convertTo(_k0, _k0.depth());
if (dualChannel)
{
if (dualChannel)
{
test_mat[REF_OUTPUT][1] = Scalar::all(0);
test_mat[OUTPUT][1] = Scalar::all(0);
}
test_mat[OUTPUT][1] = Scalar::all(0);
}
return code;
}
@@ -1102,7 +1102,7 @@ test_getQuadrangeSubPix( const Mat& src, Mat& dst, double* a )
{
int sstep = (int)(src.step / sizeof(float));
int scols = src.cols, srows = src.rows;
CV_Assert( src.depth() == CV_32F && src.type() == dst.type() );
int cn = dst.channels();
@@ -1167,11 +1167,11 @@ void CV_GetRectSubPixTest::get_test_array_types_and_sizes( int test_case_idx, ve
int src_depth = cvtest::randInt(rng) % 2, dst_depth;
int cn = cvtest::randInt(rng) % 2 ? 3 : 1;
CvSize src_size, dst_size;
dst_depth = src_depth = src_depth == 0 ? CV_8U : CV_32F;
if( src_depth < CV_32F && cvtest::randInt(rng) % 2 )
dst_depth = CV_32F;
types[INPUT][0] = CV_MAKETYPE(src_depth,cn);
types[INPUT_OUTPUT][0] = types[REF_INPUT_OUTPUT][0] = CV_MAKETYPE(dst_depth,cn);
@@ -1181,11 +1181,11 @@ void CV_GetRectSubPixTest::get_test_array_types_and_sizes( int test_case_idx, ve
dst_size.width = MIN(dst_size.width,src_size.width);
dst_size.height = MIN(dst_size.width,src_size.height);
sizes[INPUT_OUTPUT][0] = sizes[REF_INPUT_OUTPUT][0] = dst_size;
center.x = (float)(cvtest::randReal(rng)*src_size.width);
center.y = (float)(cvtest::randReal(rng)*src_size.height);
interpolation = CV_INTER_LINEAR;
test_cpp = (cvtest::randInt(rng) & 256) == 0;
}
@@ -1274,11 +1274,11 @@ void CV_GetQuadSubPixTest::get_test_array_types_and_sizes( int test_case_idx, ve
RNG& rng = ts->get_rng();
int msz, src_depth = cvtest::randInt(rng) % 2, dst_depth;
int cn = cvtest::randInt(rng) % 2 ? 3 : 1;
dst_depth = src_depth = src_depth == 0 ? CV_8U : CV_32F;
if( src_depth < CV_32F && cvtest::randInt(rng) % 2 )
dst_depth = CV_32F;
types[INPUT][0] = CV_MAKETYPE(src_depth,cn);
types[INPUT_OUTPUT][0] = types[REF_INPUT_OUTPUT][0] = CV_MAKETYPE(dst_depth,cn);
@@ -1333,7 +1333,7 @@ int CV_GetQuadSubPixTest::prepare_test_case( int test_case_idx )
center.y = (float)((cvtest::randReal(rng)*1.2 - 0.1)*src.rows);
angle = cvtest::randReal(rng)*360;
scale = cvtest::randReal(rng)*0.2 + 0.9;
// y = Ax + b -> x = A^-1(y - b) = A^-1*y - A^-1*b
scale = 1./scale;
angle = angle*(CV_PI/180.);
@@ -1413,7 +1413,7 @@ TEST(Imgproc_fitLine_vector_2d, regression)
points_vector.push_back(p21);
points_vector.push_back(p22);
points_vector.push_back(p23);
points_vector.push_back(p23);
std::vector<float> line;

View File

@@ -1,3 +1,7 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
#endif
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__

View File

@@ -91,7 +91,8 @@ void CV_ThreshTest::get_test_array_types_and_sizes( int test_case_idx,
}
else if( depth == CV_16S )
{
float min_val = SHRT_MIN-100.f, max_val = SHRT_MAX+100.f;
float min_val = SHRT_MIN-100.f;
max_val = SHRT_MAX+100.f;
thresh_val = (float)(cvtest::randReal(rng)*(max_val - min_val) + min_val);
max_val = (float)(cvtest::randReal(rng)*(max_val - min_val) + min_val);
if( cvtest::randInt(rng)%4 == 0 )