core(InputArray): replace STD_ARRAY to MATX

- remove duplication kind
pull/19535/head
Alexander Alekhin 4 years ago
parent 8f6ba5a089
commit 309e1e2b1d
  1. 2
      modules/core/include/opencv2/core/cvdef.h
  2. 8
      modules/core/include/opencv2/core/mat.hpp
  3. 18
      modules/core/include/opencv2/core/mat.inl.hpp
  4. 64
      modules/core/src/matrix_wrap.cpp
  5. 1
      modules/core/test/test_mat.cpp

@ -400,7 +400,9 @@ typedef union Cv64suf
}
Cv64suf;
#ifndef OPENCV_ABI_COMPATIBILITY
#define OPENCV_ABI_COMPATIBILITY 300
#endif
#ifdef __OPENCV_BUILD
# define DISABLE_OPENCV_24_COMPATIBILITY

@ -170,7 +170,9 @@ public:
STD_VECTOR = 3 << KIND_SHIFT,
STD_VECTOR_VECTOR = 4 << KIND_SHIFT,
STD_VECTOR_MAT = 5 << KIND_SHIFT,
EXPR = 6 << KIND_SHIFT, //!< removed
#if OPENCV_ABI_COMPATIBILITY < 500
EXPR = 6 << KIND_SHIFT, //!< removed: https://github.com/opencv/opencv/pull/17046
#endif
OPENGL_BUFFER = 7 << KIND_SHIFT,
CUDA_HOST_MEM = 8 << KIND_SHIFT,
CUDA_GPU_MAT = 9 << KIND_SHIFT,
@ -178,7 +180,9 @@ public:
STD_VECTOR_UMAT =11 << KIND_SHIFT,
STD_BOOL_VECTOR =12 << KIND_SHIFT,
STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT,
STD_ARRAY =14 << KIND_SHIFT,
#if OPENCV_ABI_COMPATIBILITY < 500
STD_ARRAY =14 << KIND_SHIFT, //!< removed: https://github.com/opencv/opencv/issues/18897
#endif
STD_ARRAY_MAT =15 << KIND_SHIFT
};

