@@ -1330,17 +1330,23 @@ class Mat extends CvStruct<cvg.Mat> {
13301330 return List .generate (rows, (row) => List .generate (cols, (col) => at <T >(row, col).val));
13311331 }
13321332
1333- /// Get the data pointer of the Mat, this getter will reture a view of native
1334- /// data, and will be GCed when the Mat is GCed.
1333+ /// Get a view of native data, and will be GCed when the Mat is GCed.
13351334 Uint8List get data {
1336- return cvRunArena <Uint8List >((arena) {
1337- final p = calloc< ffi.Pointer <cvg.uchar>> ();
1338- final plen = arena< ffi.Int > ();
1339- cvRun (() => CFFI .Mat_DataPtr (ref, p, plen));
1340- final ret = p.value.cast< ffi.Uint8 > ().asTypedList (plen.value);
1341- calloc.free (p);
1342- return ret;
1343- });
1335+ final (p, len) = dataPtr;
1336+ return p.asTypedList (len);
1337+ }
1338+
1339+ /// Get the data pointer of the Mat
1340+ ///
1341+ /// DO NOT free the pointer, the native memory is managed by [Mat]
1342+ (ffi.Pointer <ffi.Uint8 > ptr, int len) get dataPtr {
1343+ final p = calloc< ffi.Pointer <cvg.uchar>> ();
1344+ final plen = calloc< ffi.Int > ();
1345+ cvRun (() => CFFI .Mat_DataPtr (ref, p, plen));
1346+ final ret = (p.value.cast< ffi.Uint8 > (), plen.value);
1347+ calloc.free (p);
1348+ calloc.free (plen);
1349+ return ret;
13441350 }
13451351
13461352 @override
0 commit comments