Mat.fromVec constructor
vec
can be an instance of VecPoint, VecPoint2f, VecPoint3f, VecPoint3i,
VecU8, VecI8, VecU16, VecI16, VecI32, VecF32, VecF64, VecF16
data will be copied, if vec
is large, remember to dispose it.
Implementation
factory Mat.fromVec(Vec vec, {int? rows, int? cols, MatType? type}) {
final p = calloc<cvg.Mat>();
switch (vec) {
case VecPoint():
cvRun(() => ccore.cv_Mat_create_7(vec.ref, p, ffi.nullptr));
case VecPoint2f():
cvRun(() => ccore.cv_Mat_create_8(vec.ref, p, ffi.nullptr));
case VecPoint3f():
cvRun(() => ccore.cv_Mat_create_9(vec.ref, p, ffi.nullptr));
case VecPoint3i():
cvRun(() => ccore.cv_Mat_create_10(vec.ref, p, ffi.nullptr));
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.cv_Mat_create_6(rows, cols, type.value, vec.asVoid(), p, ffi.nullptr));
default:
throw UnsupportedError("Unsupported Vec type ${vec.runtimeType}");
}
return Mat._(p);
}