@ -112,7 +112,7 @@ _InputArray::_InputArray(const std::vector<_Tp>& vec)
#ifdef CV_CXX_STD_ARRAY
template<typename _Tp, std::size_t _Nm> inline
_InputArray::_InputArray(const std::array<_Tp, _Nm>& arr)
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_READ, arr.data(), Size(1, _Nm)); }
{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ, arr.data(), Size(1, _Nm)); }
template<std::size_t _Nm> inline
_InputArray::_InputArray(const std::array<Mat, _Nm>& arr)
@ -176,7 +176,7 @@ template<typename _Tp, std::size_t _Nm> inline
_InputArray _InputArray::rawIn(const std::array<_Tp, _Nm>& arr)
{
_InputArray v;
v.flags = FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_READ;
v.flags = FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_READ;
v.obj = (void*)arr.data();
v.sz = Size(1, _Nm);
return v;
@ -199,7 +199,7 @@ inline bool _InputArray::isUMatVector() const { return kind() == _InputArray::S
inline bool _InputArray::isMatx() const { return kind() == _InputArray::MATX; }
inline bool _InputArray::isVector() const { return kind() == _InputArray::STD_VECTOR ||
kind() == _InputArray::STD_BOOL_VECTOR ||
kind() == _InputArray::STD_ARRAY; }
(kind() == _InputArray::MATX && (sz.width <= 1 || sz.height <= 1)); }
inline bool _InputArray::isGpuMat() const { return kind() == _InputArray::CUDA_GPU_MAT; }
inline bool _InputArray::isGpuMatVector() const { return kind() == _InputArray::STD_VECTOR_CUDA_GPU_MAT; }
@ -219,7 +219,7 @@ _OutputArray::_OutputArray(std::vector<_Tp>& vec)
#ifdef CV_CXX_STD_ARRAY
template<typename _Tp, std::size_t _Nm> inline
_OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr)
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
template<std::size_t _Nm> inline
_OutputArray::_OutputArray(std::array<Mat, _Nm>& arr)
@ -261,7 +261,7 @@ _OutputArray::_OutputArray(const std::vector<_Tp>& vec)
#ifdef CV_CXX_STD_ARRAY
template<typename _Tp, std::size_t _Nm> inline
_OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr)
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
template<std::size_t _Nm> inline
_OutputArray::_OutputArray(const std::array<Mat, _Nm>& arr)
@ -336,7 +336,7 @@ template<typename _Tp, std::size_t _Nm> inline
_OutputArray _OutputArray::rawOut(std::array<_Tp, _Nm>& arr)
{
_OutputArray v;
v.flags = FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_WRITE;
v.flags = FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_WRITE;
v.obj = (void*)arr.data();
v.sz = Size(1, _Nm);
return v;
@ -359,7 +359,7 @@ _InputOutputArray::_InputOutputArray(std::vector<_Tp>& vec)
#ifdef CV_CXX_STD_ARRAY
template<typename _Tp, std::size_t _Nm> inline
_InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr)
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); }
{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); }
template<std::size_t _Nm> inline
_InputOutputArray::_InputOutputArray(std::array<Mat, _Nm>& arr)
@ -396,7 +396,7 @@ _InputOutputArray::_InputOutputArray(const std::vector<_Tp>& vec)
#ifdef CV_CXX_STD_ARRAY
template<typename _Tp, std::size_t _Nm> inline
_InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr)
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); }
{ init(FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW, arr.data(), Size(1, _Nm)); }
template<std::size_t _Nm> inline
_InputOutputArray::_InputOutputArray(const std::array<Mat, _Nm>& arr)
@ -473,7 +473,7 @@ template<typename _Tp, std::size_t _Nm> inline
_InputOutputArray _InputOutputArray::rawInOut(std::array<_Tp, _Nm>& arr)
{
_InputOutputArray v;
v.flags = FIXED_TYPE + FIXED_SIZE + STD_ARRAY + traits::Type<_Tp>::value + ACCESS_RW;
v.flags = FIXED_TYPE + FIXED_SIZE + MATX + traits::Type<_Tp>::value + ACCESS_RW;
v.obj = (void*)arr.data();
v.sz = Size(1, _Nm);
return v;

@ -32,7 +32,7 @@ Mat _InputArray::getMat_(int i) const
return m->getMat(accessFlags).row(i);
}
if( k == MATX || k == STD_ARRAY )
if (k == MATX)
{
CV_Assert( i < 0 );
return Mat(sz, flags, obj);
@ -172,7 +172,7 @@ void _InputArray::getMatVector(std::vector<Mat>& mv) const
return;
}
if( k == MATX || k == STD_ARRAY )
if (k == MATX)
{
size_t n = sz.height, esz = CV_ELEM_SIZE(flags);
mv.resize(n);
@ -361,7 +361,14 @@ ogl::Buffer _InputArray::getOGlBuffer() const
int _InputArray::kind() const
{
int k = flags & KIND_MASK;
#if CV_VERSION_MAJOR < 5
CV_DbgAssert(k != EXPR);
#if CV_VERSION_MAJOR < 4
if (k == STD_ARRAY)
k = MATX;
#endif
CV_DbgAssert(k != STD_ARRAY);
#endif
return k;
}
@ -391,7 +398,7 @@ Size _InputArray::size(int i) const
return ((const UMat*)obj)->size();
}
if( k == MATX || k == STD_ARRAY )
if (k == MATX)
{
CV_Assert( i < 0 );
return sz;
@ -610,7 +617,7 @@ int _InputArray::dims(int i) const
return ((const UMat*)obj)->dims;
}
if( k == MATX || k == STD_ARRAY )
if (k == MATX)
{
CV_Assert( i < 0 );
return 2;
@ -744,7 +751,7 @@ int _InputArray::type(int i) const
if( k == UMAT )
return ((const UMat*)obj)->type();
if( k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
if( k == MATX || k == STD_VECTOR || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return CV_MAT_TYPE(flags);
if( k == NONE )
@ -830,7 +837,7 @@ bool _InputArray::empty() const
if( k == UMAT )
return ((const UMat*)obj)->empty();
if( k == MATX || k == STD_ARRAY )
if (k == MATX)
return false;
if( k == STD_VECTOR )
@ -899,7 +906,7 @@ bool _InputArray::isContinuous(int i) const
if( k == UMAT )
return i < 0 ? ((const UMat*)obj)->isContinuous() : true;
if( k == MATX || k == STD_VECTOR || k == STD_ARRAY ||
if( k == MATX || k == STD_VECTOR ||
k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return true;
@ -940,7 +947,7 @@ bool _InputArray::isSubmatrix(int i) const
if( k == UMAT )
return i < 0 ? ((const UMat*)obj)->isSubmatrix() : false;
if( k == MATX || k == STD_VECTOR || k == STD_ARRAY ||
if( k == MATX || k == STD_VECTOR ||
k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return false;
@ -985,7 +992,7 @@ size_t _InputArray::offset(int i) const
return ((const UMat*)obj)->offset;
}
if( k == MATX || k == STD_VECTOR || k == STD_ARRAY ||
if( k == MATX || k == STD_VECTOR ||
k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return 0;
@ -1044,7 +1051,7 @@ size_t _InputArray::step(int i) const
return ((const UMat*)obj)->step;
}
if( k == MATX || k == STD_VECTOR || k == STD_ARRAY ||
if( k == MATX || k == STD_VECTOR ||
k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR )
return 0;
@ -1090,7 +1097,7 @@ void _InputArray::copyTo(const _OutputArray& arr) const
if( k == NONE )
arr.release();
else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == STD_BOOL_VECTOR )
else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_BOOL_VECTOR )
{
Mat m = getMat();
m.copyTo(arr);
@ -1111,7 +1118,7 @@ void _InputArray::copyTo(const _OutputArray& arr, const _InputArray & mask) cons
if( k == NONE )
arr.release();
else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == STD_BOOL_VECTOR )
else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_BOOL_VECTOR )
{
Mat m = getMat();
m.copyTo(arr, mask);
@ -1299,16 +1306,27 @@ void _OutputArray::create(int d, const int* sizes, int mtype, int i,
CV_Assert( i < 0 );
int type0 = CV_MAT_TYPE(flags);
CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) );
CV_Assert( d == 2 && ((sizes[0] == sz.height && sizes[1] == sz.width) ||
(allowTransposed && sizes[0] == sz.width && sizes[1] == sz.height)));
return;
}
if( k == STD_ARRAY )
{
int type0 = CV_MAT_TYPE(flags);
CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) );
CV_Assert( d == 2 && sz.area() == sizes[0]*sizes[1]);
CV_CheckLE(d, 2, "");
Size requested_size(d == 2 ? sizes[1] : 1, d >= 1 ? sizes[0] : 1);
if (sz.width == 1 || sz.height == 1)
{
// NB: 1D arrays assume allowTransposed=true (see #4159)
int total_1d = std::max(sz.width, sz.height);
CV_Check(requested_size, std::max(requested_size.width, requested_size.height) == total_1d, "");
}
else
{
if (!allowTransposed)
{
CV_CheckEQ(requested_size, sz, "");
}
else
{
CV_Check(requested_size,
(requested_size == sz || (requested_size.height == sz.width && requested_size.width == sz.height)),
"");
}
}
return;
}
@ -1770,7 +1788,7 @@ void _OutputArray::setTo(const _InputArray& arr, const _InputArray & mask) const
if( k == NONE )
;
else if( k == MAT || k == MATX || k == STD_VECTOR || k == STD_ARRAY )
else if (k == MAT || k == MATX || k == STD_VECTOR)
{
Mat m = getMat();
m.setTo(arr, mask);

@ -1998,7 +1998,6 @@ class TestInputArrayRangeChecking {
C(EXPR);
C(MATX);
C(STD_VECTOR);
C(STD_ARRAY);
C(NONE);
C(STD_VECTOR_VECTOR);
C(STD_BOOL_VECTOR);

Loading…
Cancel
Save