imencodeVecAsync function
Same as imencodeAsync but returns VecUChar
Implementation
Future<(bool, VecUChar)> imencodeVecAsync(
String ext,
InputArray img, {
VecI32? params,
}) async {
final buffer = VecUChar();
final pSuccess = calloc<ffi.Bool>();
final cExt = ext.toNativeUtf8().cast<ffi.Char>();
void completeFunc(Completer<(bool, VecUChar)> c) {
final success = pSuccess.value;
calloc.free(cExt);
calloc.free(pSuccess);
return c.complete((success, buffer));
}
if (params == null) {
return cvRunAsync0(
(callback) => cimgcodecs.cv_imencode(cExt, img.ref, pSuccess, buffer.ptr, callback),
completeFunc,
);
}
return cvRunAsync0(
(callback) => cimgcodecs.cv_imencode_1(cExt, img.ref, params.ref, pSuccess, buffer.ptr, callback),
completeFunc,
);
}