merged all the latest changes from 2.4 to trunk

This commit is contained in:
Vadim Pisarevsky
2012-04-13 21:50:59 +00:00
parent 020f9a6047
commit 2fd1e2ea57
416 changed files with 12852 additions and 6070 deletions

View File

@@ -218,6 +218,8 @@ CV_EXPORTS void setNumThreads(int nthreads);
CV_EXPORTS int getNumThreads();
CV_EXPORTS int getThreadNum();
CV_EXPORTS_W const std::string& getBuildInformation();
//! Returns the number of ticks.
/*!
@@ -1944,6 +1946,9 @@ public:
MSize size;
MStep step;
protected:
void initEmpty();
};
@@ -2727,7 +2732,6 @@ public:
static MatExpr eye(Size size);
//! some more overriden methods
Mat_ reshape(int _rows) const;
Mat_& adjustROI( int dtop, int dbottom, int dleft, int dright );
Mat_ operator()( const Range& rowRange, const Range& colRange ) const;
Mat_ operator()( const Rect& roi ) const;
@@ -4273,6 +4277,7 @@ public:
void set(const string& name, bool value);
void set(const string& name, const string& value);
void set(const string& name, const Mat& value);
void set(const string& name, const vector<Mat>& value);
void set(const string& name, const Ptr<Algorithm>& value);
void set(const char* name, int value);
@@ -4280,6 +4285,7 @@ public:
void set(const char* name, bool value);
void set(const char* name, const string& value);
void set(const char* name, const Mat& value);
void set(const char* name, const vector<Mat>& value);
void set(const char* name, const Ptr<Algorithm>& value);
string paramHelp(const string& name) const;
@@ -4347,6 +4353,11 @@ public:
Mat (Algorithm::*getter)()=0,
void (Algorithm::*setter)(const Mat&)=0,
const string& help=string());
void addParam(Algorithm& algo, const char* name,
vector<Mat>& value, bool readOnly=false,
vector<Mat> (Algorithm::*getter)()=0,
void (Algorithm::*setter)(const vector<Mat>&)=0,
const string& help=string());
void addParam(Algorithm& algo, const char* name,
Ptr<Algorithm>& value, bool readOnly=false,
Ptr<Algorithm> (Algorithm::*getter)()=0,
@@ -4359,7 +4370,7 @@ protected:
struct CV_EXPORTS Param
{
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, ALGORITHM=5 };
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6 };
Param();
Param(int _type, bool _readonly, int _offset,
@@ -4414,6 +4425,14 @@ template<> struct ParamType<Mat>
enum { type = Param::MAT };
};
template<> struct ParamType<vector<Mat> >
{
typedef const vector<Mat>& const_param_type;
typedef vector<Mat> member_type;
enum { type = Param::MAT_VECTOR };
};
template<> struct ParamType<Algorithm>
{
typedef const Ptr<Algorithm>& const_param_type;

View File

@@ -59,7 +59,7 @@ namespace cv
// It is intended to pass to nvcc-compiled code. GpuMat depends on headers that nvcc can't compile
template <bool expr> struct StaticAssert;
template <> struct StaticAssert<true> {static __CV_GPU_HOST_DEVICE__ void check(){}};
template <> struct StaticAssert<true> {static __CV_GPU_HOST_DEVICE__ void check(){}};
template<typename T> struct DevPtr
{

View File

@@ -55,53 +55,55 @@ namespace cv
//////////////////////////////// Mat ////////////////////////////////
inline Mat::Mat()
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
inline void Mat::initEmpty()
{
flags = MAGIC_VAL;
dims = rows = cols = 0;
data = datastart = dataend = datalimit = 0;
refcount = 0;
allocator = 0;
}
inline Mat::Mat() : size(&rows)
{
initEmpty();
}
inline Mat::Mat(int _rows, int _cols, int _type)
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
inline Mat::Mat(int _rows, int _cols, int _type) : size(&rows)
{
initEmpty();
create(_rows, _cols, _type);
}
inline Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
inline Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s) : size(&rows)
{
initEmpty();
create(_rows, _cols, _type);
*this = _s;
}
inline Mat::Mat(Size _sz, int _type)
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
inline Mat::Mat(Size _sz, int _type) : size(&rows)
{
initEmpty();
create( _sz.height, _sz.width, _type );
}
inline Mat::Mat(Size _sz, int _type, const Scalar& _s)
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
inline Mat::Mat(Size _sz, int _type, const Scalar& _s) : size(&rows)
{
initEmpty();
create(_sz.height, _sz.width, _type);
*this = _s;
}
inline Mat::Mat(int _dims, const int* _sz, int _type)
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
inline Mat::Mat(int _dims, const int* _sz, int _type) : size(&rows)
{
initEmpty();
create(_dims, _sz, _type);
}
inline Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0),
datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
inline Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s) : size(&rows)
{
initEmpty();
create(_dims, _sz, _type);
*this = _s;
}
@@ -169,27 +171,6 @@ inline Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
}
inline Mat::Mat(const CvMat* m, bool copyData)
: flags(MAGIC_VAL + (m->type & (CV_MAT_TYPE_MASK|CV_MAT_CONT_FLAG))),
dims(2), rows(m->rows), cols(m->cols), data(m->data.ptr), refcount(0),
datastart(m->data.ptr), allocator(0), size(&rows)
{
if( !copyData )
{
size_t esz = CV_ELEM_SIZE(m->type), minstep = cols*esz, _step = m->step;
if( _step == 0 )
_step = minstep;
datalimit = datastart + _step*rows;
dataend = datalimit - _step + minstep;
step[0] = _step; step[1] = esz;
}
else
{
data = datastart = dataend = 0;
Mat(m->rows, m->cols, m->type, m->data.ptr, m->step).copyTo(*this);
}
}
template<typename _Tp> inline Mat::Mat(const vector<_Tp>& vec, bool copyData)
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG),
dims(2), rows((int)vec.size()), cols(1), data(0), refcount(0),
@@ -338,8 +319,9 @@ inline Mat Mat::colRange(const Range& r) const
inline Mat Mat::diag(const Mat& d)
{
CV_Assert( d.cols == 1 );
Mat m(d.rows, d.rows, d.type(), Scalar(0)), md = m.diag();
CV_Assert( d.cols == 1 || d.rows == 1 );
int len = d.rows + d.cols - 1;
Mat m(len, len, d.type(), Scalar(0)), md = m.diag();
d.copyTo(md);
return m;
}
@@ -969,9 +951,6 @@ template<typename _Tp> inline int Mat_<_Tp>::channels() const
template<typename _Tp> inline size_t Mat_<_Tp>::stepT(int i) const { return step.p[i]/elemSize(); }
template<typename _Tp> inline size_t Mat_<_Tp>::step1(int i) const { return step.p[i]/elemSize1(); }
template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::reshape(int _rows) const
{ return Mat_<_Tp>(Mat::reshape(0,_rows)); }
template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::adjustROI( int dtop, int dbottom, int dleft, int dright )
{ return (Mat_<_Tp>&)(Mat::adjustROI(dtop, dbottom, dleft, dright)); }

View File

@@ -2277,7 +2277,7 @@ public:
{ set((_Tp*)&vec.val[0], n, true); }
Vector(const std::vector<_Tp>& vec, bool _copyData=false)
{ set((_Tp*)&vec[0], vec.size(), _copyData); }
{ set(!vec.empty() ? (_Tp*)&vec[0] : 0, vec.size(), _copyData); }
Vector(const Vector& d) { *this = d; }
@@ -2445,14 +2445,17 @@ dot(const Vector<_Tp>& v1, const Vector<_Tp>& v2)
assert(v1.size() == v2.size());
_Tw s = 0;
const _Tp *ptr1 = &v1[0], *ptr2 = &v2[0];
#if CV_ENABLE_UNROLLED
for(; i <= n - 4; i += 4 )
s += (_Tw)ptr1[i]*ptr2[i] + (_Tw)ptr1[i+1]*ptr2[i+1] +
(_Tw)ptr1[i+2]*ptr2[i+2] + (_Tw)ptr1[i+3]*ptr2[i+3];
#endif
for( ; i < n; i++ )
s += (_Tw)ptr1[i]*ptr2[i];
if( n > 0 )
{
const _Tp *ptr1 = &v1[0], *ptr2 = &v2[0];
#if CV_ENABLE_UNROLLED
for(; i <= n - 4; i += 4 )
s += (_Tw)ptr1[i]*ptr2[i] + (_Tw)ptr1[i+1]*ptr2[i+1] +
(_Tw)ptr1[i+2]*ptr2[i+2] + (_Tw)ptr1[i+3]*ptr2[i+3];
#endif
for( ; i < n; i++ )
s += (_Tw)ptr1[i]*ptr2[i];
}
return s;
}
@@ -2834,29 +2837,27 @@ public:
{
int _fmt = DataType<_Tp>::fmt;
char fmt[] = { (char)((_fmt>>8)+'1'), (char)_fmt, '\0' };
fs->writeRaw( string(fmt), (uchar*)&vec[0], vec.size()*sizeof(_Tp) );
fs->writeRaw( string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, vec.size()*sizeof(_Tp) );
}
FileStorage* fs;
};
template<typename _Tp> static inline void write( FileStorage& fs, const vector<_Tp>& vec )
{
VecWriterProxy<_Tp, DataType<_Tp>::fmt != 0> w(&fs);
w(vec);
}
template<typename _Tp> static inline FileStorage&
operator << ( FileStorage& fs, const vector<_Tp>& vec )
template<typename _Tp> static inline void write( FileStorage& fs, const string& name,
const vector<_Tp>& vec )
{
VecWriterProxy<_Tp, DataType<_Tp>::generic_type == 0> w(&fs);
w(vec);
return fs;
}
WriteStructContext ws(fs, name, CV_NODE_SEQ+(DataType<_Tp>::fmt != 0 ? CV_NODE_FLOW : 0));
write(fs, vec);
}
CV_EXPORTS_W void write( FileStorage& fs, const string& name, const Mat& value );
CV_EXPORTS void write( FileStorage& fs, const string& name, const SparseMat& value );
template<typename _Tp> static inline FileStorage& operator << (FileStorage& fs, const _Tp& value)
{
if( !fs.isOpened() )
@@ -2893,7 +2894,7 @@ inline size_t FileNode::size() const
{
int t = type();
return t == MAP ? ((CvSet*)node->data.map)->active_count :
t == SEQ ? node->data.seq->total : node != 0;
t == SEQ ? node->data.seq->total : (size_t)!isNone();
}
inline CvFileNode* FileNode::operator *() { return (CvFileNode*)node; }
@@ -2956,7 +2957,7 @@ static inline void read(const FileNode& node, string& value, const string& defau
}
CV_EXPORTS_W void read(const FileNode& node, Mat& mat, const Mat& default_mat=Mat() );
CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat=SparseMat() );
CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat=SparseMat() );
inline FileNode::operator int() const
{
@@ -3011,10 +3012,10 @@ public:
size_t remaining = it->remaining, cn = DataType<_Tp>::channels;
int _fmt = DataType<_Tp>::fmt;
char fmt[] = { (char)((_fmt>>8)+'1'), (char)_fmt, '\0' };
size_t remaining1 = remaining/cn;
count = count < remaining1 ? count : remaining1;
size_t remaining1 = remaining/cn;
count = count < remaining1 ? count : remaining1;
vec.resize(count);
it->readRaw( string(fmt), (uchar*)&vec[0], count*sizeof(_Tp) );
it->readRaw( string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp) );
}
FileNodeIterator* it;
};
@@ -3027,9 +3028,15 @@ read( FileNodeIterator& it, vector<_Tp>& vec, size_t maxCount=(size_t)INT_MAX )
}
template<typename _Tp> static inline void
read( FileNode& node, vector<_Tp>& vec, const vector<_Tp>& default_value=vector<_Tp>() )
read( const FileNode& node, vector<_Tp>& vec, const vector<_Tp>& default_value=vector<_Tp>() )
{
read( node.begin(), vec );
if(!node.node)
vec = default_value;
else
{
FileNodeIterator it = node.begin();
read( it, vec );
}
}
inline FileNodeIterator FileNode::begin() const