setNum method

void setNum(
  1. int i0,
  2. int i1,
  3. num val, [
  4. int? i2,
])

Implementation

void setNum(int i0, int i1, num val, [int? i2]) {
  switch (type.depth) {
    case MatType.CV_8U:
      i2 == null ? (ptrAt<U8>(i0) + i1).value = val.toInt() : ptrAt<U8>(i0, i1, i2).value = val.toInt();
    case MatType.CV_8S:
      i2 == null ? (ptrAt<I8>(i0) + i1).value = val.toInt() : ptrAt<I8>(i0, i1, i2).value = val.toInt();
    case MatType.CV_16U:
      i2 == null ? (ptrAt<U16>(i0) + i1).value = val.toInt() : ptrAt<U16>(i0, i1, i2).value = val.toInt();
    case MatType.CV_16S:
      i2 == null ? (ptrAt<I16>(i0) + i1).value = val.toInt() : ptrAt<I16>(i0, i1, i2).value = val.toInt();
    case MatType.CV_32S:
      i2 == null ? (ptrAt<I32>(i0) + i1).value = val.toInt() : ptrAt<I32>(i0, i1, i2).value = val.toInt();
    case MatType.CV_32F:
      i2 == null
          ? (ptrAt<F32>(i0) + i1).value = val.toDouble()
          : ptrAt<F32>(i0, i1, i2).value = val.toDouble();
    case MatType.CV_64F:
      i2 == null
          ? (ptrAt<F64>(i0) + i1).value = val.toDouble()
          : ptrAt<F64>(i0, i1, i2).value = val.toDouble();
    // TODO: waiting for official impl
    case MatType.CV_16F:
      Float16P(i2 == null ? (ptrAt<U16>(i0) + i1) : ptrAt<U16>(i0, i1, i2)).value = val.toDouble();
    case _:
      throw UnsupportedError("Unsupported type: ${type.asString()}");
  }
}