Mat.eye constructor

Mat.eye(
  1. int rows,
  2. int cols,
  3. MatType type
)

Returns an identity matrix of the specified size and type.

The method returns a Matlab-style identity matrix initializer, similarly to Mat::zeros. Similarly to Mat::ones, you can use a scale operation to create a scaled identity matrix efficiently:

// make a 4x4 diagonal matrix with 0.1's on the diagonal.
Mat A = Mat::eye(4, 4, CV_32F)*0.1;

Note In case of multi-channels type, identity matrix will be initialized only for the first channel, the others will be set to 0's

rows Number of rows.

cols Number of columns.

type Created matrix type.

https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html#a458874f0ab8946136254da37ba06b78b

Implementation

factory Mat.eye(int rows, int cols, MatType type) {
  final p = calloc<ccore.Mat>();
  cvRun(() => ccore.Eye(rows, cols, type.value, p));
  final mat = Mat._(p);
  return mat;
}