1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #11406 from alalek:core_matsize_dims

This commit is contained in:
Alexander Alekhin
2018-04-28 14:38:42 +00:00
6 changed files with 27 additions and 11 deletions
@@ -265,10 +265,10 @@ std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect)
static inline std::ostream& operator << (std::ostream& out, const MatSize& msize)
{
int i, dims = msize.p[-1];
int i, dims = msize.dims();
for( i = 0; i < dims; i++ )
{
out << msize.p[i];
out << msize[i];
if( i < dims-1 )
out << " x ";
}
+2 -1
View File
@@ -549,10 +549,11 @@ struct CV_EXPORTS UMatData
struct CV_EXPORTS MatSize
{
explicit MatSize(int* _p);
int dims() const;
Size operator()() const;
const int& operator[](int i) const;
int& operator[](int i);
operator const int*() const;
operator const int*() const; // TODO OpenCV 4.0: drop this
bool operator == (const MatSize& sz) const;
bool operator != (const MatSize& sz) const;
+17 -3
View File
@@ -1412,22 +1412,36 @@ inline
MatSize::MatSize(int* _p)
: p(_p) {}
inline
int MatSize::dims() const
{
return (p - 1)[0];
}
inline
Size MatSize::operator()() const
{
CV_DbgAssert(p[-1] <= 2);
CV_DbgAssert(dims() <= 2);
return Size(p[1], p[0]);
}
inline
const int& MatSize::operator[](int i) const
{
CV_DbgAssert(i < dims());
#ifdef __OPENCV_BUILD
CV_DbgAssert(i >= 0);
#endif
return p[i];
}
inline
int& MatSize::operator[](int i)
{
CV_DbgAssert(i < dims());
#ifdef __OPENCV_BUILD
CV_DbgAssert(i >= 0);
#endif
return p[i];
}
@@ -1440,8 +1454,8 @@ MatSize::operator const int*() const
inline
bool MatSize::operator == (const MatSize& sz) const
{
int d = p[-1];
int dsz = sz.p[-1];
int d = dims();
int dsz = sz.dims();
if( d != dsz )
return false;
if( d == 2 )