Mat.fromVec constructor

Mat.fromVec(
  1. Vec<Struct, dynamic> vec, {
  2. int? rows,
  3. int? cols,
  4. MatType? type,
})

Implementation

factory Mat.fromVec(Vec vec, {int? rows, int? cols, MatType? type}) {
  final p = calloc<ccore.Mat>();
  switch (vec) {
    case VecPoint():
      cvRun(() => ccore.Mat_NewFromVecPoint(vec.ref, p));
    case VecPoint2f():
      cvRun(() => ccore.Mat_NewFromVecPoint2f(vec.ref, p));
    case VecPoint3f():
      cvRun(() => ccore.Mat_NewFromVecPoint3f(vec.ref, p));
    case VecPoint3i():
      cvRun(() => ccore.Mat_NewFromVecPoint3i(vec.ref, p));
    case VecU8() when rows != null && cols != null && type != null:
    case VecI8() when rows != null && cols != null && type != null:
    case VecU16() when rows != null && cols != null && type != null:
    case VecI16() when rows != null && cols != null && type != null:
    case VecI32() when rows != null && cols != null && type != null:
    case VecF32() when rows != null && cols != null && type != null:
    case VecF64() when rows != null && cols != null && type != null:
    case VecF16() when rows != null && cols != null && type != null:
      cvRun(() => ccore.Mat_NewFromBytes(rows, cols, type.value, vec.asVoid(), p));
    default:
      throw UnsupportedError("Unsupported Vec type ${vec.runtimeType}");
  }
  vec.dispose();
  return Mat._(p);
}