-
Notifications
You must be signed in to change notification settings - Fork 32
Pass Uint8List to Pointer<Void> #27
Comments
Hey @theochampion, The Uint8List lives in the Dart heap, which is garbage collected, and the objects might be moved around by the garbage collector. So, you'll have to convert it into a pointer into the C heap. Uint8List list;
final pointer = allocate<Uint8>(count: list.length);
for(int i = 0, ...){
pointer[i] = list[i];
}
final voidStar = pointer.cast<Void>();
// function call
free(pointer); |
@theochampion, does this work for you? I'll close this issue, please reopen if need be. |
@dcharkes I am trying to get image data copied as a pointer and pass it to a opencv c++ function using dart ffi. Could you give me a hint of how to make it work? TIA |
@muck27 could you give more details. P.S. Feel free to open a new issue rather than reusing an old one if you have a different problem. |
Hi @dcharkes, Also from which package |
This package.
Must have been a typo on my side. It is indeed a property: https://api.dart.dev/stable/2.17.5/dart-core/List/length.html |
Note for people coming across this issue:
|
Hi there,
I have a C function with the Following signature
data here being a raw image.
My ffi function signature is:
(the bools have to be converted to ints because the bool type is not supported yet (right?))
I'm trying to call this method from dart with a
Uint8List
coming from a frame of the camera stream https://pub.dev/documentation/camera/latest/camera/Plane-class.html but I'm not sure how to convert/allocate myUint8List
tovoid *
Any idea?
Cheers!
The text was updated successfully, but these errors were encountered: