From c5088ca1b843a9f0a1c3c1a4f8b31add03c25fd6 Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Sun, 19 Jun 2011 21:13:32 +0000 Subject: [PATCH] added explicit Mat_::Mat_(const MatExpr&) (resolves ticket #996) --- modules/core/include/opencv2/core/core.hpp | 6 ++++-- modules/core/include/opencv2/core/mat.hpp | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index 2c14772..dc75f4d 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -2535,6 +2535,8 @@ public: Mat_(const Mat_& m, const Rect& roi); //! selects a submatrix, n-dim version Mat_(const Mat_& m, const Range* ranges); + //! from a matrix expression + explicit Mat_(const MatExpr& e); //! makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column explicit Mat_(const vector<_Tp>& vec, bool copyData=false); template explicit Mat_(const Vec::channel_type, n>& vec, bool copyData=true); @@ -2547,6 +2549,8 @@ public: Mat_& operator = (const Mat_& m); //! set all the elements to s. Mat_& operator = (const _Tp& s); + //! assign a matrix expression + Mat_& operator = (const MatExpr& e); //! iterators; they are smart enough to skip gaps in the end of rows iterator begin(); @@ -2562,8 +2566,6 @@ public: void create(int _ndims, const int* _sizes); //! cross-product Mat_ cross(const Mat_& m) const; - //! to support complex matrix expressions - Mat_& operator = (const MatExpr& expr); //! data type conversion template operator Mat_() const; //! overridden forms of Mat::row() etc. diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index d4300c7..a696738 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -892,7 +892,6 @@ template inline Mat_<_Tp>& Mat_<_Tp>::operator = (const _Tp& s) Mat::operator=(Scalar((const VT&)s)); return *this; } - template inline void Mat_<_Tp>::create(int _rows, int _cols) { @@ -1335,6 +1334,11 @@ inline Mat& Mat::operator = (const MatExpr& e) return *this; } +template inline Mat_<_Tp>::Mat_(const MatExpr& e) +{ + e.op->assign(e, *this, DataType<_Tp>::type); +} + template Mat_<_Tp>& Mat_<_Tp>::operator = (const MatExpr& e) { e.op->assign(e, *this, DataType<_Tp>::type); -- 2.7.4