fromYuvPlanes static method
Creates an Image from the specified YUV planes.
param yPlane A buffer that contains the Y plane. param uPlane A buffer that contains the U plane. param vPlane A buffer that contains the V plane. param yWidth The width, in pixels, of the Y plane. param yHeight The height, in pixels, of the Y plane. param uvPixelStride The pixel-level stride, in pixels, of the U and V planes. param uvRowStride The row-level stride, in pixels, of the U and V planes. param dstPixelFormat The pixel format into which to convert the input image. return The newly created image. throws FaceException An error has occurred during Face Library execution.
Implementation
static Image fromYuvPlanes(Uint8List? yPlane, Uint8List? uPlane, Uint8List? vPlane, int yWidth, int yHeight, int uvPixelStride, int uvRowStride, PixelFormat dstPixelFormat) {
Image image = Image();
Pointer<UnsignedChar>? pYPlane;
if (yPlane != null) {
pYPlane = calloc.allocate<UnsignedChar>(yPlane.length);
pYPlane.cast<Uint8>().asTypedList(yPlane.length).setAll(0, yPlane);
}
Pointer<UnsignedChar>? pUPlane;
if (uPlane != null) {
pUPlane = calloc.allocate<UnsignedChar>(uPlane.length);
pUPlane.cast<Uint8>().asTypedList(uPlane.length).setAll(0, uPlane);
}
Pointer<UnsignedChar>? pVPlane;
if (vPlane != null) {
pVPlane = calloc.allocate<UnsignedChar>(vPlane.length);
pVPlane.cast<Uint8>().asTypedList(vPlane.length).setAll(0, vPlane);
}
try {
var err = faceSDK.id3FaceImage_FromYuvPlanes(image.handle, pYPlane ?? nullptr, yPlane?.length ?? 0, pUPlane ?? nullptr, uPlane?.length ?? 0, pVPlane ?? nullptr, vPlane?.length ?? 0, yWidth, yHeight, uvPixelStride, uvRowStride, dstPixelFormat.value);
if (err != FaceError.success.value) {
image.dispose();
throw FaceException(err);
}
return image;
} finally {
if (pYPlane != null) {
calloc.free(pYPlane);
}
if (pUPlane != null) {
calloc.free(pUPlane);
}
if (pVPlane != null) {
calloc.free(pVPlane);
}
}
}