Impove the documentation for Mat::diag
authorFangjun KUANG <csukuangfj@gmail.com>
Mon, 13 Mar 2017 11:46:50 +0000 (12:46 +0100)
committerGitHub <noreply@github.com>
Mon, 13 Mar 2017 11:46:50 +0000 (12:46 +0100)
modules/core/include/opencv2/core/mat.hpp

index 331835d..792f97b 100644 (file)
@@ -1085,6 +1085,29 @@ public:
       immediately below the main one.
     - `d>0` is a diagonal from the upper half. For example, d=1 means the diagonal is set
       immediately above the main one.
+    For example:
+    @code
+        Mat m = (Mat_<int>(3,3) <<
+                    1,2,3,
+                    4,5,6,
+                    7,8,9);
+        Mat d0 = m.diag(0);
+        Mat d1 = m.diag(1);
+        Mat d_1 = m.diag(-1);
+    @endcode
+    The resulting matrices are
+    @code
+     d0 =
+       [1;
+        5;
+        9]
+     d1 =
+       [2;
+        6]
+     d_1 =
+       [4;
+        8]
+    @endcode
      */
     Mat diag(int d=0) const;