removed refcount field from Mat; that helped to find and eliminate some memory leaks. perf tests should probably pass now
This commit is contained in:
parent
5a34272150
commit
303df78cca
@ -595,7 +595,7 @@ namespace cv {
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
Mat::Mat(const cuda::GpuMat& m)
|
Mat::Mat(const cuda::GpuMat& m)
|
||||||
: flags(0), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0), datalimit(0), allocator(0), size(&rows)
|
: flags(0), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
m.download(*this);
|
m.download(*this);
|
||||||
}
|
}
|
||||||
|
@ -874,10 +874,6 @@ public:
|
|||||||
//! pointer to the data
|
//! pointer to the data
|
||||||
uchar* data;
|
uchar* data;
|
||||||
|
|
||||||
//! pointer to the reference counter;
|
|
||||||
// when matrix points to user-allocated data, the pointer is NULL
|
|
||||||
int* refcount;
|
|
||||||
|
|
||||||
//! helper fields used in locateROI and adjustROI
|
//! helper fields used in locateROI and adjustROI
|
||||||
uchar* datastart;
|
uchar* datastart;
|
||||||
uchar* dataend;
|
uchar* dataend;
|
||||||
|
@ -274,13 +274,13 @@ inline _InputOutputArray::_InputOutputArray(const cuda::CudaMem& cuda_mem)
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
Mat::Mat()
|
Mat::Mat()
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), u(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
Mat::Mat(int _rows, int _cols, int _type)
|
Mat::Mat(int _rows, int _cols, int _type)
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), u(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
create(_rows, _cols, _type);
|
create(_rows, _cols, _type);
|
||||||
@ -288,7 +288,7 @@ Mat::Mat(int _rows, int _cols, int _type)
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
|
Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), u(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
create(_rows, _cols, _type);
|
create(_rows, _cols, _type);
|
||||||
@ -297,7 +297,7 @@ Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
Mat::Mat(Size _sz, int _type)
|
Mat::Mat(Size _sz, int _type)
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), u(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
create( _sz.height, _sz.width, _type );
|
create( _sz.height, _sz.width, _type );
|
||||||
@ -305,7 +305,7 @@ Mat::Mat(Size _sz, int _type)
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
Mat::Mat(Size _sz, int _type, const Scalar& _s)
|
Mat::Mat(Size _sz, int _type, const Scalar& _s)
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), u(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
create(_sz.height, _sz.width, _type);
|
create(_sz.height, _sz.width, _type);
|
||||||
@ -314,7 +314,7 @@ Mat::Mat(Size _sz, int _type, const Scalar& _s)
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
Mat::Mat(int _dims, const int* _sz, int _type)
|
Mat::Mat(int _dims, const int* _sz, int _type)
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), u(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
create(_dims, _sz, _type);
|
create(_dims, _sz, _type);
|
||||||
@ -322,7 +322,7 @@ Mat::Mat(int _dims, const int* _sz, int _type)
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
|
Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), u(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
create(_dims, _sz, _type);
|
create(_dims, _sz, _type);
|
||||||
@ -331,12 +331,12 @@ Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
|
|||||||
|
|
||||||
inline
|
inline
|
||||||
Mat::Mat(const Mat& m)
|
Mat::Mat(const Mat& m)
|
||||||
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data), refcount(m.refcount),
|
: 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),
|
datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit), allocator(m.allocator),
|
||||||
u(m.u), size(&rows)
|
u(m.u), size(&rows)
|
||||||
{
|
{
|
||||||
if( refcount )
|
if( u )
|
||||||
CV_XADD(refcount, 1);
|
CV_XADD(&u->refcount, 1);
|
||||||
if( m.dims <= 2 )
|
if( m.dims <= 2 )
|
||||||
{
|
{
|
||||||
step[0] = m.step[0]; step[1] = m.step[1];
|
step[0] = m.step[0]; step[1] = m.step[1];
|
||||||
@ -351,7 +351,7 @@ Mat::Mat(const Mat& m)
|
|||||||
inline
|
inline
|
||||||
Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
|
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),
|
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_rows), cols(_cols),
|
||||||
data((uchar*)_data), refcount(0), datastart((uchar*)_data), dataend(0), datalimit(0),
|
data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0),
|
||||||
allocator(0), u(0), size(&rows)
|
allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
size_t esz = CV_ELEM_SIZE(_type);
|
size_t esz = CV_ELEM_SIZE(_type);
|
||||||
@ -376,7 +376,7 @@ Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
|
|||||||
inline
|
inline
|
||||||
Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
|
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),
|
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width),
|
||||||
data((uchar*)_data), refcount(0), datastart((uchar*)_data), dataend(0), datalimit(0),
|
data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0),
|
||||||
allocator(0), u(0), size(&rows)
|
allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
size_t esz = CV_ELEM_SIZE(_type);
|
size_t esz = CV_ELEM_SIZE(_type);
|
||||||
@ -401,7 +401,7 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
|
|||||||
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 | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
|
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
|
||||||
cols(1), data(0), refcount(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
cols(1), data(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
if(vec.empty())
|
if(vec.empty())
|
||||||
return;
|
return;
|
||||||
@ -418,7 +418,7 @@ Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
|
|||||||
template<typename _Tp, int n> inline
|
template<typename _Tp, int n> inline
|
||||||
Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
|
Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
|
||||||
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
|
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
|
||||||
refcount(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
if( !copyData )
|
if( !copyData )
|
||||||
{
|
{
|
||||||
@ -434,7 +434,7 @@ Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
|
|||||||
template<typename _Tp, int m, int n> inline
|
template<typename _Tp, int m, int n> inline
|
||||||
Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
|
Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
|
||||||
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0),
|
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(m), cols(n), data(0),
|
||||||
refcount(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
if( !copyData )
|
if( !copyData )
|
||||||
{
|
{
|
||||||
@ -450,7 +450,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData)
|
|||||||
template<typename _Tp> inline
|
template<typename _Tp> inline
|
||||||
Mat::Mat(const Point_<_Tp>& pt, bool copyData)
|
Mat::Mat(const Point_<_Tp>& pt, bool copyData)
|
||||||
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0),
|
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0),
|
||||||
refcount(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
if( !copyData )
|
if( !copyData )
|
||||||
{
|
{
|
||||||
@ -469,7 +469,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData)
|
|||||||
template<typename _Tp> inline
|
template<typename _Tp> inline
|
||||||
Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
|
Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
|
||||||
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0),
|
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0),
|
||||||
refcount(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
if( !copyData )
|
if( !copyData )
|
||||||
{
|
{
|
||||||
@ -489,7 +489,7 @@ Mat::Mat(const Point3_<_Tp>& pt, bool copyData)
|
|||||||
template<typename _Tp> inline
|
template<typename _Tp> inline
|
||||||
Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer)
|
Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer)
|
||||||
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0),
|
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0),
|
||||||
refcount(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
*this = commaInitializer.operator Mat_<_Tp>();
|
*this = commaInitializer.operator Mat_<_Tp>();
|
||||||
}
|
}
|
||||||
@ -507,8 +507,8 @@ Mat& Mat::operator = (const Mat& m)
|
|||||||
{
|
{
|
||||||
if( this != &m )
|
if( this != &m )
|
||||||
{
|
{
|
||||||
if( m.refcount )
|
if( m.u )
|
||||||
CV_XADD(m.refcount, 1);
|
CV_XADD(&m.u->refcount, 1);
|
||||||
release();
|
release();
|
||||||
flags = m.flags;
|
flags = m.flags;
|
||||||
if( dims <= 2 && m.dims <= 2 )
|
if( dims <= 2 && m.dims <= 2 )
|
||||||
@ -525,7 +525,6 @@ Mat& Mat::operator = (const Mat& m)
|
|||||||
datastart = m.datastart;
|
datastart = m.datastart;
|
||||||
dataend = m.dataend;
|
dataend = m.dataend;
|
||||||
datalimit = m.datalimit;
|
datalimit = m.datalimit;
|
||||||
refcount = m.refcount;
|
|
||||||
allocator = m.allocator;
|
allocator = m.allocator;
|
||||||
u = m.u;
|
u = m.u;
|
||||||
}
|
}
|
||||||
@ -604,17 +603,16 @@ void Mat::create(Size _sz, int _type)
|
|||||||
inline
|
inline
|
||||||
void Mat::addref()
|
void Mat::addref()
|
||||||
{
|
{
|
||||||
if( refcount )
|
if( u )
|
||||||
CV_XADD(refcount, 1);
|
CV_XADD(&u->refcount, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Mat::release()
|
inline void Mat::release()
|
||||||
{
|
{
|
||||||
if( refcount && CV_XADD(refcount, -1) == 1 )
|
if( u && CV_XADD(&u->refcount, -1) == 1 )
|
||||||
deallocate();
|
deallocate();
|
||||||
data = datastart = dataend = datalimit = 0;
|
data = datastart = dataend = datalimit = 0;
|
||||||
size.p[0] = 0;
|
size.p[0] = 0;
|
||||||
refcount = 0;
|
|
||||||
u = 0;
|
u = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,6 @@ void swap( Mat& a, Mat& b )
|
|||||||
std::swap(a.rows, b.rows);
|
std::swap(a.rows, b.rows);
|
||||||
std::swap(a.cols, b.cols);
|
std::swap(a.cols, b.cols);
|
||||||
std::swap(a.data, b.data);
|
std::swap(a.data, b.data);
|
||||||
std::swap(a.refcount, b.refcount);
|
|
||||||
std::swap(a.datastart, b.datastart);
|
std::swap(a.datastart, b.datastart);
|
||||||
std::swap(a.dataend, b.dataend);
|
std::swap(a.dataend, b.dataend);
|
||||||
std::swap(a.datalimit, b.datalimit);
|
std::swap(a.datalimit, b.datalimit);
|
||||||
@ -397,8 +396,8 @@ void Mat::deallocate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)
|
Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
CV_Assert( m.dims >= 2 );
|
CV_Assert( m.dims >= 2 );
|
||||||
if( m.dims > 2 )
|
if( m.dims > 2 )
|
||||||
@ -443,9 +442,9 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)
|
|||||||
|
|
||||||
Mat::Mat(const Mat& m, const Rect& roi)
|
Mat::Mat(const Mat& m, const Rect& roi)
|
||||||
: flags(m.flags), dims(2), rows(roi.height), cols(roi.width),
|
: flags(m.flags), dims(2), rows(roi.height), cols(roi.width),
|
||||||
data(m.data + roi.y*m.step[0]), refcount(m.refcount),
|
data(m.data + roi.y*m.step[0]),
|
||||||
datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit),
|
datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit),
|
||||||
allocator(m.allocator), size(&rows)
|
allocator(m.allocator), u(m.u), size(&rows)
|
||||||
{
|
{
|
||||||
CV_Assert( m.dims <= 2 );
|
CV_Assert( m.dims <= 2 );
|
||||||
flags &= roi.width < m.cols ? ~CONTINUOUS_FLAG : -1;
|
flags &= roi.width < m.cols ? ~CONTINUOUS_FLAG : -1;
|
||||||
@ -455,8 +454,8 @@ Mat::Mat(const Mat& m, const Rect& roi)
|
|||||||
data += roi.x*esz;
|
data += roi.x*esz;
|
||||||
CV_Assert( 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols &&
|
CV_Assert( 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols &&
|
||||||
0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows );
|
0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows );
|
||||||
if( refcount )
|
if( u )
|
||||||
CV_XADD(refcount, 1);
|
CV_XADD(&u->refcount, 1);
|
||||||
if( roi.width < m.cols || roi.height < m.rows )
|
if( roi.width < m.cols || roi.height < m.rows )
|
||||||
flags |= SUBMATRIX_FLAG;
|
flags |= SUBMATRIX_FLAG;
|
||||||
|
|
||||||
@ -471,8 +470,8 @@ Mat::Mat(const Mat& m, const Rect& roi)
|
|||||||
|
|
||||||
|
|
||||||
Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _steps)
|
Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _steps)
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
flags |= CV_MAT_TYPE(_type);
|
flags |= CV_MAT_TYPE(_type);
|
||||||
data = datastart = (uchar*)_data;
|
data = datastart = (uchar*)_data;
|
||||||
@ -482,8 +481,8 @@ Mat::Mat(int _dims, const int* _sizes, int _type, void* _data, const size_t* _st
|
|||||||
|
|
||||||
|
|
||||||
Mat::Mat(const Mat& m, const Range* ranges)
|
Mat::Mat(const Mat& m, const Range* ranges)
|
||||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), refcount(0), datastart(0), dataend(0),
|
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||||
datalimit(0), allocator(0), size(&rows)
|
datalimit(0), allocator(0), u(0), size(&rows)
|
||||||
{
|
{
|
||||||
int i, d = m.dims;
|
int i, d = m.dims;
|
||||||
|
|
||||||
@ -1470,6 +1469,9 @@ int _InputArray::type(int i) const
|
|||||||
{
|
{
|
||||||
int k = kind();
|
int k = kind();
|
||||||
|
|
||||||
|
if( k == MATX || k == STD_VECTOR || k == STD_VECTOR_VECTOR || (flags & FIXED_TYPE))
|
||||||
|
return CV_MAT_TYPE(flags);
|
||||||
|
|
||||||
if( k == MAT )
|
if( k == MAT )
|
||||||
return ((const Mat*)obj)->type();
|
return ((const Mat*)obj)->type();
|
||||||
|
|
||||||
@ -1479,9 +1481,6 @@ int _InputArray::type(int i) const
|
|||||||
if( k == EXPR )
|
if( k == EXPR )
|
||||||
return ((const MatExpr*)obj)->type();
|
return ((const MatExpr*)obj)->type();
|
||||||
|
|
||||||
if( k == MATX || k == STD_VECTOR || k == STD_VECTOR_VECTOR )
|
|
||||||
return CV_MAT_TYPE(flags);
|
|
||||||
|
|
||||||
if( k == NONE )
|
if( k == NONE )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -547,11 +547,10 @@ Mat UMat::getMat(int accessFlags) const
|
|||||||
u->currAllocator->map(u, accessFlags);
|
u->currAllocator->map(u, accessFlags);
|
||||||
CV_Assert(u->data != 0);
|
CV_Assert(u->data != 0);
|
||||||
Mat hdr(dims, size.p, type(), u->data + offset, step.p);
|
Mat hdr(dims, size.p, type(), u->data + offset, step.p);
|
||||||
hdr.refcount = &u->refcount;
|
|
||||||
hdr.u = u;
|
hdr.u = u;
|
||||||
hdr.datastart = hdr.data = u->data;
|
hdr.datastart = hdr.data = u->data;
|
||||||
hdr.datalimit = hdr.dataend = u->data + u->size;
|
hdr.datalimit = hdr.dataend = u->data + u->size;
|
||||||
CV_XADD(hdr.refcount, 1);
|
CV_XADD(&hdr.u->refcount, 1);
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ PyObject* pyopencv_from(const Mat& m)
|
|||||||
if( !m.data )
|
if( !m.data )
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
Mat temp, *p = (Mat*)&m;
|
Mat temp, *p = (Mat*)&m;
|
||||||
if(!p->refcount || p->allocator != &g_numpyAllocator)
|
if(!p->u || p->allocator != &g_numpyAllocator)
|
||||||
{
|
{
|
||||||
temp.allocator = &g_numpyAllocator;
|
temp.allocator = &g_numpyAllocator;
|
||||||
ERRWRAP2(m.copyTo(temp));
|
ERRWRAP2(m.copyTo(temp));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user