From 28297c0224da233844852b90e858aa765f0b7532 Mon Sep 17 00:00:00 2001 From: Maria Dimashova Date: Fri, 18 May 2012 14:38:54 +0000 Subject: [PATCH] fixed Mat::diag (#1939) --- modules/core/include/opencv2/core/mat.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 29234b073d..6b86cd7e43 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -322,7 +322,10 @@ inline Mat Mat::diag(const Mat& d) CV_Assert( d.cols == 1 || d.rows == 1 ); int len = d.rows + d.cols - 1; Mat m(len, len, d.type(), Scalar(0)), md = m.diag(); - d.copyTo(md); + if( d.cols == 1 ) + d.copyTo(md); + else + transpose(d, md); return m; }