diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 4007031b2f..05edeac523 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -170,7 +170,7 @@ public: STD_VECTOR = 3 << KIND_SHIFT, STD_VECTOR_VECTOR = 4 << KIND_SHIFT, STD_VECTOR_MAT = 5 << KIND_SHIFT, - EXPR = 6 << KIND_SHIFT, + EXPR = 6 << KIND_SHIFT, //!< removed OPENGL_BUFFER = 7 << KIND_SHIFT, CUDA_HOST_MEM = 8 << KIND_SHIFT, CUDA_GPU_MAT = 9 << KIND_SHIFT, diff --git a/modules/core/src/matrix_expressions.cpp b/modules/core/src/matrix_expressions.cpp index d4f8b743cf..58c99ed19a 100644 --- a/modules/core/src/matrix_expressions.cpp +++ b/modules/core/src/matrix_expressions.cpp @@ -1739,13 +1739,7 @@ MatExpr Mat::mul(InputArray m, double scale) const CV_INSTRUMENT_REGION(); MatExpr e; - if(m.kind() == _InputArray::EXPR) - { - const MatExpr& me = *(const MatExpr*)m.getObj(); - me.op->multiply(MatExpr(*this), me, e, scale); - } - else - MatOp_Bin::makeExpr(e, '*', *this, m.getMat(), scale); + MatOp_Bin::makeExpr(e, '*', *this, m.getMat(), scale); return e; } @@ -1840,7 +1834,6 @@ void MatExpr::swap(MatExpr& other) _InputArray::_InputArray(const MatExpr& expr) { -#if 1 if (!isIdentity(expr)) { Mat result = expr; // TODO improve through refcount == 1 of expr.a (inplace operation is possible - except gemm?) @@ -1849,9 +1842,6 @@ _InputArray::_InputArray(const MatExpr& expr) } CV_Assert(isIdentity(expr)); init(FIXED_TYPE + FIXED_SIZE + MAT + ACCESS_READ, &expr.a); -#else - init(FIXED_TYPE + FIXED_SIZE + EXPR + ACCESS_READ, &expr); -#endif } } // cv:: diff --git a/modules/core/src/matrix_wrap.cpp b/modules/core/src/matrix_wrap.cpp index 4c5efd6ba5..d410ab7719 100644 --- a/modules/core/src/matrix_wrap.cpp +++ b/modules/core/src/matrix_wrap.cpp @@ -33,12 +33,6 @@ Mat _InputArray::getMat_(int i) const return m->getMat(accessFlags).row(i); } - if( k == EXPR ) - { - CV_Assert( i < 0 ); - return (Mat)*((const MatExpr*)obj); - } - if( k == MATX || k == STD_ARRAY ) { CV_Assert( i < 0 ); @@ -179,17 +173,6 @@ void _InputArray::getMatVector(std::vector& mv) const return; } - if( k == EXPR ) - { - Mat m = *(const MatExpr*)obj; - int n = m.size[0]; - mv.resize(n); - - for( int i = 0; i < n; i++ ) - mv[i] = m.row(i); - return; - } - if( k == MATX || k == STD_ARRAY ) { size_t n = sz.height, esz = CV_ELEM_SIZE(flags); @@ -378,7 +361,9 @@ ogl::Buffer _InputArray::getOGlBuffer() const int _InputArray::kind() const { - return flags & KIND_MASK; + int k = flags & KIND_MASK; + CV_DbgAssert(k != EXPR); + return k; } int _InputArray::rows(int i) const @@ -401,12 +386,6 @@ Size _InputArray::size(int i) const return ((const Mat*)obj)->size(); } - if( k == EXPR ) - { - CV_Assert( i < 0 ); - return ((const MatExpr*)obj)->size(); - } - if( k == UMAT ) { CV_Assert( i < 0 ); @@ -569,7 +548,7 @@ int _InputArray::sizend(int* arrsz, int i) const } else { - CV_CheckLE(dims(i), 2, "Not supported"); // TODO Support EXPR with 3+ dims + CV_CheckLE(dims(i), 2, "Not supported"); Size sz2d = size(i); d = 2; if(arrsz) @@ -626,12 +605,6 @@ int _InputArray::dims(int i) const return ((const Mat*)obj)->dims; } - if( k == EXPR ) - { - CV_Assert( i < 0 ); - return ((const MatExpr*)obj)->a.dims; - } - if( k == UMAT ) { CV_Assert( i < 0 ); @@ -772,9 +745,6 @@ int _InputArray::type(int i) const if( k == UMAT ) return ((const UMat*)obj)->type(); - if( k == EXPR ) - return ((const MatExpr*)obj)->type(); - if( k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR ) return CV_MAT_TYPE(flags); @@ -861,9 +831,6 @@ bool _InputArray::empty() const if( k == UMAT ) return ((const UMat*)obj)->empty(); - if( k == EXPR ) - return false; - if( k == MATX || k == STD_ARRAY ) return false; @@ -933,7 +900,7 @@ bool _InputArray::isContinuous(int i) const if( k == UMAT ) return i < 0 ? ((const UMat*)obj)->isContinuous() : true; - if( k == EXPR || k == MATX || k == STD_VECTOR || k == STD_ARRAY || + if( k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR ) return true; @@ -974,7 +941,7 @@ bool _InputArray::isSubmatrix(int i) const if( k == UMAT ) return i < 0 ? ((const UMat*)obj)->isSubmatrix() : false; - if( k == EXPR || k == MATX || k == STD_VECTOR || k == STD_ARRAY || + if( k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR ) return false; @@ -1019,7 +986,7 @@ size_t _InputArray::offset(int i) const return ((const UMat*)obj)->offset; } - if( k == EXPR || k == MATX || k == STD_VECTOR || k == STD_ARRAY || + if( k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR ) return 0; @@ -1082,7 +1049,7 @@ size_t _InputArray::step(int i) const return ((const UMat*)obj)->step; } - if( k == EXPR || k == MATX || k == STD_VECTOR || k == STD_ARRAY || + if( k == MATX || k == STD_VECTOR || k == STD_ARRAY || k == NONE || k == STD_VECTOR_VECTOR || k == STD_BOOL_VECTOR ) return 0; @@ -1137,14 +1104,6 @@ void _InputArray::copyTo(const _OutputArray& arr) const Mat m = getMat(); m.copyTo(arr); } - else if( k == EXPR ) - { - const MatExpr& e = *((MatExpr*)obj); - if( arr.kind() == MAT ) - arr.getMatRef() = e; - else - Mat(e).copyTo(arr); - } else if( k == UMAT ) ((UMat*)obj)->copyTo(arr); #ifdef HAVE_CUDA