ptrAt<T extends NativeType> method
equivalent to Mat::ptr<T>(i0, i1, i2)
DANGEROUS
returns a pointer to operate Mat directly and effectively, use with caution!
Example:
final mat = cv.Mat.ones(3, 3, cv.MatType.CV_8UC1);
mat.set<int>(0, 0, 99);
final ptr = mat.ptrAt<cv.U8>(0, 0);
print(ptr[0]); // 99
ptr[0] = 21;
// Mat::ptr(i, j)
print(mat.at<int>(0, 0)); // 21
print(ptr[0]); // 21
final ptr1 = mat.ptrAt<cv.U8>(0);
print(ptr1[0]); // 21
print(List.generate(mat.cols, (i)=>ptr1[i]); // [21, 1, 1]
https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html#a8b2912f6a6f5d55a3c9a7aae9134d862
Implementation
ffi.Pointer<T> ptrAt<T extends ffi.NativeType>(int i0, [int? i1, int? i2]) {
return switch ((i1, i2)) {
(null, null) => ccore.cv_Mat_ptr_uchar_1(ref, i0).cast<T>(),
(final int i1, null) => ccore.cv_Mat_ptr_uchar_2(ref, i0, i1).cast<T>(),
(final int i1, final int i2) => ccore.cv_Mat_ptr_uchar_3(ref, i0, i1, i2).cast<T>(),
_ => throw UnsupportedError("ptrAt<$T>() for i1=$i1, i2=$i2 is not supported!"),
};
}