capture method Null safety
- Uint8List encodedImage
Capture faces in a given encoded image or video frame.
Implementation
List<RawSample> capture(Uint8List encodedImage) {
final cap = _dll_handle.lookupFunction<_CapturerCapBytes_c, _CapturerCapBytes_dart>(_c_namespace + 'Capturer_capture_encoded_image');
final Pointer<Uint8> frameData = malloc.allocate<Uint8>(encodedImage.length);
final pointerList = frameData.asTypedList(encodedImage.length);
Pointer<Pointer<Void>> _emptyPointerList = malloc.allocate(sizeOf<Pointer<Pointer<Void>>>() * 100);
Pointer<Pointer<Void>> exception = _getException();
List<int> addressBefore = new List<int>.generate(100, (i) => _emptyPointerList[i].address);
pointerList.setAll(0, encodedImage);
cap(_impl, frameData.cast(), encodedImage.length, _emptyPointerList.cast(), Pointer.fromFunction(_assign_pointers_vector_func), exception);
checkException(exception, _dll_handle);
List<RawSample> rss = [];
for (var i = 0; i < 100; i++) {
if (addressBefore[i] != _emptyPointerList[i].address)
rss.add(RawSample(_dll_handle, _emptyPointerList[i]));
else
break;
}
malloc.free(_emptyPointerList);
malloc.free(frameData);
return rss;
}