forEachRow method

void forEachRow(
  1. void callback(
    1. int row,
    2. List<num> values
    )
)

Iterate over all rows in the Mat.

Similar to forEachPixel, the parameter values of callback is a view of the row at every row, which means it can be modified and the original values in the Mat will be changed too.

Implementation

void forEachRow(void Function(int row, List<num> values) callback) {
  // cache necessary props, they will be only get once
  final depth = type.depth, pdata = dataPtr, step = this.step, channels = this.channels;
  final rows = this.rows, cols = this.cols;

  for (int row = 0; row < rows; row++) {
    final pp = pdata + row * step.$1;
    callback(row, _ptrAsTypedList(pp, channels * cols, depth));
  }
}