|
|
@ -489,158 +489,6 @@ CV__DEBUG_NS_END |
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////// Mat //////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////// Mat //////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat() |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
|
|
|
|
|
|
|
datalimit(0), allocator(0), u(0), size(&rows), step(0) |
|
|
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(int _rows, int _cols, int _type) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
|
|
|
|
|
|
|
datalimit(0), allocator(0), u(0), size(&rows), step(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_rows, _cols, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
|
|
|
|
|
|
|
datalimit(0), allocator(0), u(0), size(&rows), step(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_rows, _cols, _type); |
|
|
|
|
|
|
|
*this = _s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(Size _sz, int _type) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
|
|
|
|
|
|
|
datalimit(0), allocator(0), u(0), size(&rows), step(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create( _sz.height, _sz.width, _type ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(Size _sz, int _type, const Scalar& _s) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
|
|
|
|
|
|
|
datalimit(0), allocator(0), u(0), size(&rows), step(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_sz.height, _sz.width, _type); |
|
|
|
|
|
|
|
*this = _s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(int _dims, const int* _sz, int _type) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
|
|
|
|
|
|
|
datalimit(0), allocator(0), u(0), size(&rows), step(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_dims, _sz, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
|
|
|
|
|
|
|
datalimit(0), allocator(0), u(0), size(&rows), step(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_dims, _sz, _type); |
|
|
|
|
|
|
|
*this = _s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(const std::vector<int>& _sz, int _type) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
|
|
|
|
|
|
|
datalimit(0), allocator(0), u(0), size(&rows), step(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_sz, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(const std::vector<int>& _sz, int _type, const Scalar& _s) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), |
|
|
|
|
|
|
|
datalimit(0), allocator(0), u(0), size(&rows), step(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_sz, _type); |
|
|
|
|
|
|
|
*this = _s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(const Mat& m) |
|
|
|
|
|
|
|
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data), |
|
|
|
|
|
|
|
datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit), allocator(m.allocator), |
|
|
|
|
|
|
|
u(m.u), size(&rows), step(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( u ) |
|
|
|
|
|
|
|
CV_XADD(&u->refcount, 1); |
|
|
|
|
|
|
|
if( m.dims <= 2 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
step[0] = m.step[0]; step[1] = m.step[1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
dims = 0; |
|
|
|
|
|
|
|
copySize(m); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_rows), cols(_cols), |
|
|
|
|
|
|
|
data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0), |
|
|
|
|
|
|
|
allocator(0), u(0), size(&rows) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CV_Assert(total() == 0 || data != NULL); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t esz = CV_ELEM_SIZE(_type), esz1 = CV_ELEM_SIZE1(_type); |
|
|
|
|
|
|
|
size_t minstep = cols * esz; |
|
|
|
|
|
|
|
if( _step == AUTO_STEP ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_step = minstep; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CV_DbgAssert( _step >= minstep ); |
|
|
|
|
|
|
|
if (_step % esz1 != 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CV_Error(Error::BadStep, "Step must be a multiple of esz1"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
step[0] = _step; |
|
|
|
|
|
|
|
step[1] = esz; |
|
|
|
|
|
|
|
datalimit = datastart + _step * rows; |
|
|
|
|
|
|
|
dataend = datalimit - _step + minstep; |
|
|
|
|
|
|
|
updateContinuityFlag(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::Mat(Size _sz, int _type, void* _data, size_t _step) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width), |
|
|
|
|
|
|
|
data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0), |
|
|
|
|
|
|
|
allocator(0), u(0), size(&rows) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CV_Assert(total() == 0 || data != NULL); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t esz = CV_ELEM_SIZE(_type), esz1 = CV_ELEM_SIZE1(_type); |
|
|
|
|
|
|
|
size_t minstep = cols*esz; |
|
|
|
|
|
|
|
if( _step == AUTO_STEP ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_step = minstep; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CV_DbgAssert( _step >= minstep ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_step % esz1 != 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CV_Error(Error::BadStep, "Step must be a multiple of esz1"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
step[0] = _step; |
|
|
|
|
|
|
|
step[1] = esz; |
|
|
|
|
|
|
|
datalimit = datastart + _step*rows; |
|
|
|
|
|
|
|
dataend = datalimit - _step + minstep; |
|
|
|
|
|
|
|
updateContinuityFlag(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp> inline |
|
|
|
template<typename _Tp> inline |
|
|
|
Mat::Mat(const std::vector<_Tp>& vec, bool copyData) |
|
|
|
Mat::Mat(const std::vector<_Tp>& vec, bool copyData) |
|
|
|
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), |
|
|
|
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), |
|
|
@ -778,43 +626,6 @@ Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer) |
|
|
|
*this = commaInitializer.operator Mat_<_Tp>(); |
|
|
|
*this = commaInitializer.operator Mat_<_Tp>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat::~Mat() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
release(); |
|
|
|
|
|
|
|
if( step.p != step.buf ) |
|
|
|
|
|
|
|
fastFree(step.p); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat& Mat::operator = (const Mat& m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( this != &m ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( m.u ) |
|
|
|
|
|
|
|
CV_XADD(&m.u->refcount, 1); |
|
|
|
|
|
|
|
release(); |
|
|
|
|
|
|
|
flags = m.flags; |
|
|
|
|
|
|
|
if( dims <= 2 && m.dims <= 2 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
dims = m.dims; |
|
|
|
|
|
|
|
rows = m.rows; |
|
|
|
|
|
|
|
cols = m.cols; |
|
|
|
|
|
|
|
step[0] = m.step[0]; |
|
|
|
|
|
|
|
step[1] = m.step[1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
copySize(m); |
|
|
|
|
|
|
|
data = m.data; |
|
|
|
|
|
|
|
datastart = m.datastart; |
|
|
|
|
|
|
|
dataend = m.dataend; |
|
|
|
|
|
|
|
datalimit = m.datalimit; |
|
|
|
|
|
|
|
allocator = m.allocator; |
|
|
|
|
|
|
|
u = m.u; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return *this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
inline |
|
|
|
Mat Mat::row(int y) const |
|
|
|
Mat Mat::row(int y) const |
|
|
|
{ |
|
|
|
{ |
|
|
@ -851,67 +662,6 @@ Mat Mat::colRange(const Range& r) const |
|
|
|
return Mat(*this, Range::all(), r); |
|
|
|
return Mat(*this, Range::all(), r); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
Mat Mat::clone() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Mat m; |
|
|
|
|
|
|
|
copyTo(m); |
|
|
|
|
|
|
|
return m; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void Mat::assignTo( Mat& m, int _type ) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( _type < 0 ) |
|
|
|
|
|
|
|
m = *this; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
convertTo(m, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void Mat::create(int _rows, int _cols, int _type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_type &= TYPE_MASK; |
|
|
|
|
|
|
|
if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && data ) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
int sz[] = {_rows, _cols}; |
|
|
|
|
|
|
|
create(2, sz, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void Mat::create(Size _sz, int _type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_sz.height, _sz.width, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void Mat::addref() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( u ) |
|
|
|
|
|
|
|
CV_XADD(&u->refcount, 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void Mat::release() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( u && CV_XADD(&u->refcount, -1) == 1 ) |
|
|
|
|
|
|
|
deallocate(); |
|
|
|
|
|
|
|
u = NULL; |
|
|
|
|
|
|
|
datastart = dataend = datalimit = data = 0; |
|
|
|
|
|
|
|
for(int i = 0; i < dims; i++) |
|
|
|
|
|
|
|
size.p[i] = 0; |
|
|
|
|
|
|
|
#ifdef _DEBUG |
|
|
|
|
|
|
|
flags = MAGIC_VAL; |
|
|
|
|
|
|
|
dims = rows = cols = 0; |
|
|
|
|
|
|
|
if(step.p != step.buf) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fastFree(step.p); |
|
|
|
|
|
|
|
step.p = step.buf; |
|
|
|
|
|
|
|
size.p = &rows; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
inline |
|
|
|
Mat Mat::operator()( Range _rowRange, Range _colRange ) const |
|
|
|
Mat Mat::operator()( Range _rowRange, Range _colRange ) const |
|
|
|
{ |
|
|
|
{ |
|
|
@ -980,40 +730,6 @@ int Mat::channels() const |
|
|
|
return CV_MAT_CN(flags); |
|
|
|
return CV_MAT_CN(flags); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
size_t Mat::step1(int i) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return step.p[i] / elemSize1(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
bool Mat::empty() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return data == 0 || total() == 0 || dims == 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
size_t Mat::total() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( dims <= 2 ) |
|
|
|
|
|
|
|
return (size_t)rows * cols; |
|
|
|
|
|
|
|
size_t p = 1; |
|
|
|
|
|
|
|
for( int i = 0; i < dims; i++ ) |
|
|
|
|
|
|
|
p *= size[i]; |
|
|
|
|
|
|
|
return p; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
size_t Mat::total(int startDim, int endDim) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CV_Assert( 0 <= startDim && startDim <= endDim); |
|
|
|
|
|
|
|
size_t p = 1; |
|
|
|
|
|
|
|
int endDim_ = endDim <= dims ? endDim : dims; |
|
|
|
|
|
|
|
for( int i = startDim; i < endDim_; i++ ) |
|
|
|
|
|
|
|
p *= size[i]; |
|
|
|
|
|
|
|
return p; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
inline |
|
|
|
uchar* Mat::ptr(int y) |
|
|
|
uchar* Mat::ptr(int y) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1544,22 +1260,6 @@ MatSize::operator const int*() const |
|
|
|
return p; |
|
|
|
return p; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
bool MatSize::operator == (const MatSize& sz) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int d = dims(); |
|
|
|
|
|
|
|
int dsz = sz.dims(); |
|
|
|
|
|
|
|
if( d != dsz ) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
if( d == 2 ) |
|
|
|
|
|
|
|
return p[0] == sz.p[0] && p[1] == sz.p[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for( int i = 0; i < d; i++ ) |
|
|
|
|
|
|
|
if( p[i] != sz.p[i] ) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
inline |
|
|
|
bool MatSize::operator != (const MatSize& sz) const |
|
|
|
bool MatSize::operator != (const MatSize& sz) const |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1820,9 +1520,7 @@ template<typename _Tp> inline |
|
|
|
void Mat_<_Tp>::release() |
|
|
|
void Mat_<_Tp>::release() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Mat::release(); |
|
|
|
Mat::release(); |
|
|
|
#ifdef _DEBUG |
|
|
|
|
|
|
|
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value; |
|
|
|
flags = (flags & ~CV_MAT_TYPE_MASK) | traits::Type<_Tp>::value; |
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp> inline |
|
|
|
template<typename _Tp> inline |
|
|
@ -2182,51 +1880,6 @@ Mat_<_Tp>::Mat_(MatExpr&& e) |
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////// SparseMat /////////////////////////////
|
|
|
|
///////////////////////////// SparseMat /////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
SparseMat::SparseMat() |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), hdr(0) |
|
|
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
SparseMat::SparseMat(int _dims, const int* _sizes, int _type) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), hdr(0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_dims, _sizes, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
SparseMat::SparseMat(const SparseMat& m) |
|
|
|
|
|
|
|
: flags(m.flags), hdr(m.hdr) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
addref(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
SparseMat::~SparseMat() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
release(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
SparseMat& SparseMat::operator = (const SparseMat& m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( this != &m ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( m.hdr ) |
|
|
|
|
|
|
|
CV_XADD(&m.hdr->refcount, 1); |
|
|
|
|
|
|
|
release(); |
|
|
|
|
|
|
|
flags = m.flags; |
|
|
|
|
|
|
|
hdr = m.hdr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return *this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
SparseMat& SparseMat::operator = (const Mat& m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (*this = SparseMat(m)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
inline |
|
|
|
SparseMat SparseMat::clone() const |
|
|
|
SparseMat SparseMat::clone() const |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2235,30 +1888,6 @@ SparseMat SparseMat::clone() const |
|
|
|
return temp; |
|
|
|
return temp; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void SparseMat::assignTo( SparseMat& m, int _type ) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( _type < 0 ) |
|
|
|
|
|
|
|
m = *this; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
convertTo(m, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void SparseMat::addref() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( hdr ) |
|
|
|
|
|
|
|
CV_XADD(&hdr->refcount, 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void SparseMat::release() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( hdr && CV_XADD(&hdr->refcount, -1) == 1 ) |
|
|
|
|
|
|
|
delete hdr; |
|
|
|
|
|
|
|
hdr = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
inline |
|
|
|
size_t SparseMat::elemSize() const |
|
|
|
size_t SparseMat::elemSize() const |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2318,36 +1947,6 @@ size_t SparseMat::nzcount() const |
|
|
|
return hdr ? hdr->nodeCount : 0; |
|
|
|
return hdr ? hdr->nodeCount : 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
size_t SparseMat::hash(int i0) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (size_t)i0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
size_t SparseMat::hash(int i0, int i1) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (size_t)(unsigned)i0 * HASH_SCALE + (unsigned)i1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
size_t SparseMat::hash(int i0, int i1, int i2) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return ((size_t)(unsigned)i0 * HASH_SCALE + (unsigned)i1) * HASH_SCALE + (unsigned)i2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
size_t SparseMat::hash(const int* idx) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
size_t h = (unsigned)idx[0]; |
|
|
|
|
|
|
|
if( !hdr ) |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
int d = hdr->dims; |
|
|
|
|
|
|
|
for(int i = 1; i < d; i++ ) |
|
|
|
|
|
|
|
h = h * HASH_SCALE + (unsigned)idx[i]; |
|
|
|
|
|
|
|
return h; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp> inline |
|
|
|
template<typename _Tp> inline |
|
|
|
_Tp& SparseMat::ref(int i0, size_t* hashval) |
|
|
|
_Tp& SparseMat::ref(int i0, size_t* hashval) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -3667,74 +3266,6 @@ const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b) |
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////// UMat ////////////////////////////////
|
|
|
|
//////////////////////////////// UMat ////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat::UMat(UMatUsageFlags _usageFlags) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
|
|
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat::UMat(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_rows, _cols, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat::UMat(int _rows, int _cols, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_rows, _cols, _type); |
|
|
|
|
|
|
|
*this = _s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat::UMat(Size _sz, int _type, UMatUsageFlags _usageFlags) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create( _sz.height, _sz.width, _type ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat::UMat(Size _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_sz.height, _sz.width, _type); |
|
|
|
|
|
|
|
*this = _s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat::UMat(int _dims, const int* _sz, int _type, UMatUsageFlags _usageFlags) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_dims, _sz, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat::UMat(int _dims, const int* _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags) |
|
|
|
|
|
|
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_dims, _sz, _type); |
|
|
|
|
|
|
|
*this = _s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat::UMat(const UMat& m) |
|
|
|
|
|
|
|
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), allocator(m.allocator), |
|
|
|
|
|
|
|
usageFlags(m.usageFlags), u(m.u), offset(m.offset), size(&rows) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
addref(); |
|
|
|
|
|
|
|
if( m.dims <= 2 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
step[0] = m.step[0]; step[1] = m.step[1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
dims = 0; |
|
|
|
|
|
|
|
copySize(m); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename _Tp> inline |
|
|
|
template<typename _Tp> inline |
|
|
|
UMat::UMat(const std::vector<_Tp>& vec, bool copyData) |
|
|
|
UMat::UMat(const std::vector<_Tp>& vec, bool copyData) |
|
|
|
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), |
|
|
|
: flags(MAGIC_VAL | traits::Type<_Tp>::value | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), |
|
|
@ -3751,33 +3282,6 @@ cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) |
|
|
|
Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this); |
|
|
|
Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat& UMat::operator = (const UMat& m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( this != &m ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const_cast<UMat&>(m).addref(); |
|
|
|
|
|
|
|
release(); |
|
|
|
|
|
|
|
flags = m.flags; |
|
|
|
|
|
|
|
if( dims <= 2 && m.dims <= 2 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
dims = m.dims; |
|
|
|
|
|
|
|
rows = m.rows; |
|
|
|
|
|
|
|
cols = m.cols; |
|
|
|
|
|
|
|
step[0] = m.step[0]; |
|
|
|
|
|
|
|
step[1] = m.step[1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
copySize(m); |
|
|
|
|
|
|
|
allocator = m.allocator; |
|
|
|
|
|
|
|
if (usageFlags == USAGE_DEFAULT) |
|
|
|
|
|
|
|
usageFlags = m.usageFlags; |
|
|
|
|
|
|
|
u = m.u; |
|
|
|
|
|
|
|
offset = m.offset; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return *this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
inline |
|
|
|
UMat UMat::row(int y) const |
|
|
|
UMat UMat::row(int y) const |
|
|
|
{ |
|
|
|
{ |
|
|
@ -3814,55 +3318,6 @@ UMat UMat::colRange(const Range& r) const |
|
|
|
return UMat(*this, Range::all(), r); |
|
|
|
return UMat(*this, Range::all(), r); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
UMat UMat::clone() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UMat m; |
|
|
|
|
|
|
|
copyTo(m); |
|
|
|
|
|
|
|
return m; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void UMat::assignTo( UMat& m, int _type ) const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( _type < 0 ) |
|
|
|
|
|
|
|
m = *this; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
convertTo(m, _type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void UMat::create(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_type &= TYPE_MASK; |
|
|
|
|
|
|
|
if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && u ) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
int sz[] = {_rows, _cols}; |
|
|
|
|
|
|
|
create(2, sz, _type, _usageFlags); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void UMat::create(Size _sz, int _type, UMatUsageFlags _usageFlags) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
create(_sz.height, _sz.width, _type, _usageFlags); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
void UMat::addref() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( u ) |
|
|
|
|
|
|
|
CV_XADD(&(u->urefcount), 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void UMat::release() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( u && CV_XADD(&(u->urefcount), -1) == 1 ) |
|
|
|
|
|
|
|
deallocate(); |
|
|
|
|
|
|
|
for(int i = 0; i < dims; i++) |
|
|
|
|
|
|
|
size.p[i] = 0; |
|
|
|
|
|
|
|
u = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
inline |
|
|
|
UMat UMat::operator()( Range _rowRange, Range _colRange ) const |
|
|
|
UMat UMat::operator()( Range _rowRange, Range _colRange ) const |
|
|
|
{ |
|
|
|
{ |
|
|
@ -3937,23 +3392,6 @@ size_t UMat::step1(int i) const |
|
|
|
return step.p[i] / elemSize1(); |
|
|
|
return step.p[i] / elemSize1(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
bool UMat::empty() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return u == 0 || total() == 0 || dims == 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
|
|
|
|
size_t UMat::total() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( dims <= 2 ) |
|
|
|
|
|
|
|
return (size_t)rows * cols; |
|
|
|
|
|
|
|
size_t p = 1; |
|
|
|
|
|
|
|
for( int i = 0; i < dims; i++ ) |
|
|
|
|
|
|
|
p *= size[i]; |
|
|
|
|
|
|
|
return p; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CV_CXX_MOVE_SEMANTICS |
|
|
|
#ifdef CV_CXX_MOVE_SEMANTICS |
|
|
|
|
|
|
|
|
|
|
|
inline |
|
|
|
inline |
|
|
|