matFromPackedLayout function

Mat matFromPackedLayout(
  1. PackedImageLayout layout,
  2. Uint8List bytes,
  3. MatType type
)

Rebuilds a cv.Mat from a backend-neutral packed image layout.

Implementation

cv.Mat matFromPackedLayout(
  PackedImageLayout layout,
  Uint8List bytes,
  cv.MatType type,
) {
  final cv.Mat mat = cv.Mat.create(
    rows: layout.rows,
    cols: layout.cols,
    type: type,
  );
  try {
    layout.copyTo(mat.data, bytes);
    return mat;
  } catch (_) {
    mat.dispose();
    rethrow;
  }
}