From 829e558d48fb5eff196924faf601db6bca0b8556 Mon Sep 17 00:00:00 2001 From: Ilya Lysenkov Date: Tue, 10 Apr 2012 13:02:58 +0000 Subject: [PATCH] Andrey, Maria and I fixed Mat::diag() --- modules/core/include/opencv2/core/mat.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 4bd1bb7a65..f2f14fe0e9 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -319,8 +319,8 @@ inline Mat Mat::colRange(const Range& r) const inline Mat Mat::diag(const Mat& d) { - CV_Assert( d.cols == 1 ); - Mat m(d.rows, d.rows, d.type(), Scalar(0)), md = m.diag(); + CV_Assert( d.cols == 1 || d.rows == 1 ); + Mat m(d.total(), d.total(), d.type(), Scalar(0)), md = m.diag(); d.copyTo(md); return m; }